Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/pip/urllib3-1.26.19
Browse files Browse the repository at this point in the history
  • Loading branch information
Josephasafg authored Jun 23, 2024
2 parents 33b469a + 09798b1 commit 4a7aea8
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
types: [submitted]
pull_request_review_comment:
types: [created, deleted]
pull_request:
pull_request_target:
types: [opened, edited, reopened, synchronize]

jobs:
Expand Down
123 changes: 123 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,131 @@



## v2.7.0 (2024-06-21)

### Chore

* 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] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Asaf Joseph Gardin <[email protected]> ([`c509b7e`](https://github.com/AI21Labs/ai21-python/commit/c509b7e59aa984cc9948db1362162eaa52eeb1d7))

* 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] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Asaf Joseph Gardin <[email protected]> ([`5eeaf52`](https://github.com/AI21Labs/ai21-python/commit/5eeaf52af19eee54d19fb9430b6caadf972e5f9c))

### Ci

* ci: Added parter labels (#147) ([`737d98f`](https://github.com/AI21Labs/ai21-python/commit/737d98f0b28d6e335b747dbae44fc68929cf39d6))

* ci: Auto Label (#142)

* ci: Auto lgtm

* fix: script

* fix: consts

* ci: Auto labeler action

* fix: on

* fix: Added more triggers

* fix: feat trigger

* ci: size labels

* fix: More tests

* docs: remove to add

* docs: Updated labeler

* fix: Added default

* fix: Removed line

* fix: labeler

* fix: prints

* fix: Script

* fix: scri[pt

* ci: Added prints

* ci: More prints

* ci: Added echo 0

* ci: Fixed condition

* fix: condition

* fix: Removed unused lines

* fix: Removed more prints

* ci: Lgtm

* fix: condition ([`b59407c`](https://github.com/AI21Labs/ai21-python/commit/b59407cb44e0f13ddc85cb07e721126df5acccfb))

### Documentation

* docs: Azure README (#139) ([`5b0eadb`](https://github.com/AI21Labs/ai21-python/commit/5b0eadbe88702e2ca28de608191d9a17b8c0b4b0))

### Feature

* 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 ([`f2d06fc`](https://github.com/AI21Labs/ai21-python/commit/f2d06fc7d2bc155beeaec72c0481f9a239656c07))

### Fix

* fix: Add default version to azure url (#148)

* fix: Added azure api version in the url

* fix: Added _create_base_url ([`cbea1d1`](https://github.com/AI21Labs/ai21-python/commit/cbea1d19197bf48c26679f8f97d37013333994f6))


## v2.6.0 (2024-06-13)

### Chore

* chore(release): v2.6.0 [skip ci] ([`3a6de49`](https://github.com/AI21Labs/ai21-python/commit/3a6de495aa88dc98577b8b27fff94cb88d7662ba))

### Feature

* feat: Azure Client Support (#135) ([`6115632`](https://github.com/AI21Labs/ai21-python/commit/611563279999168703e49dbbf288190ee0ae262d))
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ response = client.completion.create(

### Azure

If you wish to interact with your Azure endpoint on Azure AI Studio, use the the `AI21AzureClient`
If you wish to interact with your Azure endpoint on Azure AI Studio, use the `AI21AzureClient`
and `AsyncAI21AzureClient` clients.

The following models are supported on Azure:
Expand All @@ -568,7 +568,7 @@ messages = [

response = client.chat.completions.create(
model="jamba-instruct",
messages=[messages],
messages=messages,
)
```

Expand Down
11 changes: 11 additions & 0 deletions ai21/clients/azure/ai21_azure_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from ai21.clients.studio.resources.studio_chat import StudioChat, AsyncStudioChat

AzureADTokenProvider = Callable[[], str]
_DEFAULT_AZURE_VERSION = "v1"


class BaseAzureClient(ABC):
Expand Down Expand Up @@ -42,11 +43,18 @@ def _get_azure_ad_token(self) -> Optional[str]:

return None

def _add_version_to_url(self, base_url: str, api_version: str) -> str:
if api_version:
return f"{base_url}/{api_version}"

return f"{base_url}/{_DEFAULT_AZURE_VERSION}"


class AsyncAI21AzureClient(BaseAzureClient, AsyncAI21HTTPClient):
def __init__(
self,
base_url: str,
api_version: str = _DEFAULT_AZURE_VERSION,
api_key: Optional[str] = None,
azure_ad_token: str | None = None,
azure_ad_token_provider: AzureADTokenProvider | None = None,
Expand All @@ -62,6 +70,7 @@ def __init__(
raise ValueError("Must provide either api_key or azure_ad_token_provider or azure_ad_token")

headers = self._prepare_headers(headers=default_headers or {})
base_url = self._add_version_to_url(base_url=base_url, api_version=api_version)

super().__init__(
api_key=api_key,
Expand All @@ -81,6 +90,7 @@ class AI21AzureClient(BaseAzureClient, AI21HTTPClient):
def __init__(
self,
base_url: str,
api_version: str = _DEFAULT_AZURE_VERSION,
api_key: Optional[str] = None,
azure_ad_token: str | None = None,
azure_ad_token_provider: AzureADTokenProvider | None = None,
Expand All @@ -96,6 +106,7 @@ def __init__(
raise ValueError("Must provide either api_key or azure_ad_token_provider or azure_ad_token")

headers = self._prepare_headers(headers=default_headers or {})
base_url = self._add_version_to_url(base_url=base_url, api_version=api_version)

super().__init__(
api_key=api_key,
Expand Down
2 changes: 1 addition & 1 deletion ai21/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "2.6.0"
VERSION = "2.7.0"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ exclude_lines = [

[tool.poetry]
name = "ai21"
version = "2.6.0"
version = "2.7.0"
description = ""
authors = ["AI21 Labs"]
readme = "README.md"
Expand Down

0 comments on commit 4a7aea8

Please sign in to comment.