diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9c210e34..12d4f5d5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ minimum_pre_commit_version: 2.20.0 fail_fast: false default_stages: - - commit + - pre-commit exclude: (.idea|vscode) repos: - repo: https://github.com/pre-commit/pre-commit-hooks diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c00d3d7..5f25591d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,217 @@ # CHANGELOG +## v3.1.0-rc.8 (2025-01-21) + +### Bug Fixes + +- 🐛 create thread without messages plz ([#260](https://github.com/AI21Labs/ai21-python/pull/260), + [`9b73967`](https://github.com/AI21Labs/ai21-python/commit/9b73967be1762d8cd0e772a7455dc9db6ebbb9c0)) + +* fix: :bug: create thread without messages plz + +* docs: :memo: update assistant example + +--------- + +Co-authored-by: benshuk + +### Chores + +- :recycle: thread messages should be optional + ([`7198db9`](https://github.com/AI21Labs/ai21-python/commit/7198db963dd9d922ec290ac5f9e79b941a116075)) + +### Features + +- ✨ support deleting assistant ([#258](https://github.com/AI21Labs/ai21-python/pull/258), + [`0195f62`](https://github.com/AI21Labs/ai21-python/commit/0195f62ba33f2c5af0403f40e49d1a1865869a1a)) + +* feat: :sparkles: support deleting assistant + +* fix: :recycle: assistant route description should be optional + +--------- + +Co-authored-by: benshuk + + +## v3.1.0-rc.7 (2025-01-13) + +### Bug Fixes + +- Bad endpoint in async thread runs ([#255](https://github.com/AI21Labs/ai21-python/pull/255), + [`4a7dfe0`](https://github.com/AI21Labs/ai21-python/commit/4a7dfe0c642321c2f58c56b747586d830b1ade05)) + +- Change schemas field in PlanResponse to be optional + ([#257](https://github.com/AI21Labs/ai21-python/pull/257), + [`6d9d1a4`](https://github.com/AI21Labs/ai21-python/commit/6d9d1a416dc070076175430fcdd18b56bd658e5b)) + +### Chores + +- **release**: V3.1.0-rc.7 [skip ci] + ([`45d874c`](https://github.com/AI21Labs/ai21-python/commit/45d874cc46e382746cd3eaf2165222ff7318c7ca)) + + +## v3.1.0-rc.6 (2025-01-08) + +### Bug Fixes + +- Do not require all fields for RequiredAction + ([#253](https://github.com/AI21Labs/ai21-python/pull/253), + [`1714ccc`](https://github.com/AI21Labs/ai21-python/commit/1714ccc8538e7e0329f4dc564a8d40c92b650d81)) + +### Chores + +- **release**: V3.1.0-rc.6 [skip ci] + ([`0d8f306`](https://github.com/AI21Labs/ai21-python/commit/0d8f3060e69947a1d9ac5627b392c1ffb4fc3151)) + + +## v3.1.0-rc.5 (2025-01-08) + +### Bug Fixes + +- :bug: await needed for async `plans.create` + ([#252](https://github.com/AI21Labs/ai21-python/pull/252), + [`d646e99`](https://github.com/AI21Labs/ai21-python/commit/d646e99cdd1dabca423b62e7e001ca58c5105594)) + +Co-authored-by: benshuk + +### Chores + +- **deps-dev**: Bump jinja2 from 3.1.4 to 3.1.5 + ([#247](https://github.com/AI21Labs/ai21-python/pull/247), + [`2d36461`](https://github.com/AI21Labs/ai21-python/commit/2d36461958abeb267c7f664fd2c1ce43d59d5506)) + +Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.4 to 3.1.5. - [Release + notes](https://github.com/pallets/jinja/releases) - + [Changelog](https://github.com/pallets/jinja/blob/main/CHANGES.rst) - + [Commits](https://github.com/pallets/jinja/compare/3.1.4...3.1.5) + +--- updated-dependencies: - dependency-name: jinja2 dependency-type: indirect + +... + +Signed-off-by: dependabot[bot] + +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +- **release**: V3.1.0-rc.5 [skip ci] + ([`f2f7918`](https://github.com/AI21Labs/ai21-python/commit/f2f7918fc0336bd026efb02e2228546f6abbcc5d)) + +### Refactoring + +- :label: change `rag` tool resource to `file_search` + ([#251](https://github.com/AI21Labs/ai21-python/pull/251), + [`c09170f`](https://github.com/AI21Labs/ai21-python/commit/c09170fdc2ce93aa768704aa343c769af654d686)) + +Co-authored-by: benshuk + + +## v3.1.0-rc.4 (2025-01-08) + +### Chores + +- Add `error` to `RunResponse` model ([#248](https://github.com/AI21Labs/ai21-python/pull/248), + [`787d7d3`](https://github.com/AI21Labs/ai21-python/commit/787d7d3f5d612106dcd55f35894953564ce4fd2d)) + +Co-authored-by: benshuk + +- **deps**: Bump pypa/gh-action-pypi-publish from 1.12.2 to 1.12.3 + ([#240](https://github.com/AI21Labs/ai21-python/pull/240), + [`9890ade`](https://github.com/AI21Labs/ai21-python/commit/9890ade2d80fb23d7a89f237ca73110d5656e54a)) + +Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.12.2 to + 1.12.3. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - + [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/15c56dba361d8335944d31a2ecd17d700fc7bcbc...67339c736fd9354cd4f8cb0b744f2b82a74b5c70) + +--- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: + direct:production + +update-type: version-update:semver-patch + +... + +Signed-off-by: dependabot[bot] + +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +- **deps**: Bump python-semantic-release/python-semantic-release + ([#237](https://github.com/AI21Labs/ai21-python/pull/237), + [`baac390`](https://github.com/AI21Labs/ai21-python/commit/baac39091b6c0840d91c92426099586fd69a8b3e)) + +Bumps + [python-semantic-release/python-semantic-release](https://github.com/python-semantic-release/python-semantic-release) + from 9.14.0 to 9.15.1. - [Release + notes](https://github.com/python-semantic-release/python-semantic-release/releases) - + [Changelog](https://github.com/python-semantic-release/python-semantic-release/blob/master/CHANGELOG.md) + - + [Commits](https://github.com/python-semantic-release/python-semantic-release/compare/v9.14.0...v9.15.1) + +--- updated-dependencies: - dependency-name: python-semantic-release/python-semantic-release + dependency-type: direct:production + +update-type: version-update:semver-minor + +... + +Signed-off-by: dependabot[bot] + +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +- **release**: V3.1.0-rc.4 [skip ci] + ([`4327dbb`](https://github.com/AI21Labs/ai21-python/commit/4327dbbd38dcf1dead95eda3dcc88f0e03aedd70)) + +### Continuous Integration + +- Freeze poetry version ([#246](https://github.com/AI21Labs/ai21-python/pull/246), + [`5846d09`](https://github.com/AI21Labs/ai21-python/commit/5846d094edc09f84b32628421244bfc702af176b)) + +### Features + +- :sparkles: add support for `str` message content + ([#245](https://github.com/AI21Labs/ai21-python/pull/245), + [`23772dc`](https://github.com/AI21Labs/ai21-python/commit/23772dc5971914ce32853dcac38b3a0b59c9121c)) + +* feat: :sparkles: add support for `str` message content + +* fix: :label: typing + +* fix: :label: typing again + +* fix: :label: typing thingy + +--------- + +Co-authored-by: benshuk + +- :sparkles: add support for status polling for `Run` + ([#249](https://github.com/AI21Labs/ai21-python/pull/249), + [`7ff423d`](https://github.com/AI21Labs/ai21-python/commit/7ff423dbb00bb9aa83c80d280195ad13ec80fd3d)) + +* feat: :sparkles: add support for status polling for `Run` + +* chore: :wrench: constants + +* refactor: :recycle: polling implementation + +* docs: :memo: update assistant examples + +* refactor: :recycle: rename `poll_interval` and `poll_timeout` to indicate seconds + +--------- + +Co-authored-by: benshuk + +- Add submit_input method for thread run ([#250](https://github.com/AI21Labs/ai21-python/pull/250), + [`175c686`](https://github.com/AI21Labs/ai21-python/commit/175c686cc457bdda0fe0650c1de92a51969b0eb5)) + +* feat: add submit_input method for thread run + +* fix: change gt to gte operator in poll_for_status + +* fix: add =None to optionals + + ## v3.0.1 (2024-12-02) ### Bug Fixes @@ -23,11 +234,126 @@ Bumps [Commits](https://github.com/python-semantic-release/python-semantic-release/compare/v9.10.1...v9.14.0) --- updated-dependencies: - dependency-name: python-semantic-release/python-semantic-release - dependency-type: direct:production update-type: version-update:semver-minor ... + dependency-type: direct:production + +update-type: version-update:semver-minor + +... + +Signed-off-by: dependabot[bot] + +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> + +- **release**: V3.0.1 [skip ci] + ([`4d42360`](https://github.com/AI21Labs/ai21-python/commit/4d42360564d73f1045b9f7cf98bc47938a813fc7)) + + +## v3.1.0-rc.3 (2024-12-26) + +### Bug Fixes + +- Not given as a constant not class ([#244](https://github.com/AI21Labs/ai21-python/pull/244), + [`5782127`](https://github.com/AI21Labs/ai21-python/commit/5782127fbc805b68345ba68de2508a94306f50f4)) + +### Chores + +- **release**: V3.1.0-rc.3 [skip ci] + ([`d1ec5ff`](https://github.com/AI21Labs/ai21-python/commit/d1ec5ff4de12054d3e76022445e075a41bc8b22d)) + + +## v3.1.0-rc.2 (2024-12-22) + +### Bug Fixes + +- Adapt assistant sdk to hlp ([#242](https://github.com/AI21Labs/ai21-python/pull/242), + [`78c58d5`](https://github.com/AI21Labs/ai21-python/commit/78c58d588b91f64bebd53445a1585b008011afe7)) + +* fix: add schemas to assistant plans + +* fix: support func type in code and class in schemas + +* fix: add schemas to api call + +* fix: raise an error on code parsing failed + +* fix: change types + +* fix: add tests + +* fix: adapt code to 3.8 + +* fix: support model schemas of python 3.11 + +* fix: PR comments + +* fix: add user defined plan example to integration tests + +### Chores + +- :truck: rename `internet_research` to `web_search` + ([#241](https://github.com/AI21Labs/ai21-python/pull/241), + [`770c6c5`](https://github.com/AI21Labs/ai21-python/commit/770c6c51fd7ea287d2485a3048fe748db5b636b3)) + +EXEC-470 + +Co-authored-by: benshuk + +- **release**: V3.1.0-rc.2 [skip ci] + ([`5deee97`](https://github.com/AI21Labs/ai21-python/commit/5deee97bfdf97e7e15203c2267983c55e695cfde)) + + +## v3.1.0-rc.1 (2024-12-04) + +### Bug Fixes + +- :bug: pr fixes + ([`c46e517`](https://github.com/AI21Labs/ai21-python/commit/c46e517cfd8619e4cb25581f5e714ee8fc919e47)) + +- :bug: pr fixes + ([`dd7d71d`](https://github.com/AI21Labs/ai21-python/commit/dd7d71d82eda94ef2a72fdb1492015d57444bf4e)) + +- :bug: use `List` for typing instead of `list` + ([`fc45f19`](https://github.com/AI21Labs/ai21-python/commit/fc45f19027b9f21cbf3c711952a6b1ddc3db932c)) + +- :bug: use `List` for typing instead of `list` + ([`3128145`](https://github.com/AI21Labs/ai21-python/commit/3128145a85283c8f7ed0984fffee7febb32f3ae0)) + +- :green_heart: imports + ([`a9f7d67`](https://github.com/AI21Labs/ai21-python/commit/a9f7d67feaa088ffa97f87220e3198cf0d5eb0b3)) + +- :green_heart: imports + ([`f9e695b`](https://github.com/AI21Labs/ai21-python/commit/f9e695bd5e51b49ade8342cb4796cf2b1b97e630)) + +- :label: better typing & remove doc string + ([`18d0092`](https://github.com/AI21Labs/ai21-python/commit/18d009202b64a41e70c9824fa14256e4c741606f)) + +- :label: better typing & remove doc string + ([`a03deab`](https://github.com/AI21Labs/ai21-python/commit/a03deab60a4a4be43a3211959a16c4ea132bf63f)) -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Asaf Joseph Gardin - <39553475+Josephasafg@users.noreply.github.com> +- :label: remove `Model` Literal typing + ([`90f44f5`](https://github.com/AI21Labs/ai21-python/commit/90f44f575b3031f4b11edcbc6e9fef4a8b2e1c62)) + +- :label: remove `Model` Literal typing + ([`17af071`](https://github.com/AI21Labs/ai21-python/commit/17af071f1a8d3dc7913ee7922884eedf1468f157)) + +- :label: tool_resources use type + ([`5de2d8c`](https://github.com/AI21Labs/ai21-python/commit/5de2d8c0af03b7e1fb95bf7302422374e0d77954)) + +- :label: tool_resources use type + ([`c8ee041`](https://github.com/AI21Labs/ai21-python/commit/c8ee04176eeb3cf70591048a7fcf516dab99c5f4)) + +- :truck: move classes and such + ([`c944172`](https://github.com/AI21Labs/ai21-python/commit/c944172571e10452b93542944794e6bcaeaff2c7)) + +- :truck: rename `get` method to `retrieve` + ([`d2747a5`](https://github.com/AI21Labs/ai21-python/commit/d2747a56169c8c68cd9701291fab72509835f830)) + +- :truck: rename classes and such + ([`ae7a3e4`](https://github.com/AI21Labs/ai21-python/commit/ae7a3e40dd13c3feb0b41af8bbef3ed4b2490ca9)) + +### Chores - **deps**: Bump pypa/gh-action-pypi-publish from 1.10.3 to 1.12.2 ([#227](https://github.com/AI21Labs/ai21-python/pull/227), @@ -38,23 +364,109 @@ Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publi [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/f7600683efdcb7656dec5b29656edb7bc586e597...15c56dba361d8335944d31a2ecd17d700fc7bcbc) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: - direct:production update-type: version-update:semver-minor ... + direct:production + +update-type: version-update:semver-minor + +... + +Signed-off-by: dependabot[bot] + +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> + +- **release**: V3.1.0-rc.1 [skip ci] + ([`3bdad90`](https://github.com/AI21Labs/ai21-python/commit/3bdad90a0dd7ac5e7ace2acdea58d18cf6b6599b)) + +### Features + +- :sparkles: add support for `Plan` and `Route` resources + ([#238](https://github.com/AI21Labs/ai21-python/pull/238), + [`f1f5cbc`](https://github.com/AI21Labs/ai21-python/commit/f1f5cbccb894fdd2ccb8680376801cd9c9bc4391)) + +* feat: :sparkles: add support for Plan resource + +* feat: :sparkles: add support for Route resource + +* fix: :label: List instead of list + +* refactor: :truck: rename classes and files + +--------- + +Co-authored-by: benshuk + +- :sparkles: add support for Assistant resource + ([`16ef903`](https://github.com/AI21Labs/ai21-python/commit/16ef9038dc50f4c7731953bdc51073ba45655b03)) + +under `beta` -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Asaf Joseph Gardin - <39553475+Josephasafg@users.noreply.github.com> +- :sparkles: add support for Assistant resource + ([`4b31a42`](https://github.com/AI21Labs/ai21-python/commit/4b31a42351d42b6604a9b05ea9bc0b19413d91d8)) + +under `beta` + +- :sparkles: add support for Message resource + ([`b483e70`](https://github.com/AI21Labs/ai21-python/commit/b483e704743a2d9e8fbd5da99f97bf348263a4d5)) + +- :sparkles: add support for Thread resource + ([`62566cd`](https://github.com/AI21Labs/ai21-python/commit/62566cd1fd0b42bfcd181ebb5b5032e62a15730b)) + +- ✨ add support for Run resource ([#236](https://github.com/AI21Labs/ai21-python/pull/236), + [`d4beb22`](https://github.com/AI21Labs/ai21-python/commit/d4beb227242d6e2055f1279b6ba9f453a5c0233b)) + +* feat: :sparkles: add support for Run resource + +* fix: :label: typing backwards compatability + +* refactor: :truck: rename classes & types and such + +* refactor: :fire: remove `avatar` option + +* fix: :label: typing yay + +* feat: :sparkles: add examples + +* fix: :label: make `description` optional + +* docs: :memo: add assistants info to README + +also, add examples + +* test: :white_check_mark: add assistants to tests + +* docs: :memo: update docs about Assistants + +* docs: :memo: better example + +* chore: :truck: move files + +* docs: :memo: examples fixes + +--------- + +Co-authored-by: benshuk + +### Refactoring + +- :art: reformat functions with 2+ arguments + ([`a8c345e`](https://github.com/AI21Labs/ai21-python/commit/a8c345e81f2b29dd14e5ec118d5f4068792198df)) + +- :truck: move `MessageResponse` type to a separate file + ([`151f5ac`](https://github.com/AI21Labs/ai21-python/commit/151f5acfa2d83fccb8b9bc459fce761324542ce5)) ## v3.0.0 (2024-11-11) ### Chores -- **release**: V3.0.0 [skip ci] - ([`7457c5b`](https://github.com/AI21Labs/ai21-python/commit/7457c5b2c2d9dab24b1cf863786db710bd16f7a6)) - - **release**: V2.16.0 [skip ci] ([`d8a6ecc`](https://github.com/AI21Labs/ai21-python/commit/d8a6ecc0da4f19183cdba826cf6641ad39dafbe8)) +- **release**: V3.0.0 [skip ci] + ([`7457c5b`](https://github.com/AI21Labs/ai21-python/commit/7457c5b2c2d9dab24b1cf863786db710bd16f7a6)) + ### Features - Breaking CHANGE: Version v3.0.0 ([#229](https://github.com/AI21Labs/ai21-python/pull/229), @@ -65,6 +477,10 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b feat!: Removed Legacy TSM Models +### BREAKING CHANGES + +- Version v3.0.0 (#229) + ## v2.15.2 (2024-11-05) @@ -76,9 +492,6 @@ feat!: Removed Legacy TSM Models ### Chores -- **release**: V2.15.2 [skip ci] - ([`b94594f`](https://github.com/AI21Labs/ai21-python/commit/b94594f70a68223059505c712fea54111145cd50)) - - **deps**: Bump pypa/gh-action-pypi-publish from 1.10.1 to 1.10.3 ([#216](https://github.com/AI21Labs/ai21-python/pull/216), [`5de5ae5`](https://github.com/AI21Labs/ai21-python/commit/5de5ae5cc3a42726b525e6956d61bd8bfefbc0cb)) @@ -88,11 +501,17 @@ Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publi [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/0ab0b79471669eb3a4d647e625009c62f9f3b241...f7600683efdcb7656dec5b29656edb7bc586e597) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: - direct:production update-type: version-update:semver-patch ... + direct:production + +update-type: version-update:semver-patch -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Asaf Joseph Gardin - <39553475+Josephasafg@users.noreply.github.com> +... + +Signed-off-by: dependabot[bot] + +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> - **deps**: Bump python-semantic-release/python-semantic-release ([#218](https://github.com/AI21Labs/ai21-python/pull/218), @@ -107,10 +526,18 @@ Bumps [Commits](https://github.com/python-semantic-release/python-semantic-release/compare/v9.8.8...v9.10.1) --- updated-dependencies: - dependency-name: python-semantic-release/python-semantic-release - dependency-type: direct:production update-type: version-update:semver-minor ... + dependency-type: direct:production -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> +update-type: version-update:semver-minor + +... + +Signed-off-by: dependabot[bot] + +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +- **release**: V2.15.2 [skip ci] + ([`b94594f`](https://github.com/AI21Labs/ai21-python/commit/b94594f70a68223059505c712fea54111145cd50)) ## v2.15.1 (2024-09-30) @@ -122,9 +549,6 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b ### Chores -- **release**: V2.15.1 [skip ci] - ([`d31badb`](https://github.com/AI21Labs/ai21-python/commit/d31badbaf2b688b216317967b2d85fbad986c1b0)) - - **deps**: Bump pypa/gh-action-pypi-publish from 1.10.0 to 1.10.1 ([#210](https://github.com/AI21Labs/ai21-python/pull/210), [`6da18da`](https://github.com/AI21Labs/ai21-python/commit/6da18da7dd9c104092161f435e3c39432e04f095)) @@ -134,32 +558,44 @@ Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publi [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/8a08d616893759ef8e1aa1f2785787c0b97e20d6...0ab0b79471669eb3a4d647e625009c62f9f3b241) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: - direct:production update-type: version-update:semver-patch ... + direct:production -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Asaf Joseph Gardin - <39553475+Josephasafg@users.noreply.github.com> +update-type: version-update:semver-patch + +... + +Signed-off-by: dependabot[bot] + +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> + +- **release**: V2.15.1 [skip ci] + ([`d31badb`](https://github.com/AI21Labs/ai21-python/commit/d31badbaf2b688b216317967b2d85fbad986c1b0)) ## v2.15.0 (2024-09-24) ### Chores -- **release**: V2.15.0 [skip ci] - ([`8835e75`](https://github.com/AI21Labs/ai21-python/commit/8835e75c4b825986d044658b79b5fd44497a9673)) +- **deps**: Bump pypa/gh-action-pypi-publish from 1.9.0 to 1.10.0 + ([#208](https://github.com/AI21Labs/ai21-python/pull/208), + [`6bec329`](https://github.com/AI21Labs/ai21-python/commit/6bec329d453b969f721c5a27d1459fe2cbdea9a7)) -- **deps-dev**: Bump cryptography from 42.0.7 to 43.0.1 - ([#209](https://github.com/AI21Labs/ai21-python/pull/209), - [`e811d74`](https://github.com/AI21Labs/ai21-python/commit/e811d74bfb067546f7e1873a273896b4747a7d57)) +Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.9.0 to + 1.10.0. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - + [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0...8a08d616893759ef8e1aa1f2785787c0b97e20d6) -Bumps [cryptography](https://github.com/pyca/cryptography) from 42.0.7 to 43.0.1. - - [Changelog](https://github.com/pyca/cryptography/blob/main/CHANGELOG.rst) - - [Commits](https://github.com/pyca/cryptography/compare/42.0.7...43.0.1) +--- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: + direct:production ---- updated-dependencies: - dependency-name: cryptography dependency-type: indirect ... +update-type: version-update:semver-minor -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> +... + +Signed-off-by: dependabot[bot] + +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> - **deps**: Bump python-semantic-release/python-semantic-release ([#207](https://github.com/AI21Labs/ai21-python/pull/207), @@ -174,25 +610,36 @@ Bumps [Commits](https://github.com/python-semantic-release/python-semantic-release/compare/v9.8.7...v9.8.8) --- updated-dependencies: - dependency-name: python-semantic-release/python-semantic-release - dependency-type: direct:production update-type: version-update:semver-patch ... + dependency-type: direct:production -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Asaf Joseph Gardin - <39553475+Josephasafg@users.noreply.github.com> +update-type: version-update:semver-patch -- **deps**: Bump pypa/gh-action-pypi-publish from 1.9.0 to 1.10.0 - ([#208](https://github.com/AI21Labs/ai21-python/pull/208), - [`6bec329`](https://github.com/AI21Labs/ai21-python/commit/6bec329d453b969f721c5a27d1459fe2cbdea9a7)) +... -Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.9.0 to - 1.10.0. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0...8a08d616893759ef8e1aa1f2785787c0b97e20d6) +Signed-off-by: dependabot[bot] ---- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: - direct:production update-type: version-update:semver-minor ... +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> + +- **deps-dev**: Bump cryptography from 42.0.7 to 43.0.1 + ([#209](https://github.com/AI21Labs/ai21-python/pull/209), + [`e811d74`](https://github.com/AI21Labs/ai21-python/commit/e811d74bfb067546f7e1873a273896b4747a7d57)) + +Bumps [cryptography](https://github.com/pyca/cryptography) from 42.0.7 to 43.0.1. - + [Changelog](https://github.com/pyca/cryptography/blob/main/CHANGELOG.rst) - + [Commits](https://github.com/pyca/cryptography/compare/42.0.7...43.0.1) -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> +--- updated-dependencies: - dependency-name: cryptography dependency-type: indirect + +... + +Signed-off-by: dependabot[bot] + +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +- **release**: V2.15.0 [skip ci] + ([`8835e75`](https://github.com/AI21Labs/ai21-python/commit/8835e75c4b825986d044658b79b5fd44497a9673)) ### Features @@ -242,9 +689,6 @@ Co-authored-by: Paz Shalev ### Chores -- **release**: V2.13.0 [skip ci] - ([`5d350ea`](https://github.com/AI21Labs/ai21-python/commit/5d350ea1a913e0f851de9e87e6ed01823ace2ce4)) - - **deps**: Bump python-semantic-release/python-semantic-release ([#204](https://github.com/AI21Labs/ai21-python/pull/204), [`82d3abe`](https://github.com/AI21Labs/ai21-python/commit/82d3abece58b95818505c51707145c4410dfe4d6)) @@ -258,10 +702,18 @@ Bumps [Commits](https://github.com/python-semantic-release/python-semantic-release/compare/v9.8.6...v9.8.7) --- updated-dependencies: - dependency-name: python-semantic-release/python-semantic-release - dependency-type: direct:production update-type: version-update:semver-patch ... + dependency-type: direct:production + +update-type: version-update:semver-patch + +... + +Signed-off-by: dependabot[bot] -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +- **release**: V2.13.0 [skip ci] + ([`5d350ea`](https://github.com/AI21Labs/ai21-python/commit/5d350ea1a913e0f851de9e87e6ed01823ace2ce4)) ### Documentation @@ -296,9 +748,6 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b ### Chores -- **release**: V2.11.0 [skip ci] - ([`62ddebf`](https://github.com/AI21Labs/ai21-python/commit/62ddebfcd4037353440904800d8c8e394817040a)) - - **deps**: Bump python-semantic-release/python-semantic-release ([#190](https://github.com/AI21Labs/ai21-python/pull/190), [`0c7622b`](https://github.com/AI21Labs/ai21-python/commit/0c7622b138a76bf74f509749b38ae228c761f894)) @@ -312,11 +761,20 @@ Bumps [Commits](https://github.com/python-semantic-release/python-semantic-release/compare/v9.8.5...v9.8.6) --- updated-dependencies: - dependency-name: python-semantic-release/python-semantic-release - dependency-type: direct:production update-type: version-update:semver-patch ... + dependency-type: direct:production + +update-type: version-update:semver-patch -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Asaf Joseph Gardin - <39553475+Josephasafg@users.noreply.github.com> +... + +Signed-off-by: dependabot[bot] + +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> + +- **release**: V2.11.0 [skip ci] + ([`62ddebf`](https://github.com/AI21Labs/ai21-python/commit/62ddebfcd4037353440904800d8c8e394817040a)) ### Features @@ -343,8 +801,6 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b * refactor: async stream example -* refactor: cr comments - --------- Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> @@ -354,6 +810,9 @@ Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.co ### Bug Fixes +- Env ([#197](https://github.com/AI21Labs/ai21-python/pull/197), + [`525c1ef`](https://github.com/AI21Labs/ai21-python/commit/525c1ef4cdd593eca62ae16eddda6db72a36dbcf)) + - Remove redundant dependency - dataclass json ([#194](https://github.com/AI21Labs/ai21-python/pull/194), [`e8dcd27`](https://github.com/AI21Labs/ai21-python/commit/e8dcd27e2883b4e60cbb4f4d7505309f4a963a6c)) @@ -368,9 +827,6 @@ Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.co Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> -- Env ([#197](https://github.com/AI21Labs/ai21-python/pull/197), - [`525c1ef`](https://github.com/AI21Labs/ai21-python/commit/525c1ef4cdd593eca62ae16eddda6db72a36dbcf)) - ### Chores - **release**: V2.10.1 [skip ci] @@ -393,8 +849,30 @@ Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.co ### Chores -- **release**: V2.10.0 [skip ci] - ([`4b85505`](https://github.com/AI21Labs/ai21-python/commit/4b85505e5c1830e145ecd04dc249a4df5c44ac60)) +- **deps**: Bump python-semantic-release/python-semantic-release + ([#179](https://github.com/AI21Labs/ai21-python/pull/179), + [`2175f81`](https://github.com/AI21Labs/ai21-python/commit/2175f81c29e8fcaac8ff2dfb67af2b4f0aceead7)) + +Bumps + [python-semantic-release/python-semantic-release](https://github.com/python-semantic-release/python-semantic-release) + from 9.8.3 to 9.8.5. - [Release + notes](https://github.com/python-semantic-release/python-semantic-release/releases) - + [Changelog](https://github.com/python-semantic-release/python-semantic-release/blob/master/CHANGELOG.md) + - + [Commits](https://github.com/python-semantic-release/python-semantic-release/compare/v9.8.3...v9.8.5) + +--- updated-dependencies: - dependency-name: python-semantic-release/python-semantic-release + dependency-type: direct:production + +update-type: version-update:semver-patch + +... + +Signed-off-by: dependabot[bot] + +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> - **deps-dev**: Bump setuptools from 69.5.1 to 70.0.0 ([#186](https://github.com/AI21Labs/ai21-python/pull/186), @@ -405,30 +883,18 @@ Bumps [setuptools](https://github.com/pypa/setuptools) from 69.5.1 to 70.0.0. - [Changelog](https://github.com/pypa/setuptools/blob/main/NEWS.rst) - [Commits](https://github.com/pypa/setuptools/compare/v69.5.1...v70.0.0) ---- updated-dependencies: - dependency-name: setuptools dependency-type: indirect ... +--- updated-dependencies: - dependency-name: setuptools dependency-type: indirect -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Asaf Joseph Gardin - <39553475+Josephasafg@users.noreply.github.com> +... -- **deps**: Bump python-semantic-release/python-semantic-release - ([#179](https://github.com/AI21Labs/ai21-python/pull/179), - [`2175f81`](https://github.com/AI21Labs/ai21-python/commit/2175f81c29e8fcaac8ff2dfb67af2b4f0aceead7)) +Signed-off-by: dependabot[bot] -Bumps - [python-semantic-release/python-semantic-release](https://github.com/python-semantic-release/python-semantic-release) - from 9.8.3 to 9.8.5. - [Release - notes](https://github.com/python-semantic-release/python-semantic-release/releases) - - [Changelog](https://github.com/python-semantic-release/python-semantic-release/blob/master/CHANGELOG.md) - - - [Commits](https://github.com/python-semantic-release/python-semantic-release/compare/v9.8.3...v9.8.5) +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> ---- updated-dependencies: - dependency-name: python-semantic-release/python-semantic-release - dependency-type: direct:production update-type: version-update:semver-patch ... +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Asaf Joseph Gardin - <39553475+Josephasafg@users.noreply.github.com> +- **release**: V2.10.0 [skip ci] + ([`4b85505`](https://github.com/AI21Labs/ai21-python/commit/4b85505e5c1830e145ecd04dc249a4df5c44ac60)) ### Documentation @@ -463,13 +929,6 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b * refactor: ci comments, attach alias by field, create private functions for serialization, add deprecation warning -* refactor: ci comments, attach alias by field, create private functions for serialization, add - deprecation warning - -* test: fix tests - -* test: fix tests - * test: fix tests * chore: ci comments, remove basemodel from not_given @@ -512,22 +971,28 @@ Co-authored-by: semantic-release ### Chores -- **release**: V2.9.1 [skip ci] - ([`5ed7f07`](https://github.com/AI21Labs/ai21-python/commit/5ed7f07e677ce60eb960991f3c601869d4e2c68c)) +- **deps**: Bump amannn/action-semantic-pull-request + ([#154](https://github.com/AI21Labs/ai21-python/pull/154), + [`e57d99a`](https://github.com/AI21Labs/ai21-python/commit/e57d99a04ff4b6aa4a858a2fe87f8cc8c68bcfa0)) -- **deps-dev**: Bump zipp from 3.18.1 to 3.19.1 - ([#183](https://github.com/AI21Labs/ai21-python/pull/183), - [`1812ef5`](https://github.com/AI21Labs/ai21-python/commit/1812ef50f3700bc994694c9b45a7c1cf51c45f87)) +Bumps [amannn/action-semantic-pull-request](https://github.com/amannn/action-semantic-pull-request) + from 5.5.2 to 5.5.3. - [Release + notes](https://github.com/amannn/action-semantic-pull-request/releases) - + [Changelog](https://github.com/amannn/action-semantic-pull-request/blob/main/CHANGELOG.md) - + [Commits](https://github.com/amannn/action-semantic-pull-request/compare/v5.5.2...v5.5.3) -Bumps [zipp](https://github.com/jaraco/zipp) from 3.18.1 to 3.19.1. - [Release - notes](https://github.com/jaraco/zipp/releases) - - [Changelog](https://github.com/jaraco/zipp/blob/main/NEWS.rst) - - [Commits](https://github.com/jaraco/zipp/compare/v3.18.1...v3.19.1) +--- updated-dependencies: - dependency-name: amannn/action-semantic-pull-request dependency-type: + direct:production + +update-type: version-update:semver-patch + +... + +Signed-off-by: dependabot[bot] ---- updated-dependencies: - dependency-name: zipp dependency-type: indirect ... +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> - **deps**: Bump certifi from 2024.2.2 to 2024.7.4 ([#176](https://github.com/AI21Labs/ai21-python/pull/176), @@ -536,28 +1001,35 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b Bumps [certifi](https://github.com/certifi/python-certifi) from 2024.2.2 to 2024.7.4. - [Commits](https://github.com/certifi/python-certifi/compare/2024.02.02...2024.07.04) ---- updated-dependencies: - dependency-name: certifi dependency-type: indirect ... +--- updated-dependencies: - dependency-name: certifi dependency-type: indirect -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Asaf Joseph Gardin - <39553475+Josephasafg@users.noreply.github.com> +... -- **deps**: Bump amannn/action-semantic-pull-request - ([#154](https://github.com/AI21Labs/ai21-python/pull/154), - [`e57d99a`](https://github.com/AI21Labs/ai21-python/commit/e57d99a04ff4b6aa4a858a2fe87f8cc8c68bcfa0)) +Signed-off-by: dependabot[bot] -Bumps [amannn/action-semantic-pull-request](https://github.com/amannn/action-semantic-pull-request) - from 5.5.2 to 5.5.3. - [Release - notes](https://github.com/amannn/action-semantic-pull-request/releases) - - [Changelog](https://github.com/amannn/action-semantic-pull-request/blob/main/CHANGELOG.md) - - [Commits](https://github.com/amannn/action-semantic-pull-request/compare/v5.5.2...v5.5.3) +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> ---- updated-dependencies: - dependency-name: amannn/action-semantic-pull-request dependency-type: - direct:production update-type: version-update:semver-patch ... +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> + +- **deps-dev**: Bump zipp from 3.18.1 to 3.19.1 + ([#183](https://github.com/AI21Labs/ai21-python/pull/183), + [`1812ef5`](https://github.com/AI21Labs/ai21-python/commit/1812ef50f3700bc994694c9b45a7c1cf51c45f87)) + +Bumps [zipp](https://github.com/jaraco/zipp) from 3.18.1 to 3.19.1. - [Release + notes](https://github.com/jaraco/zipp/releases) - + [Changelog](https://github.com/jaraco/zipp/blob/main/NEWS.rst) - + [Commits](https://github.com/jaraco/zipp/compare/v3.18.1...v3.19.1) + +--- updated-dependencies: - dependency-name: zipp dependency-type: indirect -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Asaf Joseph Gardin - <39553475+Josephasafg@users.noreply.github.com> +... + +Signed-off-by: dependabot[bot] + +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +- **release**: V2.9.1 [skip ci] + ([`5ed7f07`](https://github.com/AI21Labs/ai21-python/commit/5ed7f07e677ce60eb960991f3c601869d4e2c68c)) ## v2.9.0 (2024-07-07) @@ -573,29 +1045,7 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b - Version of action and json parser ([#173](https://github.com/AI21Labs/ai21-python/pull/173), [`8a270ec`](https://github.com/AI21Labs/ai21-python/commit/8a270ecfc3e8b5d312dbe49d2a47a41c31be9be3)) -### Chores - -- **release**: V2.9.0 [skip ci] - ([`f4b4d36`](https://github.com/AI21Labs/ai21-python/commit/f4b4d362b77ab94c970ae623f7f9185b94718181)) - -- **deps**: Bump actions/github-script from 6 to 7 - ([#169](https://github.com/AI21Labs/ai21-python/pull/169), - [`de4b1af`](https://github.com/AI21Labs/ai21-python/commit/de4b1af5654b30fbf01d7258a9174eb091362b1d)) - -Bumps [actions/github-script](https://github.com/actions/github-script) from 6 to 7. - [Release - notes](https://github.com/actions/github-script/releases) - - [Commits](https://github.com/actions/github-script/compare/v6...v7) - ---- updated-dependencies: - dependency-name: actions/github-script dependency-type: - direct:production update-type: version-update:semver-major ... - -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Asaf Joseph Gardin - <39553475+Josephasafg@users.noreply.github.com> - -- Semantic pr - allow running on external prs - ([#164](https://github.com/AI21Labs/ai21-python/pull/164), - [`032fd5d`](https://github.com/AI21Labs/ai21-python/commit/032fd5d3a384f8dba26568c0b618e7c5f59a0431)) +### Chores - Add status report to integration workflow ([#161](https://github.com/AI21Labs/ai21-python/pull/161), @@ -607,15 +1057,19 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b * chore: export lint to separate workflow -- Integration-tests.yaml update inputs ([#160](https://github.com/AI21Labs/ai21-python/pull/160), - [`b3f7728`](https://github.com/AI21Labs/ai21-python/commit/b3f772859374303efc130083d0f0aba0b1743398)) +- Integration-tests.yaml update checkout to specific commit + ([#158](https://github.com/AI21Labs/ai21-python/pull/158), + [`1c01663`](https://github.com/AI21Labs/ai21-python/commit/1c016630428085c44a6b1437fa87831a6b684fcb)) - Integration-tests.yaml update inputs ([#159](https://github.com/AI21Labs/ai21-python/pull/159), [`f61c905`](https://github.com/AI21Labs/ai21-python/commit/f61c9059ecb6cc8c4fafdec7f86205a768976f32)) -- Integration-tests.yaml update checkout to specific commit - ([#158](https://github.com/AI21Labs/ai21-python/pull/158), - [`1c01663`](https://github.com/AI21Labs/ai21-python/commit/1c016630428085c44a6b1437fa87831a6b684fcb)) +- Integration-tests.yaml update inputs ([#160](https://github.com/AI21Labs/ai21-python/pull/160), + [`b3f7728`](https://github.com/AI21Labs/ai21-python/commit/b3f772859374303efc130083d0f0aba0b1743398)) + +- Semantic pr - allow running on external prs + ([#164](https://github.com/AI21Labs/ai21-python/pull/164), + [`032fd5d`](https://github.com/AI21Labs/ai21-python/commit/032fd5d3a384f8dba26568c0b618e7c5f59a0431)) - Update testing workflows ([#156](https://github.com/AI21Labs/ai21-python/pull/156), [`4c170b8`](https://github.com/AI21Labs/ai21-python/commit/4c170b8378e6bfe06a1bc342d612ad1711792fca)) @@ -624,8 +1078,36 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b * chore: integration-tests.yaml - add trigger for push on main +- **deps**: Bump actions/github-script from 6 to 7 + ([#169](https://github.com/AI21Labs/ai21-python/pull/169), + [`de4b1af`](https://github.com/AI21Labs/ai21-python/commit/de4b1af5654b30fbf01d7258a9174eb091362b1d)) + +Bumps [actions/github-script](https://github.com/actions/github-script) from 6 to 7. - [Release + notes](https://github.com/actions/github-script/releases) - + [Commits](https://github.com/actions/github-script/compare/v6...v7) + +--- updated-dependencies: - dependency-name: actions/github-script dependency-type: + direct:production + +update-type: version-update:semver-major + +... + +Signed-off-by: dependabot[bot] + +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> + +- **release**: V2.9.0 [skip ci] + ([`f4b4d36`](https://github.com/AI21Labs/ai21-python/commit/f4b4d362b77ab94c970ae623f7f9185b94718181)) + ### Continuous Integration +- Remove explicit permissions from semantic-pr.yml + ([#167](https://github.com/AI21Labs/ai21-python/pull/167), + [`3674efc`](https://github.com/AI21Labs/ai21-python/commit/3674efc106959f9b5b9b35c6eacc19db413c80cf)) + - Update size label When PR size changes (#171) ([#172](https://github.com/AI21Labs/ai21-python/pull/172), [`6dd535a`](https://github.com/AI21Labs/ai21-python/commit/6dd535a4da3959ea258a2d316be7c145961b6875)) @@ -636,12 +1118,29 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b * fix: Remove file -- Remove explicit permissions from semantic-pr.yml - ([#167](https://github.com/AI21Labs/ai21-python/pull/167), - [`3674efc`](https://github.com/AI21Labs/ai21-python/commit/3674efc106959f9b5b9b35c6eacc19db413c80cf)) - ### Features +- Added Log Verbosity ([#152](https://github.com/AI21Labs/ai21-python/pull/152), + [`57b1ea9`](https://github.com/AI21Labs/ai21-python/commit/57b1ea9aa172fdef7723199fe77ca50a15d6427c)) + +* fix: Added logger to httpx + +* feat: Added set_verbose + +* feat: Added set_debug + +* fix: api-key header + +* fix: Removed unused function + +* feat: Logged env variables + +* fix: Changed call location + +* fix: CR + +* fix: Added amazon header to secrets + - Async Support AWS ([#180](https://github.com/AI21Labs/ai21-python/pull/180), [`5248d96`](https://github.com/AI21Labs/ai21-python/commit/5248d96a783b5ffab7cb7c9f6de383a1eba4df11)) @@ -688,11 +1187,15 @@ Bumps [authlib](https://github.com/lepture/authlib) from 1.3.0 to 1.3.1. - [Rele [Changelog](https://github.com/lepture/authlib/blob/master/docs/changelog.rst) - [Commits](https://github.com/lepture/authlib/compare/v1.3.0...v1.3.1) ---- updated-dependencies: - dependency-name: authlib dependency-type: indirect ... +--- updated-dependencies: - dependency-name: authlib dependency-type: indirect -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Asaf Joseph Gardin - <39553475+Josephasafg@users.noreply.github.com> +... + +Signed-off-by: dependabot[bot] + +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> * chore(deps): bump pypa/gh-action-pypi-publish from 1.8.14 to 1.9.0 (#138) @@ -701,11 +1204,9 @@ Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publi [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/81e9d935c883d0b210363ab89cf05f3894778450...ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: - direct:production update-type: version-update:semver-minor ... + direct:production -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Asaf Joseph Gardin - <39553475+Josephasafg@users.noreply.github.com> +update-type: version-update:semver-minor * chore: rebase code @@ -731,102 +1232,16 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b --------- -Signed-off-by: dependabot[bot] Co-authored-by: Asaf Joseph Gardin - <39553475+Josephasafg@users.noreply.github.com> Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> - * Add sagemaker async support (#155) -* refactor: migrate from boto3 to custom http client - -* refactor: create an aws http client, and switch bedrock client to use it - -* test: rename test, add async tests - -* feat: add async client, remove bedrock_session class - -* docs: Azure README (#139) - -* feat: Add async tokenizer, add detokenize method (#144) - -* feat: add detokenize method, add async tokenizer - -* chore: update pyproject and poetry.lock - -* fix: fix tokenizer name in examples and readme, add example - -* test: adjust unittest + add unittest for async - -* chore: cache -> lru_cache to support python 3.8 - -* test: fix test_imports test - -* chore: add env_config to bedrock client to avoid breaking changes - * refactor: sagemaker client, boto->aws http client -* refactor: export aws auth logic to new class - -* refactor: remove aws_http_client, use http_client instead, add aws auth test - -* test: fix tests - -* refactor: remove aws_http_client - -* chore(deps-dev): bump authlib from 1.3.0 to 1.3.1 (#131) - -Bumps [authlib](https://github.com/lepture/authlib) from 1.3.0 to 1.3.1. - [Release - notes](https://github.com/lepture/authlib/releases) - - [Changelog](https://github.com/lepture/authlib/blob/master/docs/changelog.rst) - - [Commits](https://github.com/lepture/authlib/compare/v1.3.0...v1.3.1) - ---- updated-dependencies: - dependency-name: authlib dependency-type: indirect ... - -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Asaf Joseph Gardin - <39553475+Josephasafg@users.noreply.github.com> - -* chore(deps): bump pypa/gh-action-pypi-publish from 1.8.14 to 1.9.0 (#138) - -Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.14 to - 1.9.0. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/81e9d935c883d0b210363ab89cf05f3894778450...ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0) - ---- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: - direct:production update-type: version-update:semver-minor ... - -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Asaf Joseph Gardin - <39553475+Josephasafg@users.noreply.github.com> - -* chore: rebase code - -* refactor: chat + chat completions - migrate to new client - -* refactor: cr comments - -* chore: add async to new bedrock components - -* refactor: rename aws folder - * chore: refactor to use http client -* chore: fix typo on file name bedrock_chat_completions - -* fix: fix errors - -* chore: fix typo - * chore: add async to sm resources * test: fix imports test -* fix: Added deprecation warning - -* fix: Added deprecation warning to async - -* chore: add log for ignoring stream - * chore: fix lint * refactor: export get_aws_region, add async sm to readme, add async examples @@ -835,12 +1250,6 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b * refactor: remove get_aws_region func ---------- - -Signed-off-by: dependabot[bot] Co-authored-by: Asaf Joseph Gardin - <39553475+Josephasafg@users.noreply.github.com> Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> - * feat: Use the same http client for all Clients (#163) * fix: Merge @@ -867,8 +1276,6 @@ Signed-off-by: dependabot[bot] Co-authored-by: Asaf Joseph * fix: base_url -* fix: Added deprecation warning - * fix: Moved 'model' extract * test: Added a tests to validate model_id and model cant be together @@ -877,41 +1284,13 @@ Signed-off-by: dependabot[bot] Co-authored-by: Asaf Joseph * fix: Bedrock integration tests ---------- - -Signed-off-by: dependabot[bot] Co-authored-by: miri-bar - <160584887+miri-bar@users.noreply.github.com> Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> - -- Added Log Verbosity ([#152](https://github.com/AI21Labs/ai21-python/pull/152), - [`57b1ea9`](https://github.com/AI21Labs/ai21-python/commit/57b1ea9aa172fdef7723199fe77ca50a15d6427c)) - -* fix: Added logger to httpx - -* feat: Added set_verbose - -* feat: Added set_debug - -* fix: api-key header - -* fix: Removed unused function - -* feat: Logged env variables - -* fix: Changed call location - -* fix: CR - -* fix: Added amazon header to secrets +Co-authored-by: miri-bar <160584887+miri-bar@users.noreply.github.com> ## v2.8.0 (2024-06-26) ### Chores -- **release**: V2.8.0 [skip ci] - ([`c5087cf`](https://github.com/AI21Labs/ai21-python/commit/c5087cf6f20accdeba57d7630e1cd780de36e435)) - - **deps**: Bump python-semantic-release/python-semantic-release ([#143](https://github.com/AI21Labs/ai21-python/pull/143), [`718baaa`](https://github.com/AI21Labs/ai21-python/commit/718baaacce4af67c39c6e875782948e2158f22d4)) @@ -925,11 +1304,17 @@ Bumps [Commits](https://github.com/python-semantic-release/python-semantic-release/compare/v9.8.0...v9.8.3) --- updated-dependencies: - dependency-name: python-semantic-release/python-semantic-release - dependency-type: direct:production update-type: version-update:semver-patch ... + dependency-type: direct:production + +update-type: version-update:semver-patch -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Asaf Joseph Gardin - <39553475+Josephasafg@users.noreply.github.com> +... + +Signed-off-by: dependabot[bot] + +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> - **deps**: Bump urllib3 from 1.26.18 to 1.26.19 ([#140](https://github.com/AI21Labs/ai21-python/pull/140), @@ -940,11 +1325,18 @@ Bumps [urllib3](https://github.com/urllib3/urllib3) from 1.26.18 to 1.26.19. - [ [Changelog](https://github.com/urllib3/urllib3/blob/1.26.19/CHANGES.rst) - [Commits](https://github.com/urllib3/urllib3/compare/1.26.18...1.26.19) ---- updated-dependencies: - dependency-name: urllib3 dependency-type: indirect ... +--- updated-dependencies: - dependency-name: urllib3 dependency-type: indirect + +... + +Signed-off-by: dependabot[bot] + +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Asaf Joseph Gardin - <39553475+Josephasafg@users.noreply.github.com> +- **release**: V2.8.0 [skip ci] + ([`c5087cf`](https://github.com/AI21Labs/ai21-python/commit/c5087cf6f20accdeba57d7630e1cd780de36e435)) ### Continuous Integration @@ -953,6 +1345,9 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b ### Documentation +- Fix message pass ([#150](https://github.com/AI21Labs/ai21-python/pull/150), + [`8f41631`](https://github.com/AI21Labs/ai21-python/commit/8f41631025021f19b665c0b4836a664438957549)) + - Update README.md ([#149](https://github.com/AI21Labs/ai21-python/pull/149), [`09798b1`](https://github.com/AI21Labs/ai21-python/commit/09798b1e730098d0f3d43695a39d416a75f5a17d)) @@ -960,9 +1355,6 @@ minor fix Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> -- Fix message pass ([#150](https://github.com/AI21Labs/ai21-python/pull/150), - [`8f41631`](https://github.com/AI21Labs/ai21-python/commit/8f41631025021f19b665c0b4836a664438957549)) - ### Features - Adding Jamaba-Instruct-V1(chat_completions) to AWS Bedrock @@ -1001,9 +1393,6 @@ Co-authored-by: Josephasafg ### Chores -- **release**: V2.7.0 [skip ci] - ([`054459e`](https://github.com/AI21Labs/ai21-python/commit/054459e1289efb1a82a81a37038c7ca32279f5ed)) - - **deps**: Bump pypa/gh-action-pypi-publish from 1.8.14 to 1.9.0 ([#138](https://github.com/AI21Labs/ai21-python/pull/138), [`c509b7e`](https://github.com/AI21Labs/ai21-python/commit/c509b7e59aa984cc9948db1362162eaa52eeb1d7)) @@ -1013,11 +1402,17 @@ Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publi [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/81e9d935c883d0b210363ab89cf05f3894778450...ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: - direct:production update-type: version-update:semver-minor ... + direct:production + +update-type: version-update:semver-minor + +... -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Asaf Joseph Gardin - <39553475+Josephasafg@users.noreply.github.com> +Signed-off-by: dependabot[bot] + +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> - **deps-dev**: Bump authlib from 1.3.0 to 1.3.1 ([#131](https://github.com/AI21Labs/ai21-python/pull/131), @@ -1028,11 +1423,18 @@ Bumps [authlib](https://github.com/lepture/authlib) from 1.3.0 to 1.3.1. - [Rele [Changelog](https://github.com/lepture/authlib/blob/master/docs/changelog.rst) - [Commits](https://github.com/lepture/authlib/compare/v1.3.0...v1.3.1) ---- updated-dependencies: - dependency-name: authlib dependency-type: indirect ... +--- updated-dependencies: - dependency-name: authlib dependency-type: indirect + +... + +Signed-off-by: dependabot[bot] + +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Asaf Joseph Gardin - <39553475+Josephasafg@users.noreply.github.com> +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> + +- **release**: V2.7.0 [skip ci] + ([`054459e`](https://github.com/AI21Labs/ai21-python/commit/054459e1289efb1a82a81a37038c7ca32279f5ed)) ### Continuous Integration @@ -1092,8 +1494,6 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b * ci: Lgtm -* fix: condition - ### Documentation - Azure README ([#139](https://github.com/AI21Labs/ai21-python/pull/139), @@ -1216,40 +1616,6 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b * fix: fix import on sm stub -* feat: async support - stream, http, ai21 http - -* fix: commit changes - -* feat: studio resource, chat, chat completions, answer - -* feat: beta, dataset, completion, custom model - -* feat: embed, gec, improvements - -* feat: paraphrase, segmentation, summarize, by segment - -* feat: library - -* feat: client - -* refactor: sync and async http, ai21 http, ai21 client, resources - -* test: update imports, create tests for async - -* fix: base client - -* fix: add pytest marker asyncio - -* fix: add pytest asyncio to poetry - -* fix: add delete to lib files, add examples, test examples - -* fix: tests - -* fix: fix stream, add stream tests, add readme - -* fix: fix import on sm stub - * fix: fix async http client, fix tests * fix: remove commented out code @@ -1258,10 +1624,6 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b * fix: fix failing test -* fix: fix failing test - -* fix: fix failing test - * fix: fix library test * fix: cr comments @@ -1287,10 +1649,7 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b - Num_retries ([#125](https://github.com/AI21Labs/ai21-python/pull/125), [`cbbc213`](https://github.com/AI21Labs/ai21-python/commit/cbbc213bd840158797d3b5cfbcbc11200bd12f06)) -### Chores - -- **release**: V2.4.1 [skip ci] - ([`f708889`](https://github.com/AI21Labs/ai21-python/commit/f708889469a022a26df4dcd2dc29636cebc5f581)) +### Chores - **deps**: Bump python-semantic-release/python-semantic-release ([#121](https://github.com/AI21Labs/ai21-python/pull/121), @@ -1305,11 +1664,20 @@ Bumps [Commits](https://github.com/python-semantic-release/python-semantic-release/compare/v9.7.3...v9.8.0) --- updated-dependencies: - dependency-name: python-semantic-release/python-semantic-release - dependency-type: direct:production update-type: version-update:semver-minor ... + dependency-type: direct:production + +update-type: version-update:semver-minor + +... + +Signed-off-by: dependabot[bot] + +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Asaf Joseph Gardin - <39553475+Josephasafg@users.noreply.github.com> +- **release**: V2.4.1 [skip ci] + ([`f708889`](https://github.com/AI21Labs/ai21-python/commit/f708889469a022a26df4dcd2dc29636cebc5f581)) ### Continuous Integration @@ -1348,9 +1716,6 @@ Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.co ### Chores -- **release**: V2.3.1 [skip ci] - ([`b6d3186`](https://github.com/AI21Labs/ai21-python/commit/b6d3186a3854a2f04366558f17f5b2d81cd88fdc)) - - **deps**: Bump idna from 3.6 to 3.7 ([#96](https://github.com/AI21Labs/ai21-python/pull/96), [`7c52f19`](https://github.com/AI21Labs/ai21-python/commit/7c52f19012d400a23e38f5e41191d5f865c7d0a6)) @@ -1359,11 +1724,18 @@ Bumps [idna](https://github.com/kjd/idna) from 3.6 to 3.7. - [Release [Changelog](https://github.com/kjd/idna/blob/master/HISTORY.rst) - [Commits](https://github.com/kjd/idna/compare/v3.6...v3.7) ---- updated-dependencies: - dependency-name: idna dependency-type: indirect ... +--- updated-dependencies: - dependency-name: idna dependency-type: indirect + +... + +Signed-off-by: dependabot[bot] + +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Asaf Joseph Gardin - <39553475+Josephasafg@users.noreply.github.com> +- **release**: V2.3.1 [skip ci] + ([`b6d3186`](https://github.com/AI21Labs/ai21-python/commit/b6d3186a3854a2f04366558f17f5b2d81cd88fdc)) ### Documentation @@ -1390,28 +1762,6 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b ### Chores -- **release**: V2.3.0 [skip ci] - ([`d2d416a`](https://github.com/AI21Labs/ai21-python/commit/d2d416aaaf018c9905ad947fe70e30dfd951b5e6)) - -- **deps**: Bump python-semantic-release/python-semantic-release - ([#115](https://github.com/AI21Labs/ai21-python/pull/115), - [`2ff5912`](https://github.com/AI21Labs/ai21-python/commit/2ff5912c38be61ea3c06b52037109eb7504ae1a2)) - -Bumps - [python-semantic-release/python-semantic-release](https://github.com/python-semantic-release/python-semantic-release) - from 9.3.1 to 9.7.3. - [Release - notes](https://github.com/python-semantic-release/python-semantic-release/releases) - - [Changelog](https://github.com/python-semantic-release/python-semantic-release/blob/master/CHANGELOG.md) - - - [Commits](https://github.com/python-semantic-release/python-semantic-release/compare/v9.3.1...v9.7.3) - ---- updated-dependencies: - dependency-name: python-semantic-release/python-semantic-release - dependency-type: direct:production update-type: version-update:semver-minor ... - -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Asaf Joseph Gardin - <39553475+Josephasafg@users.noreply.github.com> - - **deps**: Bump amannn/action-semantic-pull-request ([#103](https://github.com/AI21Labs/ai21-python/pull/103), [`5dd95ac`](https://github.com/AI21Labs/ai21-python/commit/5dd95acdeb73967377ada7ba3da98002df58398f)) @@ -1423,114 +1773,50 @@ Bumps [amannn/action-semantic-pull-request](https://github.com/amannn/action-sem [Commits](https://github.com/amannn/action-semantic-pull-request/compare/v5.4.0...v5.5.2) --- updated-dependencies: - dependency-name: amannn/action-semantic-pull-request dependency-type: - direct:production update-type: version-update:semver-minor ... - -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Asaf Joseph Gardin - <39553475+Josephasafg@users.noreply.github.com> - -### Features - -- Jamba Stream Support ([#117](https://github.com/AI21Labs/ai21-python/pull/117), - [`ae0d12b`](https://github.com/AI21Labs/ai21-python/commit/ae0d12b4e4fbb9cdf8e2fac20ec370e7f91215b4)) - -* feat: Add httpx support (#111) - -* feat: Added httpx to pyproject - -* feat: httpx instead of requests - -* feat: Removed requests - -* fix: not given - -* fix: setup - -* feat: Added tenacity for retry - -* fix: conftest - -* test: Added tests - -* fix: Rename - -* fix: Modified test - -* fix: CR - -* fix: request - -* feat: Stream support jamba (#114) - -* feat: Added httpx to pyproject - -* feat: httpx instead of requests - -* feat: Removed requests - -* fix: not given - -* fix: setup - -* feat: Added tenacity for retry - -* fix: conftest - -* test: Added tests - -* fix: Rename - -* fix: Modified test - -* feat: stream support (unfinished) - -* feat: Added tenacity for retry - -* test: Added tests - -* fix: Rename - -* feat: stream support (unfinished) - -* fix: single request creation - -* feat: Support stream_cls - -* fix: passed response_cls - -* fix: Removed unnecessary json_to_response + direct:production -* fix: imports +update-type: version-update:semver-minor -* fix: tests +... -* fix: imports +Signed-off-by: dependabot[bot] -* fix: reponse parse +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> -* fix: Added two examples to tests +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> -* fix: sagemaker tests +- **deps**: Bump python-semantic-release/python-semantic-release + ([#115](https://github.com/AI21Labs/ai21-python/pull/115), + [`2ff5912`](https://github.com/AI21Labs/ai21-python/commit/2ff5912c38be61ea3c06b52037109eb7504ae1a2)) -* test: Added stream tests +Bumps + [python-semantic-release/python-semantic-release](https://github.com/python-semantic-release/python-semantic-release) + from 9.3.1 to 9.7.3. - [Release + notes](https://github.com/python-semantic-release/python-semantic-release/releases) - + [Changelog](https://github.com/python-semantic-release/python-semantic-release/blob/master/CHANGELOG.md) + - + [Commits](https://github.com/python-semantic-release/python-semantic-release/compare/v9.3.1...v9.7.3) -* fix: comment out failing test +--- updated-dependencies: - dependency-name: python-semantic-release/python-semantic-release + dependency-type: direct:production -* fix: CR +update-type: version-update:semver-minor -* fix: Removed code +... -* docs: Added readme for streaming +Signed-off-by: dependabot[bot] -* fix: condition +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> -* docs: readme +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> -* test: Added integration test for streaming +- **release**: V2.3.0 [skip ci] + ([`d2d416a`](https://github.com/AI21Labs/ai21-python/commit/d2d416aaaf018c9905ad947fe70e30dfd951b5e6)) -* fix: Added enter and close to stream +### Features -* fix: Uncomment chat completions test +- Jamba Stream Support ([#117](https://github.com/AI21Labs/ai21-python/pull/117), + [`ae0d12b`](https://github.com/AI21Labs/ai21-python/commit/ae0d12b4e4fbb9cdf8e2fac20ec370e7f91215b4)) * feat: Add httpx support (#111) @@ -1560,34 +1846,6 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b * feat: Stream support jamba (#114) -* feat: Added httpx to pyproject - -* feat: httpx instead of requests - -* feat: Removed requests - -* fix: not given - -* fix: setup - -* feat: Added tenacity for retry - -* fix: conftest - -* test: Added tests - -* fix: Rename - -* fix: Modified test - -* feat: stream support (unfinished) - -* feat: Added tenacity for retry - -* test: Added tests - -* fix: Rename - * feat: stream support (unfinished) * fix: single request creation @@ -1602,8 +1860,6 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b * fix: tests -* fix: imports - * fix: reponse parse * fix: Added two examples to tests @@ -1614,8 +1870,6 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b * fix: comment out failing test -* fix: CR - * fix: Removed code * docs: Added readme for streaming @@ -1632,8 +1886,6 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b * fix: poetry.lock -* fix: poetry.lock - * fix: Uncomment test case * fix: Removed unused json_to_response @@ -1723,12 +1975,12 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b ### Chores -- **release**: V2.2.1 [skip ci] - ([`4fbfe00`](https://github.com/AI21Labs/ai21-python/commit/4fbfe0002bdf1e28bdfc611f1e9b9b99012f77c7)) - - Update chat example ([#95](https://github.com/AI21Labs/ai21-python/pull/95), [`7dd83b1`](https://github.com/AI21Labs/ai21-python/commit/7dd83b184a21fe3d94a8a8b90f9bfe04c6e30e2e)) +- **release**: V2.2.1 [skip ci] + ([`4fbfe00`](https://github.com/AI21Labs/ai21-python/commit/4fbfe0002bdf1e28bdfc611f1e9b9b99012f77c7)) + ## v2.2.0 (2024-04-10) @@ -1758,86 +2010,110 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b ### Chores -- **release**: V2.1.3 [skip ci] - ([`a2b783c`](https://github.com/AI21Labs/ai21-python/commit/a2b783c6e1d7a095f69fc6cc3be86460e12949af)) +- **deps**: Bump pypa/gh-action-pypi-publish from 1.8.11 to 1.8.14 + ([#77](https://github.com/AI21Labs/ai21-python/pull/77), + [`7f3ea4a`](https://github.com/AI21Labs/ai21-python/commit/7f3ea4ab5ff87f92312e6fd873a17cbab010ed4e)) -- **deps-dev**: Bump black from 22.12.0 to 24.3.0 - ([#80](https://github.com/AI21Labs/ai21-python/pull/80), - [`5986522`](https://github.com/AI21Labs/ai21-python/commit/59865220571bbdb19edf69aee16b21dbe7582d85)) +Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.11 to + 1.8.14. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - + [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/2f6f737ca5f74c637829c0f5c3acd0e29ea5e8bf...81e9d935c883d0b210363ab89cf05f3894778450) -* chore(deps-dev): bump black from 22.12.0 to 24.3.0 +--- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: + direct:production -Bumps [black](https://github.com/psf/black) from 22.12.0 to 24.3.0. - [Release - notes](https://github.com/psf/black/releases) - - [Changelog](https://github.com/psf/black/blob/main/CHANGES.md) - - [Commits](https://github.com/psf/black/compare/22.12.0...24.3.0) +update-type: version-update:semver-patch ---- updated-dependencies: - dependency-name: black dependency-type: direct:development ... +... Signed-off-by: dependabot[bot] -* refactor: lint fixes - ---------- +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Asaf Gardin - <147075902+asafgardin@users.noreply.github.com> Co-authored-by: Asaf Gardin +Co-authored-by: Asaf Gardin <147075902+asafgardin@users.noreply.github.com> - **deps**: Bump python-semantic-release/python-semantic-release - ([#85](https://github.com/AI21Labs/ai21-python/pull/85), - [`aea5963`](https://github.com/AI21Labs/ai21-python/commit/aea5963943ad6220a41386acc5adbf23a8f0bf3e)) + ([#81](https://github.com/AI21Labs/ai21-python/pull/81), + [`c94966b`](https://github.com/AI21Labs/ai21-python/commit/c94966b4b05eec93a44e828800f043233b1fe5f4)) Bumps [python-semantic-release/python-semantic-release](https://github.com/python-semantic-release/python-semantic-release) - from 9.3.0 to 9.3.1. - [Release + from 8.7.2 to 9.3.0. - [Release notes](https://github.com/python-semantic-release/python-semantic-release/releases) - [Changelog](https://github.com/python-semantic-release/python-semantic-release/blob/master/CHANGELOG.md) - - [Commits](https://github.com/python-semantic-release/python-semantic-release/compare/v9.3.0...v9.3.1) + [Commits](https://github.com/python-semantic-release/python-semantic-release/compare/v8.7.2...v9.3.0) --- updated-dependencies: - dependency-name: python-semantic-release/python-semantic-release - dependency-type: direct:production update-type: version-update:semver-patch ... + dependency-type: direct:production + +update-type: version-update:semver-major -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> +... + +Signed-off-by: dependabot[bot] + +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +Co-authored-by: Asaf Gardin <147075902+asafgardin@users.noreply.github.com> - **deps**: Bump python-semantic-release/python-semantic-release - ([#81](https://github.com/AI21Labs/ai21-python/pull/81), - [`c94966b`](https://github.com/AI21Labs/ai21-python/commit/c94966b4b05eec93a44e828800f043233b1fe5f4)) + ([#85](https://github.com/AI21Labs/ai21-python/pull/85), + [`aea5963`](https://github.com/AI21Labs/ai21-python/commit/aea5963943ad6220a41386acc5adbf23a8f0bf3e)) Bumps [python-semantic-release/python-semantic-release](https://github.com/python-semantic-release/python-semantic-release) - from 8.7.2 to 9.3.0. - [Release + from 9.3.0 to 9.3.1. - [Release notes](https://github.com/python-semantic-release/python-semantic-release/releases) - [Changelog](https://github.com/python-semantic-release/python-semantic-release/blob/master/CHANGELOG.md) - - [Commits](https://github.com/python-semantic-release/python-semantic-release/compare/v8.7.2...v9.3.0) + [Commits](https://github.com/python-semantic-release/python-semantic-release/compare/v9.3.0...v9.3.1) --- updated-dependencies: - dependency-name: python-semantic-release/python-semantic-release - dependency-type: direct:production update-type: version-update:semver-major ... + dependency-type: direct:production -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Asaf Gardin - <147075902+asafgardin@users.noreply.github.com> +update-type: version-update:semver-patch -- **deps**: Bump pypa/gh-action-pypi-publish from 1.8.11 to 1.8.14 - ([#77](https://github.com/AI21Labs/ai21-python/pull/77), - [`7f3ea4a`](https://github.com/AI21Labs/ai21-python/commit/7f3ea4ab5ff87f92312e6fd873a17cbab010ed4e)) +... -Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.11 to - 1.8.14. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/2f6f737ca5f74c637829c0f5c3acd0e29ea5e8bf...81e9d935c883d0b210363ab89cf05f3894778450) +Signed-off-by: dependabot[bot] + +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +- **deps-dev**: Bump black from 22.12.0 to 24.3.0 + ([#80](https://github.com/AI21Labs/ai21-python/pull/80), + [`5986522`](https://github.com/AI21Labs/ai21-python/commit/59865220571bbdb19edf69aee16b21dbe7582d85)) + +* chore(deps-dev): bump black from 22.12.0 to 24.3.0 + +Bumps [black](https://github.com/psf/black) from 22.12.0 to 24.3.0. - [Release + notes](https://github.com/psf/black/releases) - + [Changelog](https://github.com/psf/black/blob/main/CHANGES.md) - + [Commits](https://github.com/psf/black/compare/22.12.0...24.3.0) + +--- updated-dependencies: - dependency-name: black dependency-type: direct:development + +... + +Signed-off-by: dependabot[bot] + +* refactor: lint fixes + +--------- + +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> ---- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: - direct:production update-type: version-update:semver-patch ... +Co-authored-by: Asaf Gardin <147075902+asafgardin@users.noreply.github.com> + +Co-authored-by: Asaf Gardin -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Asaf Gardin - <147075902+asafgardin@users.noreply.github.com> +- **release**: V2.1.3 [skip ci] + ([`a2b783c`](https://github.com/AI21Labs/ai21-python/commit/a2b783c6e1d7a095f69fc6cc3be86460e12949af)) ### Testing +- Check imports ([#76](https://github.com/AI21Labs/ai21-python/pull/76), + [`a72e23b`](https://github.com/AI21Labs/ai21-python/commit/a72e23b063ad3c1db076ced932bf0f4e6703c576)) + - Integration test for library files ([#83](https://github.com/AI21Labs/ai21-python/pull/83), [`3a50669`](https://github.com/AI21Labs/ai21-python/commit/3a50669db9351223ca971908eaa6e4842011d259)) @@ -1847,9 +2123,6 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b * fix: chat tests -- Check imports ([#76](https://github.com/AI21Labs/ai21-python/pull/76), - [`a72e23b`](https://github.com/AI21Labs/ai21-python/commit/a72e23b063ad3c1db076ced932bf0f4e6703c576)) - ## v2.1.2 (2024-02-27) @@ -1881,20 +2154,10 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b * fix: fix studio completion example -* fix: fix studio completion example - * fix: remove logit bias from bedrock * fix: add logit bias to sagemaker completion, add params string -* fix: adjust tests - -* fix: add logit bias integration test - -* fix: update studio completion example - -* fix: fix studio completion example - * fix: update code with new not_giving approach ### Chores @@ -1914,8 +2177,6 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b * fix: Added validation for model_id -* fix: Added validation for model_id - - Pass model id in Bedrock client init ([#71](https://github.com/AI21Labs/ai21-python/pull/71), [`409e818`](https://github.com/AI21Labs/ai21-python/commit/409e818b751c261b93befedad968d6533860296c)) @@ -1987,6 +2248,13 @@ Co-authored-by: etang ### Bug Fixes +- Add model types to docs ([#62](https://github.com/AI21Labs/ai21-python/pull/62), + [`ca5c3ca`](https://github.com/AI21Labs/ai21-python/commit/ca5c3ca4127fa3393c1d29f069120b3896da8beb)) + +* fix: Added model names in readme + +* fix: Added header + - Removed answer_length and mode from answer ([#65](https://github.com/AI21Labs/ai21-python/pull/65), [`3814e57`](https://github.com/AI21Labs/ai21-python/commit/3814e57c7a90a026cfb4ee4f97b7edb0de937f16)) @@ -1995,13 +2263,6 @@ Co-authored-by: etang * test: Fixed test -- Add model types to docs ([#62](https://github.com/AI21Labs/ai21-python/pull/62), - [`ca5c3ca`](https://github.com/AI21Labs/ai21-python/commit/ca5c3ca4127fa3393c1d29f069120b3896da8beb)) - -* fix: Added model names in readme - -* fix: Added header - ### Chores - **release**: V2.0.4 [skip ci] @@ -2036,8 +2297,9 @@ Co-authored-by: etang --------- -Co-authored-by: Joshua Broyde Co-authored-by: - asafgardin <147075902+asafgardin@users.noreply.github.com> +Co-authored-by: Joshua Broyde + +Co-authored-by: asafgardin <147075902+asafgardin@users.noreply.github.com> ## v2.0.2 (2024-02-04) @@ -2049,9 +2311,6 @@ Co-authored-by: Joshua Broyde Co-a ### Chores -- **release**: V2.0.2 [skip ci] - ([`2db1816`](https://github.com/AI21Labs/ai21-python/commit/2db1816a152a20d18cbd397183512f479d4fec90)) - - **deps**: Bump python-semantic-release/python-semantic-release ([#49](https://github.com/AI21Labs/ai21-python/pull/49), [`aac9932`](https://github.com/AI21Labs/ai21-python/commit/aac993213edfe2ee889d5d12e899fe32e0ba702a)) @@ -2065,11 +2324,20 @@ Bumps [Commits](https://github.com/python-semantic-release/python-semantic-release/compare/v8.3.0...v8.7.2) --- updated-dependencies: - dependency-name: python-semantic-release/python-semantic-release - dependency-type: direct:production update-type: version-update:semver-minor ... + dependency-type: direct:production + +update-type: version-update:semver-minor + +... + +Signed-off-by: dependabot[bot] + +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: asafgardin - <147075902+asafgardin@users.noreply.github.com> +Co-authored-by: asafgardin <147075902+asafgardin@users.noreply.github.com> + +- **release**: V2.0.2 [skip ci] + ([`2db1816`](https://github.com/AI21Labs/ai21-python/commit/2db1816a152a20d18cbd397183512f479d4fec90)) ## v2.0.1 (2024-02-01) @@ -2108,6 +2376,10 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b BREAKING CHANGE: 2.0.0 to SDK +### BREAKING CHANGES + +- 2.0.0 to SDK + ## v1.0.0 (2024-01-31) @@ -2137,10 +2409,6 @@ BREAKING CHANGE: 2.0.0 to SDK * ci: pypi api keys -* ci: Added rc pipeline for semantic release - -* ci: pypi api keys - * fix: readme * chore(release): v2.0.0-rc.4 [skip ci] @@ -2215,64 +2483,6 @@ BREAKING CHANGE: 2.0.0 to SDK * fix: Feedback fixes (#29) -* test: get_tokenizer tests - -* fix: cases - -* test: Added some unittests to resources - -* fix: rename var - -* test: Added ai21 studio client tsts - -* fix: rename files - -* fix: Added types - -* test: added test to http - -* fix: removed unnecessary auth param - -* test: Added tests - -* test: Added sagemaker - -* test: Created a single session per instance - -* ci: removed unnecessary action - -* fix: errors - -* fix: error renames - -* fix: rename upload - -* fix: rename type - -* fix: rename variable - -* fix: removed experimental - -* test: fixed - -* test: Added some unittests to resources - -* test: Added ai21 studio client tsts - -* fix: rename files - -* fix: Added types - -* test: added test to http - -* fix: removed unnecessary auth param - -* test: Added tests - -* test: Added sagemaker - -* test: Created a single session per instance - * fix: errors * fix: error renames @@ -2335,8 +2545,6 @@ BREAKING CHANGE: 2.0.0 to SDK * refactor: init -* fix: imports - * refactor: added more to imports * chore(release): v2.0.0-rc.7 [skip ci] @@ -2355,8 +2563,6 @@ BREAKING CHANGE: 2.0.0 to SDK * fix: env vars to http -* fix: env vars to http - * chore(release): v2.0.0-rc.8 [skip ci] * fix: Removed name parameter from chat message (#36) @@ -2371,8 +2577,6 @@ BREAKING CHANGE: 2.0.0 to SDK * fix: parameters for chat create -* fix: imports - * chore(release): v2.0.0-rc.10 [skip ci] * fix: top_k_returns to top_k_return (#40) @@ -2395,14 +2599,6 @@ BREAKING CHANGE: 2.0.0 to SDK * fix: aws tests (#44) -* ci: rc branch trigger for integration test - -* fix: wrapped in quotes - -* fix: AWS tests - -* test: ci - * fix: AWS tests * test: ci @@ -2433,34 +2629,6 @@ BREAKING CHANGE: 2.0.0 to SDK * fix: example for library -* ci: Add rc branch prefix trigger for integration tests (#43) - -* ci: rc branch trigger for integration test - -* fix: wrapped in quotes - -* fix: types - -* test: Added some integration tests - -* test: improvements - -* test: test_paraphrase.py - -* fix: doc - -* fix: removed unused comment - -* test: test_summarize.py - -* test: Added tests for test_summarize_by_segment.py - -* test: test_segmentation.py - -* fix: file id in library response - -* fix: example for library - * docs: docstrings * fix: question @@ -2476,11 +2644,15 @@ Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.2 to 3.1.3. - [Release [Changelog](https://github.com/pallets/jinja/blob/main/CHANGES.rst) - [Commits](https://github.com/pallets/jinja/compare/3.1.2...3.1.3) ---- updated-dependencies: - dependency-name: jinja2 dependency-type: indirect ... +--- updated-dependencies: - dependency-name: jinja2 dependency-type: indirect + +... -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: asafgardin - <147075902+asafgardin@users.noreply.github.com> +Signed-off-by: dependabot[bot] + +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +Co-authored-by: asafgardin <147075902+asafgardin@users.noreply.github.com> * chore(deps-dev): bump gitpython from 3.1.40 to 3.1.41 (#37) @@ -2489,11 +2661,7 @@ Bumps [gitpython](https://github.com/gitpython-developers/GitPython) from 3.1.40 [Changelog](https://github.com/gitpython-developers/GitPython/blob/main/CHANGES) - [Commits](https://github.com/gitpython-developers/GitPython/compare/3.1.40...3.1.41) ---- updated-dependencies: - dependency-name: gitpython dependency-type: indirect ... - -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: asafgardin - <147075902+asafgardin@users.noreply.github.com> +--- updated-dependencies: - dependency-name: gitpython dependency-type: indirect * chore(deps): bump actions/upload-artifact from 3 to 4 (#21) @@ -2502,11 +2670,9 @@ Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from [Commits](https://github.com/actions/upload-artifact/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: - direct:production update-type: version-update:semver-major ... + direct:production -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: asafgardin - <147075902+asafgardin@users.noreply.github.com> +update-type: version-update:semver-major * chore(deps): bump pypa/gh-action-pypi-publish from 1.4.2 to 1.8.11 (#20) @@ -2515,11 +2681,9 @@ Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publi [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/27b31702a0e7fc50959f5ad993c78deac1bdfc29...2f6f737ca5f74c637829c0f5c3acd0e29ea5e8bf) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: - direct:production update-type: version-update:semver-minor ... + direct:production -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: asafgardin - <147075902+asafgardin@users.noreply.github.com> +update-type: version-update:semver-minor * chore(deps): bump actions/setup-python from 4 to 5 (#19) @@ -2528,11 +2692,6 @@ Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to [Commits](https://github.com/actions/setup-python/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production - update-type: version-update:semver-major ... - -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: asafgardin - <147075902+asafgardin@users.noreply.github.com> * chore(deps): bump amannn/action-semantic-pull-request (#2) @@ -2543,26 +2702,18 @@ Bumps [amannn/action-semantic-pull-request](https://github.com/amannn/action-sem [Commits](https://github.com/amannn/action-semantic-pull-request/compare/v5.0.2...v5.4.0) --- updated-dependencies: - dependency-name: amannn/action-semantic-pull-request dependency-type: - direct:production update-type: version-update:semver-minor ... - -Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: asafgardin - <147075902+asafgardin@users.noreply.github.com> + direct:production * test: Added tests for library (#45) * test: Added tests for library -* fix: CR - * chore(release): v2.0.0-rc.12 [skip ci] * fix: Removed unnecessary pre commit hook * fix: Removed autouse -* fix: CR - * docs: CONTRIBUTING.md * docs: LICENSE @@ -2573,9 +2724,9 @@ Signed-off-by: dependabot[bot] Co-authored-by: dependabot[b --------- -Signed-off-by: dependabot[bot] Co-authored-by: github-actions - Co-authored-by: etang Co-authored-by: dependabot[bot] - <49699333+dependabot[bot]@users.noreply.github.com> +Co-authored-by: github-actions + +Co-authored-by: etang ## v2.0.0-rc.3 (2023-12-18) @@ -2641,43 +2792,50 @@ Signed-off-by: dependabot[bot] Co-authored-by: github-actio ### Chores -- **release**: V1.0.0-rc.1 [skip ci] - ([`65e09a4`](https://github.com/AI21Labs/ai21-python/commit/65e09a4146540c977c619348effcbeb443441a58)) +- **release**: V0.1.0-rc.1 [skip ci] + ([`3d67c2c`](https://github.com/AI21Labs/ai21-python/commit/3d67c2c9165441c09ca9a75f79021f0dba8e9325)) -- **release**: V1.1.0-rc.4 [skip ci] - ([`f696102`](https://github.com/AI21Labs/ai21-python/commit/f69610222200239ea8a7203d475780859c76bfab)) +- **release**: V0.1.0-rc.2 [skip ci] + ([`46e8eae`](https://github.com/AI21Labs/ai21-python/commit/46e8eaebe8ccacafc6b90172b3c3e3da783c3d6f)) -- **release**: V1.1.0-rc.3 [skip ci] - ([`25a4f85`](https://github.com/AI21Labs/ai21-python/commit/25a4f85a52ba024b1a44683f03ba395f8c7eb12d)) +- **release**: V0.1.0-rc.3 [skip ci] + ([`71ee300`](https://github.com/AI21Labs/ai21-python/commit/71ee3005b92b70e1655e26566d7454c79c5008f9)) -- **release**: V1.1.0-rc.2 [skip ci] - ([`d131bfc`](https://github.com/AI21Labs/ai21-python/commit/d131bfc603a3f3d1c2de32e9cd6c436169476db3)) +- **release**: V1.0.0-rc.1 [skip ci] + ([`65e09a4`](https://github.com/AI21Labs/ai21-python/commit/65e09a4146540c977c619348effcbeb443441a58)) - **release**: V1.1.0-rc.1 [skip ci] ([`de5b2b5`](https://github.com/AI21Labs/ai21-python/commit/de5b2b55c4fb0ba99b002ec7c75c34eb130a63c8)) -- **release**: V1.10.0-rc.1 [skip ci] - ([`331d142`](https://github.com/AI21Labs/ai21-python/commit/331d142e8b07c9688ab42280659a57d38759b9e6)) +- **release**: V1.1.0-rc.2 [skip ci] + ([`d131bfc`](https://github.com/AI21Labs/ai21-python/commit/d131bfc603a3f3d1c2de32e9cd6c436169476db3)) -- **release**: V0.1.0-rc.3 [skip ci] - ([`71ee300`](https://github.com/AI21Labs/ai21-python/commit/71ee3005b92b70e1655e26566d7454c79c5008f9)) +- **release**: V1.1.0-rc.3 [skip ci] + ([`25a4f85`](https://github.com/AI21Labs/ai21-python/commit/25a4f85a52ba024b1a44683f03ba395f8c7eb12d)) -- **release**: V0.1.0-rc.2 [skip ci] - ([`46e8eae`](https://github.com/AI21Labs/ai21-python/commit/46e8eaebe8ccacafc6b90172b3c3e3da783c3d6f)) +- **release**: V1.1.0-rc.4 [skip ci] + ([`f696102`](https://github.com/AI21Labs/ai21-python/commit/f69610222200239ea8a7203d475780859c76bfab)) -- **release**: V0.1.0-rc.1 [skip ci] - ([`3d67c2c`](https://github.com/AI21Labs/ai21-python/commit/3d67c2c9165441c09ca9a75f79021f0dba8e9325)) +- **release**: V1.10.0-rc.1 [skip ci] + ([`331d142`](https://github.com/AI21Labs/ai21-python/commit/331d142e8b07c9688ab42280659a57d38759b9e6)) ### Continuous Integration -- Python versions ([#5](https://github.com/AI21Labs/ai21-python/pull/5), - [`52d18cb`](https://github.com/AI21Labs/ai21-python/commit/52d18cb6b3f4a52976aced6f24f5543886e7403f)) - - Add_integration_test_action ([#4](https://github.com/AI21Labs/ai21-python/pull/4), [`f89e082`](https://github.com/AI21Labs/ai21-python/commit/f89e08213fc06b0328987331260368ca248f14ee)) +- Python versions ([#5](https://github.com/AI21Labs/ai21-python/pull/5), + [`52d18cb`](https://github.com/AI21Labs/ai21-python/commit/52d18cb6b3f4a52976aced6f24f5543886e7403f)) + ### Features +- Breaking CHANGE: pre release 2.0.0 ([#9](https://github.com/AI21Labs/ai21-python/pull/9), + [`b15d4c7`](https://github.com/AI21Labs/ai21-python/commit/b15d4c757afe18ee000334ec8355c9baa5351505)) + +* fix: remove file + +* feat: bump 1.0.0 BREAKING CHANGE: pre release + - Bump 2 rc version ([#13](https://github.com/AI21Labs/ai21-python/pull/13), [`1426ed1`](https://github.com/AI21Labs/ai21-python/commit/1426ed16cdf9cd1d201a0bfe8bbf9a454ad685f7)) @@ -2687,12 +2845,6 @@ Signed-off-by: dependabot[bot] Co-authored-by: github-actio * fix: verison -- Version rc bump ([#12](https://github.com/AI21Labs/ai21-python/pull/12), - [`88ccbe2`](https://github.com/AI21Labs/ai21-python/commit/88ccbe2b0d35b1f1682b0fcf58ca1a755fa26739)) - -- Readme restart ([#11](https://github.com/AI21Labs/ai21-python/pull/11), - [`992dedc`](https://github.com/AI21Labs/ai21-python/commit/992dedc63dd99dbffe78c80343afca1bb0530649)) - - Bumping test ([#10](https://github.com/AI21Labs/ai21-python/pull/10), [`5650abd`](https://github.com/AI21Labs/ai21-python/commit/5650abdac34dd035b80962ce14d173376210193e)) @@ -2702,26 +2854,6 @@ BREAKING CHANGE: New SDK version * fix: removed version rc -* fix: removed CHANGELOG.md - -* fix: removed version rc - -- Breaking CHANGE: pre release 2.0.0 ([#9](https://github.com/AI21Labs/ai21-python/pull/9), - [`b15d4c7`](https://github.com/AI21Labs/ai21-python/commit/b15d4c757afe18ee000334ec8355c9baa5351505)) - -* fix: remove file - -* feat: bump 1.0.0 BREAKING CHANGE: pre release - -- Test pypi ([#7](https://github.com/AI21Labs/ai21-python/pull/7), - [`549d044`](https://github.com/AI21Labs/ai21-python/commit/549d0444e09e1af34b29e6d264c61bfe0c091dbe)) - -* feat: release candidate - -* ci: test pypi - -* fix: version - - Pre release publish ([#6](https://github.com/AI21Labs/ai21-python/pull/6), [`ed3ff91`](https://github.com/AI21Labs/ai21-python/commit/ed3ff91090f14ded7b9d1ae03fdff5ac935fbdc0)) @@ -2733,6 +2865,9 @@ BREAKING CHANGE: New SDK version * fix: push to test pypi +- Readme restart ([#11](https://github.com/AI21Labs/ai21-python/pull/11), + [`992dedc`](https://github.com/AI21Labs/ai21-python/commit/992dedc63dd99dbffe78c80343afca1bb0530649)) + - Sdk code ([#3](https://github.com/AI21Labs/ai21-python/pull/3), [`0e9b36a`](https://github.com/AI21Labs/ai21-python/commit/0e9b36aca7ab0a3800552c8929c6f4f7d1cd9e1f)) @@ -2840,8 +2975,6 @@ BREAKING CHANGE: New SDK version * fix: test path -* fix: CR - * feat: Added bedrock session * feat: Added SageMakerSession @@ -2865,3 +2998,15 @@ BREAKING CHANGE: New SDK version * ci: Added integration tests only on push to main * fix: removed unused import + +- Test pypi ([#7](https://github.com/AI21Labs/ai21-python/pull/7), + [`549d044`](https://github.com/AI21Labs/ai21-python/commit/549d0444e09e1af34b29e6d264c61bfe0c091dbe)) + +* feat: release candidate + +* ci: test pypi + +* fix: version + +- Version rc bump ([#12](https://github.com/AI21Labs/ai21-python/pull/12), + [`88ccbe2`](https://github.com/AI21Labs/ai21-python/commit/88ccbe2b0d35b1f1682b0fcf58ca1a755fa26739)) diff --git a/README.md b/README.md index b3bbeb80..71856588 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ - [Installation](#Installation) 💿 - [Usage - Chat Completions](#Usage) - [Conversational RAG (Beta)](#Conversational-RAG-Beta) +- [Assistants (Beta)](#Assistants-Beta) - [Older Models Support Usage](#Older-Models-Support-Usage) - [More Models](#More-Models) - [Streaming](#Streaming) @@ -388,6 +389,41 @@ For a more detailed example, see the chat [sync](examples/studio/conversational_ --- +### Assistants (Beta) + +Create assistants to help you with your tasks. + +```python +from time import sleep +from ai21 import AI21Client +from ai21.models.assistant.message import Message + +messages = [ + Message(content={"type": "text", "text": "Youre message here"}, role="user"), +] + +client = AI21Client() + +assistant = client.beta.assistants.create(name="My assistant") +thread = client.beta.threads.create(messages=messages) +run = client.beta.threads.runs.create(thread_id=thread.id, assistant_id=assistant.id) + +while run.status == "in_progress": + run = client.beta.threads.runs.get(thread_id=thread.id, run_id=run.id) + sleep(1) + +if run.status == "completed": + messages = client.beta.threads.messages.list(thread_id=thread.id) + print(messages) +else: + # handle error or required action + pass +``` + +For a more detailed example, see [sync](examples/studio/assistant/assistant.py) and [async](examples/studio/assistant/async_assistant.py) examples. + +--- + ### File Upload ```python diff --git a/ai21/clients/common/beta/__init__.py b/ai21/clients/common/beta/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/ai21/clients/common/beta/assistant/__init__.py b/ai21/clients/common/beta/assistant/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/ai21/clients/common/beta/assistant/assistants.py b/ai21/clients/common/beta/assistant/assistants.py new file mode 100644 index 00000000..4e4f0c2d --- /dev/null +++ b/ai21/clients/common/beta/assistant/assistants.py @@ -0,0 +1,81 @@ +from __future__ import annotations + +from abc import ABC, abstractmethod +from typing import Any, Dict, List + +from ai21.clients.common.beta.assistant.plans import BasePlans +from ai21.clients.common.beta.assistant.routes import BaseRoutes +from ai21.models.assistant.assistant import Optimization, Tool, ToolResources +from ai21.models.responses.assistant_response import AssistantResponse, ListAssistant, DeletedAssistantResponse +from ai21.types import NotGiven, NOT_GIVEN +from ai21.utils.typing import remove_not_given + + +class BaseAssistants(ABC): + _module_name = "assistants" + plans: BasePlans + routes: BaseRoutes + + @abstractmethod + def create( + self, + name: str, + *, + description: str | NotGiven = NOT_GIVEN, + optimization: Optimization | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, + tools: List[Dict[str, Tool]] | NotGiven = NOT_GIVEN, + tool_resources: ToolResources | NotGiven = NOT_GIVEN, + **kwargs, + ) -> AssistantResponse: + pass + + def _create_body( + self, + *, + name: str, + description: str | NotGiven, + optimization: str | NotGiven, + models: List[str] | NotGiven, + tools: List[Dict[str, Tool]] | NotGiven, + tool_resources: dict | NotGiven, + **kwargs, + ) -> Dict[str, Any]: + return remove_not_given( + { + "name": name, + "description": description, + "optimization": optimization, + "models": models, + "tools": tools, + "tool_resources": tool_resources, + **kwargs, + } + ) + + @abstractmethod + def list(self) -> ListAssistant: + pass + + @abstractmethod + def retrieve(self, assistant_id: str) -> AssistantResponse: + pass + + @abstractmethod + def modify( + self, + assistant_id: str, + *, + name: str | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + optimization: Optimization | NotGiven = NOT_GIVEN, + is_archived: bool | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, + tools: List[Dict[str, Tool]] | NotGiven = NOT_GIVEN, + tool_resources: ToolResources | NotGiven = NOT_GIVEN, + ) -> AssistantResponse: + pass + + @abstractmethod + def delete(self, assistant_id: str) -> DeletedAssistantResponse: + pass diff --git a/ai21/clients/common/beta/assistant/messages.py b/ai21/clients/common/beta/assistant/messages.py new file mode 100644 index 00000000..5ebc8966 --- /dev/null +++ b/ai21/clients/common/beta/assistant/messages.py @@ -0,0 +1,25 @@ +from __future__ import annotations + +from abc import ABC, abstractmethod + +from ai21.models.assistant.message import ThreadMessageRole, ThreadMessageContent +from ai21.models.responses.message_response import MessageResponse, ListMessageResponse + + +class BaseMessages(ABC): + _module_name = "messages" + + @abstractmethod + def create( + self, + thread_id: str, + *, + role: ThreadMessageRole, + content: ThreadMessageContent, + **kwargs, + ) -> MessageResponse: + pass + + @abstractmethod + def list(self, thread_id: str) -> ListMessageResponse: + pass diff --git a/ai21/clients/common/beta/assistant/plans.py b/ai21/clients/common/beta/assistant/plans.py new file mode 100644 index 00000000..6923cf75 --- /dev/null +++ b/ai21/clients/common/beta/assistant/plans.py @@ -0,0 +1,90 @@ +from __future__ import annotations + +import inspect +from abc import ABC, abstractmethod +from typing import Any, Dict, Type, Callable, List + +from pydantic import BaseModel + +from ai21.errors import CodeParsingError +from ai21.models._pydantic_compatibility import _to_schema +from ai21.models.responses.plan_response import PlanResponse, ListPlanResponse +from ai21.types import NOT_GIVEN, NotGiven +from ai21.utils.typing import remove_not_given + + +class BasePlans(ABC): + _module_name = "plans" + + def _parse_schema(self, schema: Type[BaseModel] | Dict[str, Any]) -> Dict[str, Any]: + if inspect.isclass(schema) and issubclass(schema, BaseModel): + return _to_schema(schema) + return schema + + def _parse_code(self, code: str | Callable) -> str: + if callable(code): + try: + return inspect.getsource(code).strip() + except OSError as e: + raise CodeParsingError(str(e)) + except Exception: + raise CodeParsingError() + return code + + @abstractmethod + def create( + self, + *, + assistant_id: str, + code: str | Callable, + schemas: List[Dict[str, Any]] | List[Type[BaseModel]] | NotGiven = NOT_GIVEN, + **kwargs, + ) -> PlanResponse: + pass + + def _create_body( + self, + *, + code: str | Callable, + schemas: List[Dict[str, Any]] | List[BaseModel] | NotGiven = NOT_GIVEN, + **kwargs, + ) -> Dict[str, Any]: + code_str = self._parse_code(code) + + return remove_not_given( + { + "code": code_str, + "schemas": ( + [self._parse_schema(schema) for schema in schemas] if schemas is not NOT_GIVEN else NOT_GIVEN + ), + **kwargs, + } + ) + + @abstractmethod + def list( + self, + *, + assistant_id: str, + ) -> ListPlanResponse: + pass + + @abstractmethod + def retrieve( + self, + *, + assistant_id: str, + plan_id: str, + ) -> PlanResponse: + pass + + @abstractmethod + def modify( + self, + *, + assistant_id: str, + plan_id: str, + code: str, + schemas: List[Dict[str, Any]] | NotGiven = NOT_GIVEN, + ) -> PlanResponse: + pass diff --git a/ai21/clients/common/beta/assistant/routes.py b/ai21/clients/common/beta/assistant/routes.py new file mode 100644 index 00000000..c34e30e3 --- /dev/null +++ b/ai21/clients/common/beta/assistant/routes.py @@ -0,0 +1,77 @@ +from __future__ import annotations + +from abc import ABC, abstractmethod +from typing import Any, Dict, List + +from ai21.models.responses.route_response import RouteResponse, ListRouteResponse +from ai21.types import NotGiven, NOT_GIVEN +from ai21.utils.typing import remove_not_given + + +class BaseRoutes(ABC): + _module_name = "routes" + + @abstractmethod + def create( + self, + *, + assistant_id: str, + plan_id: str, + name: str, + examples: List[str], + description: str | NotGiven = NOT_GIVEN, + **kwargs, + ) -> RouteResponse: + pass + + def _create_body( + self, + *, + plan_id: str | NotGiven = NOT_GIVEN, + name: str | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + examples: List[str] | NotGiven = NOT_GIVEN, + **kwargs, + ) -> Dict[str, Any]: + return remove_not_given( + { + "plan_id": plan_id, + "name": name, + "description": description, + "examples": examples, + **kwargs, + } + ) + + @abstractmethod + def retrieve( + self, + *, + assistant_id: str, + route_id: str, + ) -> RouteResponse: + pass + + @abstractmethod + def list( + self, + *, + assistant_id: str, + name: str | NotGiven = NotGiven, + ) -> ListRouteResponse: + pass + + @abstractmethod + def modify( + self, + *, + assistant_id: str, + route_id: str, + description: str | NotGiven = NOT_GIVEN, + examples: List[str] | NotGiven = NOT_GIVEN, + ) -> RouteResponse: + pass + + @abstractmethod + def delete(self, *, assistant_id: str, route_id: str): + pass diff --git a/ai21/clients/common/beta/assistant/runs.py b/ai21/clients/common/beta/assistant/runs.py new file mode 100644 index 00000000..13131b16 --- /dev/null +++ b/ai21/clients/common/beta/assistant/runs.py @@ -0,0 +1,103 @@ +from __future__ import annotations + +from abc import ABC, abstractmethod +from typing import Any, List + +from ai21.models.assistant.assistant import Optimization +from ai21.models.assistant.run import ToolOutput +from ai21.models.responses.run_response import RunResponse +from ai21.types import NOT_GIVEN, NotGiven +from ai21.utils.typing import remove_not_given + + +class BaseRuns(ABC): + _module_name = "runs" + + @abstractmethod + def create( + self, + *, + thread_id: str, + assistant_id: str, + description: str | NotGiven = NOT_GIVEN, + optimization: Optimization | NotGiven = NOT_GIVEN, + **kwargs, + ) -> RunResponse: + pass + + def _create_body( + self, + *, + thread_id: str, + assistant_id: str, + description: str | NotGiven, + optimization: str | NotGiven, + **kwargs, + ) -> dict: + return remove_not_given( + { + "thread_id": thread_id, + "assistant_id": assistant_id, + "description": description, + "optimization": optimization, + **kwargs, + } + ) + + @abstractmethod + def retrieve( + self, + *, + thread_id: str, + run_id: str, + ) -> RunResponse: + pass + + @abstractmethod + def cancel( + self, + *, + thread_id: str, + run_id: str, + ) -> RunResponse: + pass + + @abstractmethod + def submit_tool_outputs(self, *, thread_id: str, run_id: str, tool_outputs: List[ToolOutput]) -> RunResponse: + pass + + @abstractmethod + def _poll_for_status( + self, *, thread_id: str, run_id: str, poll_interval: float, poll_timeout: float + ) -> RunResponse: + pass + + @abstractmethod + def create_and_poll( + self, + *, + thread_id: str, + assistant_id: str, + description: str | NotGiven, + optimization: Optimization | NotGiven, + poll_interval_sec: float, + poll_timeout_sec: float, + **kwargs, + ) -> RunResponse: + pass + + @abstractmethod + def submit_input(self, *, thread_id: str, run_id: str, input: Any) -> RunResponse: + pass + + @abstractmethod + def submit_input_and_poll( + self, + *, + thread_id: str, + run_id: str, + input: Any, + poll_interval_sec: float, + poll_timeout_sec: float, + ) -> RunResponse: + pass diff --git a/ai21/clients/common/beta/assistant/threads.py b/ai21/clients/common/beta/assistant/threads.py new file mode 100644 index 00000000..883b75c0 --- /dev/null +++ b/ai21/clients/common/beta/assistant/threads.py @@ -0,0 +1,34 @@ +from __future__ import annotations + +from abc import ABC, abstractmethod +from typing import List, Optional + +from ai21.clients.common.beta.assistant.messages import BaseMessages +from ai21.models.assistant.message import Message, modify_message_content +from ai21.models.responses.thread_response import ThreadResponse +from ai21.types import NOT_GIVEN, NotGiven +from ai21.utils.typing import remove_not_given + + +class BaseThreads(ABC): + _module_name = "threads" + messages: BaseMessages + + @abstractmethod + def create( + self, + messages: List[Message] | NotGiven = NOT_GIVEN, + **kwargs, + ) -> ThreadResponse: + pass + + def _create_body(self, messages: List[Message] | NotGiven, **kwargs) -> Optional[dict]: + body = remove_not_given({"messages": messages, **kwargs}) + + body["messages"] = [modify_message_content(message) for message in body.get("messages", [])] + + return body + + @abstractmethod + def retrieve(self, thread_id: str) -> ThreadResponse: + pass diff --git a/ai21/clients/studio/resources/beta/assistant/__init__.py b/ai21/clients/studio/resources/beta/assistant/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/ai21/clients/studio/resources/beta/assistant/assistant.py b/ai21/clients/studio/resources/beta/assistant/assistant.py new file mode 100644 index 00000000..50cae6c3 --- /dev/null +++ b/ai21/clients/studio/resources/beta/assistant/assistant.py @@ -0,0 +1,144 @@ +from __future__ import annotations + +from typing import Dict, List + +from ai21.clients.common.beta.assistant.assistants import BaseAssistants +from ai21.clients.studio.resources.beta.assistant.assistants_plans import AssistantPlans, AsyncAssistantPlans +from ai21.clients.studio.resources.beta.assistant.assistant_routes import AssistantRoutes, AsyncAssistantRoutes +from ai21.clients.studio.resources.studio_resource import ( + AsyncStudioResource, + StudioResource, +) +from ai21.http_client.async_http_client import AsyncAI21HTTPClient +from ai21.http_client.http_client import AI21HTTPClient +from ai21.models.assistant.assistant import Tool, ToolResources +from ai21.models.responses.assistant_response import AssistantResponse, ListAssistant, DeletedAssistantResponse +from ai21.types import NotGiven, NOT_GIVEN + + +class Assistants(StudioResource, BaseAssistants): + def __init__(self, client: AI21HTTPClient): + super().__init__(client) + + self.plans = AssistantPlans(client) + self.routes = AssistantRoutes(client) + + def create( + self, + name: str, + *, + description: str | NotGiven = NOT_GIVEN, + optimization: str | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, + tools: List[Dict[str, Tool]] | NotGiven = NOT_GIVEN, + tool_resources: ToolResources | NotGiven = NOT_GIVEN, + **kwargs, + ) -> AssistantResponse: + body = self._create_body( + name=name, + description=description, + optimization=optimization, + models=models, + tools=tools, + tool_resources=tool_resources, + **kwargs, + ) + + return self._post(path=f"/{self._module_name}", body=body, response_cls=AssistantResponse) + + def retrieve(self, assistant_id: str) -> AssistantResponse: + return self._get(path=f"/{self._module_name}/{assistant_id}", response_cls=AssistantResponse) + + def list(self) -> ListAssistant: + return self._get(path=f"/{self._module_name}", response_cls=ListAssistant) + + def modify( + self, + assistant_id: str, + *, + name: str | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + optimization: str | NotGiven = NOT_GIVEN, + is_archived: bool | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, + tools: List[Dict[str, Tool]] | NotGiven = NOT_GIVEN, + tool_resources: ToolResources | NotGiven = NOT_GIVEN, + ) -> AssistantResponse: + body = self._create_body( + name=name, + description=description, + optimization=optimization, + is_archived=is_archived, + models=models, + tools=tools, + tool_resources=tool_resources, + ) + + return self._patch(path=f"/{self._module_name}/{assistant_id}", body=body, response_cls=AssistantResponse) + + def delete(self, assistant_id: str) -> DeletedAssistantResponse: + return self._delete(path=f"/{self._module_name}/{assistant_id}", response_cls=DeletedAssistantResponse) + + +class AsyncAssistants(AsyncStudioResource, BaseAssistants): + def __init__(self, client: AsyncAI21HTTPClient): + super().__init__(client) + + self.plans = AsyncAssistantPlans(client) + self.routes = AsyncAssistantRoutes(client) + + async def create( + self, + name: str, + *, + description: str | NotGiven = NOT_GIVEN, + optimization: str | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, + tools: List[Dict[str, Tool]] | NotGiven = NOT_GIVEN, + tool_resources: ToolResources | NotGiven = NOT_GIVEN, + **kwargs, + ) -> AssistantResponse: + body = self._create_body( + name=name, + description=description, + optimization=optimization, + models=models, + tools=tools, + tool_resources=tool_resources, + **kwargs, + ) + + return await self._post(path=f"/{self._module_name}", body=body, response_cls=AssistantResponse) + + async def retrieve(self, assistant_id: str) -> AssistantResponse: + return await self._get(path=f"/{self._module_name}/{assistant_id}", response_cls=AssistantResponse) + + async def list(self) -> ListAssistant: + return await self._get(path=f"/{self._module_name}", response_cls=ListAssistant) + + async def modify( + self, + assistant_id: str, + *, + name: str | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + optimization: str | NotGiven = NOT_GIVEN, + is_archived: bool | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, + tools: List[Dict[str, Tool]] | NotGiven = NOT_GIVEN, + tool_resources: ToolResources | NotGiven = NOT_GIVEN, + ) -> AssistantResponse: + body = self._create_body( + name=name, + description=description, + optimization=optimization, + is_archived=is_archived, + models=models, + tools=tools, + tool_resources=tool_resources, + ) + + return await self._patch(path=f"/{self._module_name}/{assistant_id}", body=body, response_cls=AssistantResponse) + + async def delete(self, assistant_id: str) -> DeletedAssistantResponse: + return await self._delete(path=f"/{self._module_name}/{assistant_id}", response_cls=DeletedAssistantResponse) diff --git a/ai21/clients/studio/resources/beta/assistant/assistant_routes.py b/ai21/clients/studio/resources/beta/assistant/assistant_routes.py new file mode 100644 index 00000000..14bc6641 --- /dev/null +++ b/ai21/clients/studio/resources/beta/assistant/assistant_routes.py @@ -0,0 +1,149 @@ +from __future__ import annotations + +from typing import List + +from ai21.clients.common.beta.assistant.routes import BaseRoutes +from ai21.clients.studio.resources.studio_resource import ( + AsyncStudioResource, + StudioResource, +) +from ai21.models.responses.route_response import RouteResponse, ListRouteResponse +from ai21.types import NotGiven, NOT_GIVEN + + +class AssistantRoutes(StudioResource, BaseRoutes): + def create( + self, + *, + assistant_id: str, + plan_id: str, + name: str, + description: str | NotGiven = NOT_GIVEN, + examples: List[str], + **kwargs, + ) -> RouteResponse: + body = self._create_body( + plan_id=plan_id, + name=name, + description=description, + examples=examples, + **kwargs, + ) + + return self._post(path=f"/assistants/{assistant_id}/{self._module_name}", body=body, response_cls=RouteResponse) + + def list( + self, + *, + assistant_id: str, + name: str | NotGiven = NOT_GIVEN, + ) -> ListRouteResponse: + params = self._create_body(name=name) + + return self._get( + path=f"/assistants/{assistant_id}/{self._module_name}", params=params, response_cls=ListRouteResponse + ) + + def retrieve( + self, + *, + assistant_id: str, + route_id: str, + ) -> RouteResponse: + return self._get(path=f"/assistants/{assistant_id}/{self._module_name}/{route_id}", response_cls=RouteResponse) + + def modify( + self, + *, + assistant_id: str, + route_id: str, + description: str | NotGiven = NOT_GIVEN, + examples: List[str] | NotGiven = NOT_GIVEN, + ) -> RouteResponse: + body = self._create_body( + description=description, + examples=examples, + ) + + return self._patch( + path=f"/assistants/{assistant_id}/{self._module_name}/{route_id}", body=body, response_cls=RouteResponse + ) + + def delete( + self, + *, + assistant_id: str, + route_id: str, + ): + return self._delete(path=f"/assistants/{assistant_id}/{self._module_name}/{route_id}") + + +class AsyncAssistantRoutes(AsyncStudioResource, BaseRoutes): + async def create( + self, + *, + assistant_id: str, + plan_id: str, + name: str, + description: str | NotGiven = NOT_GIVEN, + examples: List[str], + **kwargs, + ) -> RouteResponse: + body = self._create_body( + plan_id=plan_id, + name=name, + description=description, + examples=examples, + **kwargs, + ) + + return await self._post( + path=f"/assistants/{assistant_id}/{self._module_name}", body=body, response_cls=RouteResponse + ) + + async def list( + self, + *, + assistant_id: str, + name: str | NotGiven = NOT_GIVEN, + ) -> ListRouteResponse: + params = self._create_body(name=name) + + return await self._get( + path=f"/assistants/{assistant_id}/{self._module_name}", params=params, response_cls=ListRouteResponse + ) + + async def retrieve( + self, + *, + assistant_id: str, + route_id: str, + ) -> RouteResponse: + return await self._get( + path=f"/assistants/{assistant_id}/{self._module_name}/{route_id}", response_cls=RouteResponse + ) + + async def modify( + self, + *, + assistant_id: str, + route_id: str, + description: str | NotGiven = NOT_GIVEN, + examples: List[str] | NotGiven = NOT_GIVEN, + ) -> RouteResponse: + body = self._create_body( + description=description, + examples=examples, + ) + + return await self._patch( + path=f"/assistants/{assistant_id}/{self._module_name}/{route_id}", body=body, response_cls=RouteResponse + ) + + async def delete( + self, + *, + assistant_id: str, + route_id: str, + ): + return await self._delete(path=f"/assistants/{assistant_id}/{self._module_name}/{route_id}") diff --git a/ai21/clients/studio/resources/beta/assistant/assistants_plans.py b/ai21/clients/studio/resources/beta/assistant/assistants_plans.py new file mode 100644 index 00000000..ff9a9b1e --- /dev/null +++ b/ai21/clients/studio/resources/beta/assistant/assistants_plans.py @@ -0,0 +1,117 @@ +from __future__ import annotations + +from typing import List, Any, Dict, Type + +from pydantic import BaseModel + +from ai21.clients.common.beta.assistant.plans import BasePlans +from ai21.clients.studio.resources.studio_resource import ( + AsyncStudioResource, + StudioResource, +) +from ai21.models.responses.plan_response import PlanResponse, ListPlanResponse +from ai21.types import NotGiven, NOT_GIVEN + + +class AssistantPlans(StudioResource, BasePlans): + def create( + self, + *, + assistant_id: str, + code: str, + schemas: List[Dict[str, Any]] | List[Type[BaseModel]] | NotGiven = NOT_GIVEN, + **kwargs, + ) -> PlanResponse: + body = self._create_body( + code=code, + schemas=schemas, + **kwargs, + ) + + return self._post(path=f"/assistants/{assistant_id}/{self._module_name}", body=body, response_cls=PlanResponse) + + def list( + self, + *, + assistant_id: str, + ) -> ListPlanResponse: + return self._get(path=f"/assistants/{assistant_id}/{self._module_name}", response_cls=ListPlanResponse) + + def retrieve( + self, + *, + assistant_id: str, + plan_id: str, + ) -> PlanResponse: + return self._get(path=f"/assistants/{assistant_id}/{self._module_name}/{plan_id}", response_cls=PlanResponse) + + def modify( + self, + *, + assistant_id: str, + plan_id: str, + code: str, + schemas: List[Dict[str, Any]] | List[Type[BaseModel]] | NotGiven = NOT_GIVEN, + ) -> PlanResponse: + body = self._create_body( + code=code, + schemas=schemas, + ) + + return self._patch( + path=f"/assistants/{assistant_id}/{self._module_name}/{plan_id}", body=body, response_cls=PlanResponse + ) + + +class AsyncAssistantPlans(AsyncStudioResource, BasePlans): + async def create( + self, + *, + assistant_id: str, + code: str, + schemas: List[Dict[str, Any]] | List[Type[BaseModel]] | NotGiven = NOT_GIVEN, + **kwargs, + ) -> PlanResponse: + body = self._create_body( + code=code, + schemas=schemas, + **kwargs, + ) + + return await self._post( + path=f"/assistants/{assistant_id}/{self._module_name}", body=body, response_cls=PlanResponse + ) + + async def list( + self, + *, + assistant_id: str, + ) -> ListPlanResponse: + return await self._get(path=f"/assistants/{assistant_id}/{self._module_name}", response_cls=ListPlanResponse) + + async def retrieve( + self, + *, + assistant_id: str, + plan_id: str, + ) -> PlanResponse: + return await self._get( + path=f"/assistants/{assistant_id}/{self._module_name}/{plan_id}", response_cls=PlanResponse + ) + + async def modify( + self, + *, + assistant_id: str, + plan_id: str, + code: str, + schemas: List[Dict[str, Any]] | List[Type[BaseModel]] | NotGiven = NOT_GIVEN, + ) -> PlanResponse: + body = self._create_body( + code=code, + schemas=schemas, + ) + + return await self._patch( + path=f"/assistants/{assistant_id}/{self._module_name}/{plan_id}", body=body, response_cls=PlanResponse + ) diff --git a/ai21/clients/studio/resources/beta/assistant/thread.py b/ai21/clients/studio/resources/beta/assistant/thread.py new file mode 100644 index 00000000..91279317 --- /dev/null +++ b/ai21/clients/studio/resources/beta/assistant/thread.py @@ -0,0 +1,53 @@ +from __future__ import annotations + +from typing import List + +from ai21.clients.common.beta.assistant.threads import BaseThreads +from ai21.clients.studio.resources.beta.assistant.thread_messages import ThreadMessages, AsyncThreadMessages +from ai21.clients.studio.resources.beta.assistant.thread_runs import AsyncThreadRuns, ThreadRuns +from ai21.clients.studio.resources.studio_resource import StudioResource, AsyncStudioResource +from ai21.http_client.async_http_client import AsyncAI21HTTPClient +from ai21.http_client.http_client import AI21HTTPClient +from ai21.models.assistant.message import Message +from ai21.models.responses.thread_response import ThreadResponse +from ai21.types import NOT_GIVEN, NotGiven + + +class Threads(StudioResource, BaseThreads): + def __init__(self, client: AI21HTTPClient): + super().__init__(client) + + self.messages = ThreadMessages(client) + self.runs = ThreadRuns(client) + + def create( + self, + messages: List[Message] | NotGiven = NOT_GIVEN, + **kwargs, + ) -> ThreadResponse: + body = self._create_body(messages=messages, **kwargs) + + return self._post(path=f"/{self._module_name}", body=body, response_cls=ThreadResponse) + + def retrieve(self, thread_id: str) -> ThreadResponse: + return self._get(path=f"/{self._module_name}/{thread_id}", response_cls=ThreadResponse) + + +class AsyncThreads(AsyncStudioResource, BaseThreads): + def __init__(self, client: AsyncAI21HTTPClient): + super().__init__(client) + + self.messages = AsyncThreadMessages(client) + self.runs = AsyncThreadRuns(client) + + async def create( + self, + messages: List[Message] | NotGiven = NOT_GIVEN, + **kwargs, + ) -> ThreadResponse: + body = self._create_body(messages=messages, **kwargs) + + return await self._post(path=f"/{self._module_name}", body=body, response_cls=ThreadResponse) + + async def retrieve(self, thread_id: str) -> ThreadResponse: + return await self._get(path=f"/{self._module_name}/{thread_id}", response_cls=ThreadResponse) diff --git a/ai21/clients/studio/resources/beta/assistant/thread_messages.py b/ai21/clients/studio/resources/beta/assistant/thread_messages.py new file mode 100644 index 00000000..167c39bc --- /dev/null +++ b/ai21/clients/studio/resources/beta/assistant/thread_messages.py @@ -0,0 +1,43 @@ +from __future__ import annotations + + +from ai21.clients.common.beta.assistant.messages import BaseMessages +from ai21.clients.studio.resources.studio_resource import StudioResource, AsyncStudioResource +from ai21.models.assistant.message import ThreadMessageRole, modify_message_content, Message, ThreadMessageContent +from ai21.models.responses.message_response import MessageResponse, ListMessageResponse + + +class ThreadMessages(StudioResource, BaseMessages): + def create( + self, + thread_id: str, + *, + role: ThreadMessageRole, + content: ThreadMessageContent, + **kwargs, + ) -> MessageResponse: + body = modify_message_content(Message(role=role, content=content)) + + return self._post(path=f"/threads/{thread_id}/{self._module_name}", body=body, response_cls=MessageResponse) + + def list(self, thread_id: str) -> ListMessageResponse: + return self._get(path=f"/threads/{thread_id}/{self._module_name}", response_cls=ListMessageResponse) + + +class AsyncThreadMessages(AsyncStudioResource, BaseMessages): + async def create( + self, + thread_id: str, + *, + role: ThreadMessageRole, + content: ThreadMessageContent, + **kwargs, + ) -> MessageResponse: + body = modify_message_content(Message(role=role, content=content)) + + return await self._post( + path=f"/threads/{thread_id}/{self._module_name}", body=body, response_cls=MessageResponse + ) + + async def list(self, thread_id: str) -> ListMessageResponse: + return await self._get(path=f"/threads/{thread_id}/{self._module_name}", response_cls=ListMessageResponse) diff --git a/ai21/clients/studio/resources/beta/assistant/thread_runs.py b/ai21/clients/studio/resources/beta/assistant/thread_runs.py new file mode 100644 index 00000000..555ad6c8 --- /dev/null +++ b/ai21/clients/studio/resources/beta/assistant/thread_runs.py @@ -0,0 +1,229 @@ +from __future__ import annotations + +import asyncio +import time +from typing import Any, List + +from ai21.clients.common.beta.assistant.runs import BaseRuns +from ai21.clients.studio.resources.studio_resource import StudioResource, AsyncStudioResource +from ai21.models.assistant.assistant import Optimization +from ai21.models.assistant.run import ( + ToolOutput, + TERMINATED_RUN_STATUSES, + DEFAULT_RUN_POLL_INTERVAL, + DEFAULT_RUN_POLL_TIMEOUT, +) +from ai21.models.responses.run_response import RunResponse +from ai21.types import NotGiven, NOT_GIVEN + + +class ThreadRuns(StudioResource, BaseRuns): + def create( + self, + *, + thread_id: str, + assistant_id: str, + description: str | NotGiven = NOT_GIVEN, + optimization: Optimization | NotGiven = NOT_GIVEN, + **kwargs, + ) -> RunResponse: + body = self._create_body( + thread_id=thread_id, + assistant_id=assistant_id, + description=description, + optimization=optimization, + **kwargs, + ) + + return self._post(path=f"/threads/{thread_id}/{self._module_name}", body=body, response_cls=RunResponse) + + def retrieve( + self, + *, + thread_id: str, + run_id: str, + ) -> RunResponse: + return self._get(path=f"/threads/{thread_id}/{self._module_name}/{run_id}", response_cls=RunResponse) + + def cancel( + self, + *, + thread_id: str, + run_id: str, + ) -> RunResponse: + return self._post(path=f"/threads/{thread_id}/{self._module_name}/{run_id}/cancel", response_cls=RunResponse) + + def submit_tool_outputs(self, *, thread_id: str, run_id: str, tool_outputs: List[ToolOutput]) -> RunResponse: + body = dict(tool_outputs=tool_outputs) + + return self._post( + path=f"/threads/{thread_id}/{self._module_name}/{run_id}/submit_tool_outputs", + body=body, + response_cls=RunResponse, + ) + + def _poll_for_status( + self, *, thread_id: str, run_id: str, poll_interval: float, poll_timeout: float + ) -> RunResponse: + start_time = time.time() + + while True: + run = self.retrieve(thread_id=thread_id, run_id=run_id) + + if run.status in TERMINATED_RUN_STATUSES: + return run + + if (time.time() - start_time) >= poll_timeout: + return run + + time.sleep(poll_interval) + + def create_and_poll( + self, + *, + thread_id: str, + assistant_id: str, + description: str | NotGiven = NOT_GIVEN, + optimization: Optimization | NotGiven = NOT_GIVEN, + poll_interval_sec: float = DEFAULT_RUN_POLL_INTERVAL, + poll_timeout_sec: float = DEFAULT_RUN_POLL_TIMEOUT, + **kwargs, + ) -> RunResponse: + run = self.create( + thread_id=thread_id, assistant_id=assistant_id, description=description, optimization=optimization, **kwargs + ) + + return self._poll_for_status( + thread_id=thread_id, run_id=run.id, poll_interval=poll_interval_sec, poll_timeout=poll_timeout_sec + ) + + def submit_input(self, *, thread_id: str, run_id: str, input: Any) -> RunResponse: + body = dict(input=input) + + return self._post( + path=f"/threads/{thread_id}/{self._module_name}/{run_id}/submit_input", + body=body, + response_cls=RunResponse, + ) + + def submit_input_and_poll( + self, + *, + thread_id: str, + run_id: str, + input: Any, + poll_interval_sec: float = DEFAULT_RUN_POLL_INTERVAL, + poll_timeout_sec: float = DEFAULT_RUN_POLL_TIMEOUT, + ) -> RunResponse: + run = self.submit_input(thread_id=thread_id, run_id=run_id, input=input) + + return self._poll_for_status( + thread_id=thread_id, run_id=run.id, poll_interval=poll_interval_sec, poll_timeout=poll_timeout_sec + ) + + +class AsyncThreadRuns(AsyncStudioResource, BaseRuns): + async def create( + self, + *, + thread_id: str, + assistant_id: str, + description: str | NotGiven = NOT_GIVEN, + optimization: Optimization | NotGiven = NOT_GIVEN, + **kwargs, + ) -> RunResponse: + body = self._create_body( + thread_id=thread_id, + assistant_id=assistant_id, + description=description, + optimization=optimization, + **kwargs, + ) + + return await self._post(path=f"/threads/{thread_id}/{self._module_name}", body=body, response_cls=RunResponse) + + async def retrieve( + self, + *, + thread_id: str, + run_id: str, + ) -> RunResponse: + return await self._get(path=f"/threads/{thread_id}/{self._module_name}/{run_id}", response_cls=RunResponse) + + async def cancel( + self, + *, + thread_id: str, + run_id: str, + ) -> RunResponse: + return await self._post( + path=f"/threads/{thread_id}/{self._module_name}/{run_id}/cancel", response_cls=RunResponse + ) + + async def submit_tool_outputs(self, *, thread_id: str, run_id: str, tool_outputs: List[ToolOutput]) -> RunResponse: + body = dict(tool_outputs=tool_outputs) + + return await self._post( + path=f"/threads/{thread_id}/{self._module_name}/{run_id}/submit_tool_outputs", + body=body, + response_cls=RunResponse, + ) + + async def _poll_for_status( + self, *, thread_id: str, run_id: str, poll_interval: float, poll_timeout: float + ) -> RunResponse: + start_time = time.time() + + while True: + run = await self.retrieve(thread_id=thread_id, run_id=run_id) + + if run.status in TERMINATED_RUN_STATUSES: + return run + + if (time.time() - start_time) >= poll_timeout: + return run + + await asyncio.sleep(poll_interval) + + async def create_and_poll( + self, + *, + thread_id: str, + assistant_id: str, + description: str | NotGiven = NOT_GIVEN, + optimization: Optimization | NotGiven = NOT_GIVEN, + poll_interval_sec: float = DEFAULT_RUN_POLL_INTERVAL, + poll_timeout_sec: float = DEFAULT_RUN_POLL_TIMEOUT, + **kwargs, + ) -> RunResponse: + run = await self.create( + thread_id=thread_id, assistant_id=assistant_id, description=description, optimization=optimization, **kwargs + ) + + return await self._poll_for_status( + thread_id=thread_id, run_id=run.id, poll_interval=poll_interval_sec, poll_timeout=poll_timeout_sec + ) + + async def submit_input(self, *, thread_id: str, run_id: str, input: Any) -> RunResponse: + body = dict(input=input) + + return await self._post( + path=f"/threads/{thread_id}/{self._module_name}/{run_id}/submit_input", + body=body, + response_cls=RunResponse, + ) + + async def submit_input_and_poll( + self, + *, + thread_id: str, + run_id: str, + input: Any, + poll_interval_sec: float = DEFAULT_RUN_POLL_INTERVAL, + poll_timeout_sec: float = DEFAULT_RUN_POLL_TIMEOUT, + ) -> RunResponse: + run = await self.submit_input(thread_id=thread_id, run_id=run_id, input=input) + + return await self._poll_for_status( + thread_id=thread_id, run_id=run.id, poll_interval=poll_interval_sec, poll_timeout=poll_timeout_sec + ) diff --git a/ai21/clients/studio/resources/beta/async_beta.py b/ai21/clients/studio/resources/beta/async_beta.py index a94ddc95..5a29cb9e 100644 --- a/ai21/clients/studio/resources/beta/async_beta.py +++ b/ai21/clients/studio/resources/beta/async_beta.py @@ -1,3 +1,5 @@ +from ai21.clients.studio.resources.beta.assistant.assistant import AsyncAssistants +from ai21.clients.studio.resources.beta.assistant.thread import AsyncThreads from ai21.clients.studio.resources.studio_conversational_rag import AsyncStudioConversationalRag from ai21.clients.studio.resources.studio_resource import AsyncStudioResource from ai21.http_client.async_http_client import AsyncAI21HTTPClient @@ -7,4 +9,6 @@ class AsyncBeta(AsyncStudioResource): def __init__(self, client: AsyncAI21HTTPClient): super().__init__(client) + self.assistants = AsyncAssistants(client) self.conversational_rag = AsyncStudioConversationalRag(client) + self.threads = AsyncThreads(client) diff --git a/ai21/clients/studio/resources/beta/beta.py b/ai21/clients/studio/resources/beta/beta.py index 1269f970..d2d36a1d 100644 --- a/ai21/clients/studio/resources/beta/beta.py +++ b/ai21/clients/studio/resources/beta/beta.py @@ -1,3 +1,5 @@ +from ai21.clients.studio.resources.beta.assistant.assistant import Assistants +from ai21.clients.studio.resources.beta.assistant.thread import Threads from ai21.clients.studio.resources.studio_conversational_rag import StudioConversationalRag from ai21.clients.studio.resources.studio_resource import StudioResource from ai21.http_client.http_client import AI21HTTPClient @@ -7,4 +9,6 @@ class Beta(StudioResource): def __init__(self, client: AI21HTTPClient): super().__init__(client) + self.assistants = Assistants(client) self.conversational_rag = StudioConversationalRag(client) + self.threads = Threads(client) diff --git a/ai21/clients/studio/resources/studio_resource.py b/ai21/clients/studio/resources/studio_resource.py index e4b6634e..386d0d9b 100644 --- a/ai21/clients/studio/resources/studio_resource.py +++ b/ai21/clients/studio/resources/studio_resource.py @@ -80,6 +80,12 @@ def _get( response = self._client.execute_http_request(method="GET", path=path, params=params or {}) return _cast_response(response=response, response_cls=response_cls) + def _patch( + self, path: str, response_cls: Optional[ResponseT] = None, body: Dict[str, Any] = None + ) -> ResponseT | StreamT: + response = self._client.execute_http_request(method="PATCH", path=path, body=body or {}) + return _cast_response(response=response, response_cls=response_cls) + def _put( self, path: str, response_cls: Optional[ResponseT] = None, body: Dict[str, Any] = None ) -> ResponseT | StreamT: @@ -131,6 +137,12 @@ async def _get( response = await self._client.execute_http_request(method="GET", path=path, params=params or {}) return _cast_response(response=response, response_cls=response_cls) + async def _patch( + self, path: str, response_cls: Optional[ResponseT] = None, body: Dict[str, Any] = None + ) -> ResponseT | AsyncStreamT: + response = await self._client.execute_http_request(method="PATCH", path=path, body=body or {}) + return _cast_response(response=response, response_cls=response_cls) + async def _put( self, path: str, response_cls: Optional[ResponseT] = None, body: Dict[str, Any] = None ) -> ResponseT | AsyncStreamT: diff --git a/ai21/errors.py b/ai21/errors.py index 5e557998..7b2f168f 100644 --- a/ai21/errors.py +++ b/ai21/errors.py @@ -111,3 +111,10 @@ def __init__(self, chunk: str, error_message: Optional[str] = None): class InternalDependencyException(AI21APIError): def __init__(self, details: Optional[str] = None): super().__init__(530, details) + + +class CodeParsingError(AI21Error): + def __init__(self, details: Optional[str] = None): + message = f"Code can't be parsed{'' if details is None else f': {details}'}" + super().__init__(message) + self.message = message diff --git a/ai21/models/_pydantic_compatibility.py b/ai21/models/_pydantic_compatibility.py index 5f58c0de..41d08509 100644 --- a/ai21/models/_pydantic_compatibility.py +++ b/ai21/models/_pydantic_compatibility.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Dict, Any +from typing import Dict, Any, Type from pydantic import VERSION, BaseModel @@ -33,3 +33,10 @@ def _from_json(obj: "AI21BaseModel", json_str: str, **kwargs) -> BaseModel: # n return obj.model_validate_json(json_str, **kwargs) return obj.parse_raw(json_str, **kwargs) + + +def _to_schema(model_object: Type[BaseModel], **kwargs) -> Dict[str, Any]: + if IS_PYDANTIC_V2: + return model_object.model_json_schema(**kwargs) + + return model_object.schema(**kwargs) diff --git a/ai21/models/assistant/__init__.py b/ai21/models/assistant/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/ai21/models/assistant/assistant.py b/ai21/models/assistant/assistant.py new file mode 100644 index 00000000..d9254b3b --- /dev/null +++ b/ai21/models/assistant/assistant.py @@ -0,0 +1,12 @@ +from typing import Optional, Literal + +from typing_extensions import TypedDict + +Optimization = Literal["cost", "latency"] +Tool = Literal["file_search", "web_search", "plan_approval"] + + +class ToolResources(TypedDict, total=False): + file_search: Optional[dict] + web_search: Optional[dict] + plan_approval: Optional[dict] diff --git a/ai21/models/assistant/message.py b/ai21/models/assistant/message.py new file mode 100644 index 00000000..ace7c146 --- /dev/null +++ b/ai21/models/assistant/message.py @@ -0,0 +1,30 @@ +from __future__ import annotations +from typing import Literal, Union + +from typing_extensions import TypedDict + + +ThreadMessageRole = Literal["assistant", "user"] + + +class ThreadMessageContentText(TypedDict): + type: Literal["text"] + text: str + + +ThreadMessageContent = Union[str, ThreadMessageContentText] + + +class Message(TypedDict): + role: ThreadMessageRole + content: ThreadMessageContent + + +def modify_message_content(message: Message) -> Message: + role = message["role"] + content = message["content"] + + if isinstance(content, str): + content = ThreadMessageContentText(type="text", text=content) + + return Message(role=role, content=content) diff --git a/ai21/models/assistant/run.py b/ai21/models/assistant/run.py new file mode 100644 index 00000000..3d29eaa0 --- /dev/null +++ b/ai21/models/assistant/run.py @@ -0,0 +1,51 @@ +from typing import Dict, Literal, Any, List, Set, Optional + +from typing_extensions import TypedDict + + +RunStatus = Literal[ + "cancelled", + "cancelling", + "completed", + "expired", + "failed", + "incomplete", + "in_progress", + "queued", + "requires_action", +] + +TERMINATED_RUN_STATUSES: Set[RunStatus] = {"completed", "failed", "expired", "cancelled", "requires_action"} +DEFAULT_RUN_POLL_INTERVAL: float = 1 # seconds +DEFAULT_RUN_POLL_TIMEOUT: float = 60 # seconds + + +class ToolOutput(TypedDict): + tool_call_id: str + output: Any + + +class Function(TypedDict): + name: str + arguments: Any + + +class ToolCall(TypedDict): + type: Literal["function"] + id: str + function: Function + + +class SubmitToolCallOutputs(TypedDict): + tool_calls: List[ToolOutput] + + +class SubmitInput(TypedDict): + event_name: str + data: Dict[str, Any] + + +class RequiredAction(TypedDict, total=False): + type: Literal["submit_tool_outputs", "submit_input"] + submit_tool_outputs: Optional[SubmitToolCallOutputs] = None + submit_input: Optional[SubmitInput] = None diff --git a/ai21/models/responses/assistant_response.py b/ai21/models/responses/assistant_response.py new file mode 100644 index 00000000..ed63c296 --- /dev/null +++ b/ai21/models/responses/assistant_response.py @@ -0,0 +1,32 @@ +from datetime import datetime +from typing import Optional, List, Literal, Any, Dict + +from ai21.models.ai21_base_model import AI21BaseModel +from ai21.models.assistant.assistant import ToolResources + + +class AssistantResponse(AI21BaseModel): + id: str + created_at: datetime + updated_at: datetime + object: Literal["assistant"] = "assistant" + name: str + description: Optional[str] = None + optimization: str + organization_id: str + user_id: str + avatar: Optional[str] = None + is_archived: bool = False + models: Optional[List[str]] = None + tools: Optional[List[Dict[str, Any]]] = None + tool_resources: Optional[ToolResources] = None + + +class ListAssistant(AI21BaseModel): + results: List[AssistantResponse] + + +class DeletedAssistantResponse(AI21BaseModel): + object: Literal["assistant"] = "assistant" + deleted: bool = True + id: str diff --git a/ai21/models/responses/message_response.py b/ai21/models/responses/message_response.py new file mode 100644 index 00000000..10426c19 --- /dev/null +++ b/ai21/models/responses/message_response.py @@ -0,0 +1,20 @@ +from datetime import datetime +from typing import Literal, Optional, List + +from ai21.models.ai21_base_model import AI21BaseModel +from ai21.models.assistant.message import ThreadMessageRole, ThreadMessageContentText + + +class MessageResponse(AI21BaseModel): + id: str + created_at: datetime + updated_at: datetime + object: Literal["message"] = "message" + role: ThreadMessageRole + content: ThreadMessageContentText + run_id: Optional[str] = None + assistant_id: Optional[str] = None + + +class ListMessageResponse(AI21BaseModel): + results: List[MessageResponse] diff --git a/ai21/models/responses/plan_response.py b/ai21/models/responses/plan_response.py new file mode 100644 index 00000000..e8afa863 --- /dev/null +++ b/ai21/models/responses/plan_response.py @@ -0,0 +1,23 @@ +from datetime import datetime +from typing import List, Optional, Dict, Any + +from ai21.models.ai21_base_model import AI21BaseModel + + +class PlanResponse(AI21BaseModel): + id: str + created_at: datetime + updated_at: datetime + assistant_id: str + code: str + schemas: Optional[List[Dict[str, Any]]] = None + + +class ListPlanResponse(AI21BaseModel): + results: List[PlanResponse] + + +class PlanValidationResponse(AI21BaseModel): + is_valid: bool + message: Optional[str] = None + details: Optional[str] = None diff --git a/ai21/models/responses/route_response.py b/ai21/models/responses/route_response.py new file mode 100644 index 00000000..b0c2da36 --- /dev/null +++ b/ai21/models/responses/route_response.py @@ -0,0 +1,19 @@ +from datetime import datetime +from typing import List + +from ai21.models.ai21_base_model import AI21BaseModel + + +class RouteResponse(AI21BaseModel): + id: str + created_at: datetime + updated_at: datetime + assistant_id: str + plan_id: str + name: str + description: str + examples: List[str] + + +class ListRouteResponse(AI21BaseModel): + results: List[RouteResponse] diff --git a/ai21/models/responses/run_response.py b/ai21/models/responses/run_response.py new file mode 100644 index 00000000..63ae4400 --- /dev/null +++ b/ai21/models/responses/run_response.py @@ -0,0 +1,20 @@ +from datetime import datetime +from typing import Optional + +from ai21.models.ai21_base_model import AI21BaseModel +from ai21.models.assistant.assistant import Optimization +from ai21.models.assistant.run import RunStatus, RequiredAction + + +class RunResponse(AI21BaseModel): + id: str + created_at: datetime + updated_at: datetime + thread_id: str + assistant_id: str + description: Optional[str] = None + status: RunStatus + optimization: Optimization + execution_id: Optional[str] = None + required_action: Optional[RequiredAction] = None + error: Optional[str] = None diff --git a/ai21/models/responses/thread_response.py b/ai21/models/responses/thread_response.py new file mode 100644 index 00000000..f7206a40 --- /dev/null +++ b/ai21/models/responses/thread_response.py @@ -0,0 +1,15 @@ +from datetime import datetime +from typing import List, Literal + +from ai21.models.ai21_base_model import AI21BaseModel + + +class ThreadResponse(AI21BaseModel): + id: str + created_at: datetime + updated_at: datetime + object: Literal["thread"] = "thread" + + +class ListThread(AI21BaseModel): + results: List[ThreadResponse] diff --git a/ai21/version.py b/ai21/version.py index ce310920..9408db31 100644 --- a/ai21/version.py +++ b/ai21/version.py @@ -1 +1 @@ -VERSION = "3.0.1" +VERSION = "3.1.0-rc.8" diff --git a/examples/studio/assistant/__init__.py b/examples/studio/assistant/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/examples/studio/assistant/assistant.py b/examples/studio/assistant/assistant.py new file mode 100644 index 00000000..e0628f29 --- /dev/null +++ b/examples/studio/assistant/assistant.py @@ -0,0 +1,27 @@ +from ai21 import AI21Client + + +def main(): + ai21_client = AI21Client() + + assistant = ai21_client.beta.assistants.create(name="My Assistant") + + thread = ai21_client.beta.threads.create() + + ai21_client.beta.threads.messages.create(thread_id=thread.id, role="user", content="Hello") + + run = ai21_client.beta.threads.runs.create_and_poll( + thread_id=thread.id, + assistant_id=assistant.id, + ) + + if run.status == "completed": + messages = ai21_client.beta.threads.messages.list(thread_id=thread.id) + print("Messages:") + print("\n".join(f"{msg.role}: {msg.content['text']}" for msg in messages.results)) + else: + print(f"Run status: {run.status}") + + +if __name__ == "__main__": + main() diff --git a/examples/studio/assistant/async_assistant.py b/examples/studio/assistant/async_assistant.py new file mode 100644 index 00000000..cc4d1ae7 --- /dev/null +++ b/examples/studio/assistant/async_assistant.py @@ -0,0 +1,31 @@ +import asyncio + +from ai21 import AsyncAI21Client + + +async def main(): + ai21_client = AsyncAI21Client() + + assistant = await ai21_client.beta.assistants.create(name="My Assistant") + + thread = await ai21_client.beta.threads.create() + + await ai21_client.beta.threads.messages.create(thread_id=thread.id, role="user", content="Hello") + + run = await ai21_client.beta.threads.runs.create_and_poll( + thread_id=thread.id, + assistant_id=assistant.id, + ) + + if run.status == "completed": + messages = await ai21_client.beta.threads.messages.list(thread_id=thread.id) + print("Messages:") + print("\n".join(f"{msg.role}: {msg.content['text']}" for msg in messages.results)) + elif run.status == "failed": + raise Exception(f"Run failed. Status: {run.status}") + else: + print(f"Run status: {run.status}") + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/examples/studio/assistant/user_defined_plans.py b/examples/studio/assistant/user_defined_plans.py new file mode 100644 index 00000000..0273de18 --- /dev/null +++ b/examples/studio/assistant/user_defined_plans.py @@ -0,0 +1,32 @@ +from ai21 import AI21Client +from pydantic import BaseModel + +TIMEOUT = 20 + + +def func(): + pass + + +class ExampleSchema(BaseModel): + name: str + id: str + + +def main(): + ai21_client = AI21Client() + + assistant = ai21_client.beta.assistants.create(name="My Assistant") + + plan = ai21_client.beta.assistants.plans.create(assistant_id=assistant.id, code=func, schemas=[ExampleSchema]) + ai21_client.beta.assistants.routes.create( + assistant_id=assistant.id, plan_id=plan.id, name="My Route", examples=["hi"], description="My Route Description" + ) + routes = ai21_client.beta.assistants.routes.list(assistant_id=assistant.id) + print(f"Routes: {routes}") + plans = ai21_client.beta.assistants.plans.list(assistant_id=assistant.id) + print(f"Plans: {plans}") + + +if __name__ == "__main__": + main() diff --git a/pyproject.toml b/pyproject.toml index 1e909570..e00ce9ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ exclude_lines = [ [tool.poetry] name = "ai21" -version = "3.0.1" +version = "3.1.0-rc.8" description = "" authors = ["AI21 Labs"] readme = "README.md" diff --git a/tests/integration_tests/clients/test_studio.py b/tests/integration_tests/clients/test_studio.py index 5cd0d4dd..24c75a7f 100644 --- a/tests/integration_tests/clients/test_studio.py +++ b/tests/integration_tests/clients/test_studio.py @@ -25,6 +25,7 @@ ("chat/chat_function_calling.py",), ("chat/chat_function_calling_multiple_tools.py",), ("chat/chat_response_format.py",), + ("assistant/user_defined_plans.py",), ], ids=[ "when_tokenization__should_return_ok", @@ -35,6 +36,7 @@ "when_chat_completions_with_function_calling__should_return_ok", "when_chat_completions_with_function_calling_multiple_tools_should_return_ok", "when_chat_completions_with_response_format__should_return_ok", + "when_assistant_with_user_defined_plans_should_return_ok", ], ) def test_studio(test_file_name: str): @@ -55,6 +57,8 @@ def test_studio(test_file_name: str): ("chat/async_stream_chat_completions.py",), ("conversational_rag/conversational_rag.py",), ("conversational_rag/async_conversational_rag.py",), + ("assistant/assistant.py",), + ("assistant/async_assistant.py",), ], ids=[ "when_chat__should_return_ok", @@ -62,6 +66,8 @@ def test_studio(test_file_name: str): "when_stream_chat_completions__should_return_ok", "when_conversational_rag__should_return_ok", "when_async_conversational_rag__should_return_ok", + "when_assistant__should_return_ok", + "when_async_assistant__should_return_ok", ], ) async def test_async_studio(test_file_name: str): diff --git a/tests/unittests/clients/studio/resources/assistant/__init__.py b/tests/unittests/clients/studio/resources/assistant/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/unittests/clients/studio/resources/assistant/plans/__init__.py b/tests/unittests/clients/studio/resources/assistant/plans/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/unittests/clients/studio/resources/assistant/plans/test_plan_body_creation.py b/tests/unittests/clients/studio/resources/assistant/plans/test_plan_body_creation.py new file mode 100644 index 00000000..bfd202c2 --- /dev/null +++ b/tests/unittests/clients/studio/resources/assistant/plans/test_plan_body_creation.py @@ -0,0 +1,130 @@ +from typing import Callable, List, Dict, Any, Type, Union + +from pydantic import BaseModel +from ai21.clients.common.beta.assistant.plans import BasePlans +from ai21.errors import CodeParsingError +from ai21.models.responses.plan_response import PlanResponse, ListPlanResponse +from ai21.types import NotGiven, NOT_GIVEN +import pytest + + +class PlanTestClass(BasePlans): + def create( + self, + *, + assistant_id: str, + code: Union[str, Callable], + schemas: Union[List[Dict[str, Any]], List[Type[BaseModel]], NotGiven] = NOT_GIVEN, + **kwargs, + ) -> PlanResponse: + pass + + def list(self, *, assistant_id: str) -> ListPlanResponse: + pass + + def retrieve(self, *, assistant_id: str, plan_id: str) -> PlanResponse: + pass + + def modify( + self, *, assistant_id: str, plan_id: str, code: str, schemas: Union[List[Dict[str, Any]], NotGiven] = NOT_GIVEN + ) -> PlanResponse: + pass + + +def test_create_body__when_pass_code_str__should_return_dict(): + # Arrange + code = "code" + + # Act + result = PlanTestClass()._create_body(code=code) + + # Assert + assert result == {"code": code} + + +def test_create_body__when_pass_code_callable__should_return_dict(): + # Arrange + def code(): + return "code" + + # Act + result = PlanTestClass()._create_body(code=code) + + # Assert + assert result == {"code": 'def code():\n return "code"'} + + +def test_create_body__when_pass_code_and_dict_schemas__should_return_dict_with_schemas(): + # Arrange + code = "code" + schemas = [{"type": "object", "properties": {"name": {"type": "string"}}}] + + # Act + result = PlanTestClass()._create_body(code=code, schemas=schemas) + + # Assert + assert result == {"code": code, "schemas": schemas} + + +class TestSchema(BaseModel): + name: str + age: int + + +def test_create_body__when_pass_code_and_pydantic_schemas__should_return_dict_with_converted_schemas(): + # Arrange + code = "code" + schemas = [TestSchema] + + # Act + result = PlanTestClass()._create_body(code=code, schemas=schemas) + + # Assert + expected_schema = { + "properties": {"age": {"title": "Age", "type": "integer"}, "name": {"title": "Name", "type": "string"}}, + "required": ["name", "age"], + "title": "TestSchema", + "type": "object", + } + assert result == {"code": code, "schemas": [expected_schema]} + + +def test_create_body__when_pass_code_and_not_given_schemas__should_return_dict_without_schemas(): + # Arrange + code = "code" + + # Act + result = PlanTestClass()._create_body(code=code, schemas=NOT_GIVEN) + + # Assert + assert result == {"code": code} + + +def test_create_body__when_pass_empty_schemas_list__should_return_dict_with_empty_schemas(): + # Arrange + code = "code" + schemas = [] + + # Act + result = PlanTestClass()._create_body(code=code, schemas=schemas) + + # Assert + assert result == {"code": code, "schemas": schemas} + + +def test_create_body__when_cannot_get_source_code__should_raise_code_parsing_error(): + # Arrange + class CallableWithoutSource: + def __call__(self): + return "result" + + # Override __code__ to simulate a built-in function or method + @property + def __code__(self): + raise AttributeError("'CallableWithoutSource' object has no attribute '__code__'") + + code = CallableWithoutSource() + + # Act & Assert + with pytest.raises(CodeParsingError): + PlanTestClass()._create_body(code=code)