From 16ef9038dc50f4c7731953bdc51073ba45655b03 Mon Sep 17 00:00:00 2001 From: benshuk Date: Wed, 27 Nov 2024 18:36:59 +0200 Subject: [PATCH 01/50] feat: :sparkles: add support for Assistant resource under `beta` --- ai21/clients/common/assistant/__init__.py | 0 ai21/clients/common/assistant/assistant.py | 131 ++++++++++++++++++ .../studio/resources/assistant/__init__.py | 0 .../resources/assistant/studio_assistant.py | 131 ++++++++++++++++++ .../studio/resources/beta/async_beta.py | 2 + ai21/clients/studio/resources/beta/beta.py | 2 + .../studio/resources/studio_resource.py | 12 ++ ai21/models/responses/assistant_response.py | 21 +++ examples/studio/assistant/__init__.py | 0 9 files changed, 299 insertions(+) create mode 100644 ai21/clients/common/assistant/__init__.py create mode 100644 ai21/clients/common/assistant/assistant.py create mode 100644 ai21/clients/studio/resources/assistant/__init__.py create mode 100644 ai21/clients/studio/resources/assistant/studio_assistant.py create mode 100644 ai21/models/responses/assistant_response.py create mode 100644 examples/studio/assistant/__init__.py diff --git a/ai21/clients/common/assistant/__init__.py b/ai21/clients/common/assistant/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/ai21/clients/common/assistant/assistant.py b/ai21/clients/common/assistant/assistant.py new file mode 100644 index 00000000..a646a917 --- /dev/null +++ b/ai21/clients/common/assistant/assistant.py @@ -0,0 +1,131 @@ +from __future__ import annotations + +from abc import ABC, abstractmethod +from typing import Any, Dict, List + +from ai21.models.responses.assistant_response import AssistantResponse +from ai21.types import NotGiven, NOT_GIVEN +from ai21.utils.typing import remove_not_given + + +class Assistant(ABC): + _module_name = "assistants" + + @abstractmethod + def create( + self, + name: str, + *, + description: str | NotGiven = NOT_GIVEN, + optimization: str | NotGiven = NOT_GIVEN, + avatar: str | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, + tools: List[str] | NotGiven = NOT_GIVEN, + tool_resources: dict | NotGiven = NOT_GIVEN, + **kwargs, + ) -> AssistantResponse: + """ + :param name: The name of the assistant. + :param description: The description of the assistant. + :param optimization: The optimization to use. + :param avatar: The avatar to use. + :param models: The models to use. + :param tools: The tools to use. + :param tool_resources: The tool resources to use. + :param kwargs: Additional keyword arguments. + :return: The response object. + """ + pass + + def _create_body( + self, + name: str, + *, + description: str | NotGiven, + optimization: str | NotGiven, + avatar: str | NotGiven, + models: List[str] | NotGiven, + tools: List[str] | NotGiven, + tool_resources: dict | NotGiven, + **kwargs, + ) -> Dict[str, Any]: + return remove_not_given( + { + "name": name, + "description": description, + "optimization": optimization, + "avatar": avatar, + "models": models, + "tools": tools, + "tool_resources": tool_resources, + **kwargs, + } + ) + + @abstractmethod + def list(self) -> List[AssistantResponse]: + """ + :return: The response object. + """ + pass + + @abstractmethod + def get(self, assistant_id: str) -> AssistantResponse: + """ + :param assistant_id: The ID of the assistant. + :return: The response object. + """ + pass + + @abstractmethod + def modify( + self, + assistant_id: str, + *, + name: str | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + optimization: str | NotGiven = NOT_GIVEN, + avatar: str | NotGiven = NOT_GIVEN, + is_archived: bool | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, + tools: List[str] | NotGiven = NOT_GIVEN, + tool_resources: dict | NotGiven = NOT_GIVEN, + ) -> AssistantResponse: + """ + :param assistant_id: The ID of the assistant. + :param name: The name of the assistant. + :param description: The description of the assistant. + :param optimization: The optimization to use. + :param avatar: The avatar to use. + :param is_archived: Whether the assistant is archived. + :param models: The models to use. + :param tools: The tools to use. + :param tool_resources: The tool resources to use. + :param kwargs: Additional keyword arguments. + :return: The response object. + """ + pass + + def _modify_body( + self, + name: str, + description: str | NotGiven, + optimization: str | NotGiven, + avatar: str | NotGiven, + is_archived: bool | NotGiven, + models: List[str] | NotGiven, + tools: List[str] | NotGiven, + tool_resources: dict | NotGiven, + ) -> Dict[str, Any]: + return remove_not_given( + { + "name": name, + "description": description, + "optimization": optimization, + "avatar": avatar, + "is_archived": is_archived, + "models": models, + "tools": tools, + "tool_resources": tool_resources, + } + ) diff --git a/ai21/clients/studio/resources/assistant/__init__.py b/ai21/clients/studio/resources/assistant/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/ai21/clients/studio/resources/assistant/studio_assistant.py b/ai21/clients/studio/resources/assistant/studio_assistant.py new file mode 100644 index 00000000..0fea72a3 --- /dev/null +++ b/ai21/clients/studio/resources/assistant/studio_assistant.py @@ -0,0 +1,131 @@ +from __future__ import annotations + +from typing import List + +from ai21.clients.common.assistant.assistant import Assistant +from ai21.clients.studio.resources.studio_resource import ( + AsyncStudioResource, + StudioResource, +) +from ai21.models.responses.assistant_response import AssistantResponse +from ai21.types import NotGiven, NOT_GIVEN + + +class StudioAssistant(StudioResource, Assistant): + def create( + self, + name: str, + *, + description: str | NotGiven = NOT_GIVEN, + optimization: str | NotGiven = NOT_GIVEN, + avatar: str | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, + tools: List[str] | NotGiven = NOT_GIVEN, + tool_resources: dict | NotGiven = NOT_GIVEN, + **kwargs, + ) -> AssistantResponse: + body = self._create_body( + name=name, + description=description, + optimization=optimization, + avatar=avatar, + models=models, + tools=tools, + tool_resources=tool_resources, + **kwargs, + ) + + return self._post(path=f"/{self._module_name}", body=body, response_cls=AssistantResponse) + + def get(self, assistant_id: str) -> AssistantResponse: + return self._get(path=f"/{self._module_name}/{assistant_id}", response_cls=AssistantResponse) + + def list(self) -> List[AssistantResponse]: + response = self._get(path=f"/{self._module_name}") + return response["results"] + + def modify( + self, + assistant_id: str, + *, + name: str | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + optimization: str | NotGiven = NOT_GIVEN, + avatar: str | NotGiven = NOT_GIVEN, + is_archived: bool | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, + tools: List[str] | NotGiven = NOT_GIVEN, + tool_resources: dict | NotGiven = NOT_GIVEN, + ) -> AssistantResponse: + body = self._modify_body( + name=name, + description=description, + optimization=optimization, + avatar=avatar, + 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) + + +class AsyncStudioAssistant(AsyncStudioResource, Assistant): + async def create( + self, + name: str, + *, + description: str | NotGiven = NOT_GIVEN, + optimization: str | NotGiven = NOT_GIVEN, + avatar: str | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, + tools: List[str] | NotGiven = NOT_GIVEN, + tool_resources: dict | NotGiven = NOT_GIVEN, + **kwargs, + ) -> AssistantResponse: + body = self._create_body( + name=name, + description=description, + optimization=optimization, + avatar=avatar, + models=models, + tools=tools, + tool_resources=tool_resources, + **kwargs, + ) + + return self._post(path=f"/{self._module_name}", body=body, response_cls=AssistantResponse) + + async def get(self, assistant_id: str) -> AssistantResponse: + return await self._get(path=f"/{self._module_name}/{assistant_id}", response_cls=AssistantResponse) + + async def list(self) -> List[AssistantResponse]: + response = await self._get(path=f"/{self._module_name}") + return response["results"] + + async def modify( + self, + assistant_id: str, + *, + name: str | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + optimization: str | NotGiven = NOT_GIVEN, + avatar: str | NotGiven = NOT_GIVEN, + is_archived: bool | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, + tools: List[str] | NotGiven = NOT_GIVEN, + tool_resources: dict | NotGiven = NOT_GIVEN, + ) -> AssistantResponse: + body = self._modify_body( + name=name, + description=description, + optimization=optimization, + avatar=avatar, + 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) diff --git a/ai21/clients/studio/resources/beta/async_beta.py b/ai21/clients/studio/resources/beta/async_beta.py index a94ddc95..521c7a13 100644 --- a/ai21/clients/studio/resources/beta/async_beta.py +++ b/ai21/clients/studio/resources/beta/async_beta.py @@ -1,3 +1,4 @@ +from ai21.clients.studio.resources.assistant.studio_assistant import AsyncStudioAssistant 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 @@ -8,3 +9,4 @@ def __init__(self, client: AsyncAI21HTTPClient): super().__init__(client) self.conversational_rag = AsyncStudioConversationalRag(client) + self.assistants = AsyncStudioAssistant(client) diff --git a/ai21/clients/studio/resources/beta/beta.py b/ai21/clients/studio/resources/beta/beta.py index 1269f970..8560597a 100644 --- a/ai21/clients/studio/resources/beta/beta.py +++ b/ai21/clients/studio/resources/beta/beta.py @@ -1,3 +1,4 @@ +from ai21.clients.studio.resources.assistant.studio_assistant import StudioAssistant 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 @@ -8,3 +9,4 @@ def __init__(self, client: AI21HTTPClient): super().__init__(client) self.conversational_rag = StudioConversationalRag(client) + self.assistants = StudioAssistant(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/models/responses/assistant_response.py b/ai21/models/responses/assistant_response.py new file mode 100644 index 00000000..dea5833d --- /dev/null +++ b/ai21/models/responses/assistant_response.py @@ -0,0 +1,21 @@ +from datetime import datetime +from typing import Optional + +from ai21.models.ai21_base_model import AI21BaseModel + + +class AssistantResponse(AI21BaseModel): + id: str + created_at: datetime + updated_at: datetime + object: str + name: str + description: Optional[str] + optimization: str + organization_id: str + user_id: str + avatar: Optional[str] = None + is_archived: bool = False + models: Optional[list[str]] = None + tools: Optional[list[str]] = None + tool_resources: Optional[dict] = None diff --git a/examples/studio/assistant/__init__.py b/examples/studio/assistant/__init__.py new file mode 100644 index 00000000..e69de29b From fc45f19027b9f21cbf3c711952a6b1ddc3db932c Mon Sep 17 00:00:00 2001 From: benshuk Date: Thu, 28 Nov 2024 10:38:48 +0200 Subject: [PATCH 02/50] fix: :bug: use `List` for typing instead of `list` --- ai21/models/responses/assistant_response.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ai21/models/responses/assistant_response.py b/ai21/models/responses/assistant_response.py index dea5833d..9863f106 100644 --- a/ai21/models/responses/assistant_response.py +++ b/ai21/models/responses/assistant_response.py @@ -1,5 +1,5 @@ from datetime import datetime -from typing import Optional +from typing import Optional, List from ai21.models.ai21_base_model import AI21BaseModel @@ -16,6 +16,6 @@ class AssistantResponse(AI21BaseModel): user_id: str avatar: Optional[str] = None is_archived: bool = False - models: Optional[list[str]] = None - tools: Optional[list[str]] = None + models: Optional[List[str]] = None + tools: Optional[List[str]] = None tool_resources: Optional[dict] = None From 18d009202b64a41e70c9824fa14256e4c741606f Mon Sep 17 00:00:00 2001 From: benshuk Date: Thu, 28 Nov 2024 15:33:26 +0200 Subject: [PATCH 03/50] fix: :label: better typing & remove doc string --- ai21/clients/common/assistant/assistant.py | 49 ++++----------------- ai21/models/responses/assistant_response.py | 13 +++++- 2 files changed, 21 insertions(+), 41 deletions(-) diff --git a/ai21/clients/common/assistant/assistant.py b/ai21/clients/common/assistant/assistant.py index a646a917..2a2fc135 100644 --- a/ai21/clients/common/assistant/assistant.py +++ b/ai21/clients/common/assistant/assistant.py @@ -3,7 +3,7 @@ from abc import ABC, abstractmethod from typing import Any, Dict, List -from ai21.models.responses.assistant_response import AssistantResponse +from ai21.models.responses.assistant_response import AssistantResponse, Optimization, ToolsResources, Model, Tool from ai21.types import NotGiven, NOT_GIVEN from ai21.utils.typing import remove_not_given @@ -17,24 +17,13 @@ def create( name: str, *, description: str | NotGiven = NOT_GIVEN, - optimization: str | NotGiven = NOT_GIVEN, + optimization: Optimization | NotGiven = NOT_GIVEN, avatar: str | NotGiven = NOT_GIVEN, - models: List[str] | NotGiven = NOT_GIVEN, - tools: List[str] | NotGiven = NOT_GIVEN, - tool_resources: dict | NotGiven = NOT_GIVEN, + models: List[Model] | NotGiven = NOT_GIVEN, + tools: List[Tool] | NotGiven = NOT_GIVEN, + tool_resources: ToolsResources | NotGiven = NOT_GIVEN, **kwargs, ) -> AssistantResponse: - """ - :param name: The name of the assistant. - :param description: The description of the assistant. - :param optimization: The optimization to use. - :param avatar: The avatar to use. - :param models: The models to use. - :param tools: The tools to use. - :param tool_resources: The tool resources to use. - :param kwargs: Additional keyword arguments. - :return: The response object. - """ pass def _create_body( @@ -64,17 +53,10 @@ def _create_body( @abstractmethod def list(self) -> List[AssistantResponse]: - """ - :return: The response object. - """ pass @abstractmethod def get(self, assistant_id: str) -> AssistantResponse: - """ - :param assistant_id: The ID of the assistant. - :return: The response object. - """ pass @abstractmethod @@ -84,26 +66,13 @@ def modify( *, name: str | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, - optimization: str | NotGiven = NOT_GIVEN, + optimization: Optimization | NotGiven = NOT_GIVEN, avatar: str | NotGiven = NOT_GIVEN, is_archived: bool | NotGiven = NOT_GIVEN, - models: List[str] | NotGiven = NOT_GIVEN, - tools: List[str] | NotGiven = NOT_GIVEN, - tool_resources: dict | NotGiven = NOT_GIVEN, + models: List[Model] | NotGiven = NOT_GIVEN, + tools: List[Tool] | NotGiven = NOT_GIVEN, + tool_resources: ToolsResources | NotGiven = NOT_GIVEN, ) -> AssistantResponse: - """ - :param assistant_id: The ID of the assistant. - :param name: The name of the assistant. - :param description: The description of the assistant. - :param optimization: The optimization to use. - :param avatar: The avatar to use. - :param is_archived: Whether the assistant is archived. - :param models: The models to use. - :param tools: The tools to use. - :param tool_resources: The tool resources to use. - :param kwargs: Additional keyword arguments. - :return: The response object. - """ pass def _modify_body( diff --git a/ai21/models/responses/assistant_response.py b/ai21/models/responses/assistant_response.py index 9863f106..5b0d0769 100644 --- a/ai21/models/responses/assistant_response.py +++ b/ai21/models/responses/assistant_response.py @@ -1,9 +1,20 @@ from datetime import datetime -from typing import Optional, List +from typing import Optional, List, Literal, TypedDict from ai21.models.ai21_base_model import AI21BaseModel +Optimization = Literal["cost", "latency"] +Model = Literal["jamba-1-5", "jamba-1-5-large"] +Tool = Literal["rag", "internet_research", "plan_approval"] + + +class ToolsResources(TypedDict, total=False): + rag: Optional[dict] + internet_research: Optional[dict] + plan_approval: Optional[dict] + + class AssistantResponse(AI21BaseModel): id: str created_at: datetime From c46e517cfd8619e4cb25581f5e714ee8fc919e47 Mon Sep 17 00:00:00 2001 From: benshuk Date: Thu, 28 Nov 2024 16:38:08 +0200 Subject: [PATCH 04/50] fix: :bug: pr fixes --- ai21/clients/common/assistant/assistant.py | 41 +++++------------ .../resources/assistant/studio_assistant.py | 46 ++++++++++--------- ai21/models/responses/assistant_response.py | 6 ++- 3 files changed, 42 insertions(+), 51 deletions(-) diff --git a/ai21/clients/common/assistant/assistant.py b/ai21/clients/common/assistant/assistant.py index 2a2fc135..24eb1508 100644 --- a/ai21/clients/common/assistant/assistant.py +++ b/ai21/clients/common/assistant/assistant.py @@ -3,7 +3,14 @@ from abc import ABC, abstractmethod from typing import Any, Dict, List -from ai21.models.responses.assistant_response import AssistantResponse, Optimization, ToolsResources, Model, Tool +from ai21.models.responses.assistant_response import ( + AssistantResponse, + Optimization, + ToolResources, + Model, + Tool, + ListAssistantResponse, +) from ai21.types import NotGiven, NOT_GIVEN from ai21.utils.typing import remove_not_given @@ -21,15 +28,15 @@ def create( avatar: str | NotGiven = NOT_GIVEN, models: List[Model] | NotGiven = NOT_GIVEN, tools: List[Tool] | NotGiven = NOT_GIVEN, - tool_resources: ToolsResources | NotGiven = NOT_GIVEN, + tool_resources: ToolResources | NotGiven = NOT_GIVEN, **kwargs, ) -> AssistantResponse: pass def _create_body( self, - name: str, *, + name: str, description: str | NotGiven, optimization: str | NotGiven, avatar: str | NotGiven, @@ -52,7 +59,7 @@ def _create_body( ) @abstractmethod - def list(self) -> List[AssistantResponse]: + def list(self) -> ListAssistantResponse: pass @abstractmethod @@ -71,30 +78,6 @@ def modify( is_archived: bool | NotGiven = NOT_GIVEN, models: List[Model] | NotGiven = NOT_GIVEN, tools: List[Tool] | NotGiven = NOT_GIVEN, - tool_resources: ToolsResources | NotGiven = NOT_GIVEN, + tool_resources: ToolResources | NotGiven = NOT_GIVEN, ) -> AssistantResponse: pass - - def _modify_body( - self, - name: str, - description: str | NotGiven, - optimization: str | NotGiven, - avatar: str | NotGiven, - is_archived: bool | NotGiven, - models: List[str] | NotGiven, - tools: List[str] | NotGiven, - tool_resources: dict | NotGiven, - ) -> Dict[str, Any]: - return remove_not_given( - { - "name": name, - "description": description, - "optimization": optimization, - "avatar": avatar, - "is_archived": is_archived, - "models": models, - "tools": tools, - "tool_resources": tool_resources, - } - ) diff --git a/ai21/clients/studio/resources/assistant/studio_assistant.py b/ai21/clients/studio/resources/assistant/studio_assistant.py index 0fea72a3..4c336a55 100644 --- a/ai21/clients/studio/resources/assistant/studio_assistant.py +++ b/ai21/clients/studio/resources/assistant/studio_assistant.py @@ -7,7 +7,13 @@ AsyncStudioResource, StudioResource, ) -from ai21.models.responses.assistant_response import AssistantResponse +from ai21.models.responses.assistant_response import ( + AssistantResponse, + Model, + Tool, + ToolResources, + ListAssistantResponse, +) from ai21.types import NotGiven, NOT_GIVEN @@ -19,9 +25,9 @@ def create( description: str | NotGiven = NOT_GIVEN, optimization: str | NotGiven = NOT_GIVEN, avatar: str | NotGiven = NOT_GIVEN, - models: List[str] | NotGiven = NOT_GIVEN, - tools: List[str] | NotGiven = NOT_GIVEN, - tool_resources: dict | NotGiven = NOT_GIVEN, + models: List[Model] | NotGiven = NOT_GIVEN, + tools: List[Tool] | NotGiven = NOT_GIVEN, + tool_resources: ToolResources | NotGiven = NOT_GIVEN, **kwargs, ) -> AssistantResponse: body = self._create_body( @@ -40,9 +46,8 @@ def create( def get(self, assistant_id: str) -> AssistantResponse: return self._get(path=f"/{self._module_name}/{assistant_id}", response_cls=AssistantResponse) - def list(self) -> List[AssistantResponse]: - response = self._get(path=f"/{self._module_name}") - return response["results"] + def list(self) -> ListAssistantResponse: + return self._get(path=f"/{self._module_name}", response_cls=ListAssistantResponse) def modify( self, @@ -53,11 +58,11 @@ def modify( optimization: str | NotGiven = NOT_GIVEN, avatar: str | NotGiven = NOT_GIVEN, is_archived: bool | NotGiven = NOT_GIVEN, - models: List[str] | NotGiven = NOT_GIVEN, - tools: List[str] | NotGiven = NOT_GIVEN, - tool_resources: dict | NotGiven = NOT_GIVEN, + models: List[Model] | NotGiven = NOT_GIVEN, + tools: List[Tool] | NotGiven = NOT_GIVEN, + tool_resources: ToolResources | NotGiven = NOT_GIVEN, ) -> AssistantResponse: - body = self._modify_body( + body = self._create_body( name=name, description=description, optimization=optimization, @@ -79,9 +84,9 @@ async def create( description: str | NotGiven = NOT_GIVEN, optimization: str | NotGiven = NOT_GIVEN, avatar: str | NotGiven = NOT_GIVEN, - models: List[str] | NotGiven = NOT_GIVEN, - tools: List[str] | NotGiven = NOT_GIVEN, - tool_resources: dict | NotGiven = NOT_GIVEN, + models: List[Model] | NotGiven = NOT_GIVEN, + tools: List[Tool] | NotGiven = NOT_GIVEN, + tool_resources: ToolResources | NotGiven = NOT_GIVEN, **kwargs, ) -> AssistantResponse: body = self._create_body( @@ -100,9 +105,8 @@ async def create( async def get(self, assistant_id: str) -> AssistantResponse: return await self._get(path=f"/{self._module_name}/{assistant_id}", response_cls=AssistantResponse) - async def list(self) -> List[AssistantResponse]: - response = await self._get(path=f"/{self._module_name}") - return response["results"] + async def list(self) -> ListAssistantResponse: + return await self._get(path=f"/{self._module_name}", response_cls=ListAssistantResponse) async def modify( self, @@ -113,11 +117,11 @@ async def modify( optimization: str | NotGiven = NOT_GIVEN, avatar: str | NotGiven = NOT_GIVEN, is_archived: bool | NotGiven = NOT_GIVEN, - models: List[str] | NotGiven = NOT_GIVEN, - tools: List[str] | NotGiven = NOT_GIVEN, - tool_resources: dict | NotGiven = NOT_GIVEN, + models: List[Model] | NotGiven = NOT_GIVEN, + tools: List[Tool] | NotGiven = NOT_GIVEN, + tool_resources: ToolResources | NotGiven = NOT_GIVEN, ) -> AssistantResponse: - body = self._modify_body( + body = self._create_body( name=name, description=description, optimization=optimization, diff --git a/ai21/models/responses/assistant_response.py b/ai21/models/responses/assistant_response.py index 5b0d0769..9eb2ac2e 100644 --- a/ai21/models/responses/assistant_response.py +++ b/ai21/models/responses/assistant_response.py @@ -9,7 +9,7 @@ Tool = Literal["rag", "internet_research", "plan_approval"] -class ToolsResources(TypedDict, total=False): +class ToolResources(TypedDict, total=False): rag: Optional[dict] internet_research: Optional[dict] plan_approval: Optional[dict] @@ -30,3 +30,7 @@ class AssistantResponse(AI21BaseModel): models: Optional[List[str]] = None tools: Optional[List[str]] = None tool_resources: Optional[dict] = None + + +class ListAssistantResponse(AI21BaseModel): + results: List[AssistantResponse] From 90f44f575b3031f4b11edcbc6e9fef4a8b2e1c62 Mon Sep 17 00:00:00 2001 From: benshuk Date: Thu, 28 Nov 2024 16:57:28 +0200 Subject: [PATCH 05/50] fix: :label: remove `Model` Literal typing --- ai21/clients/common/assistant/assistant.py | 5 ++--- .../studio/resources/assistant/studio_assistant.py | 9 ++++----- ai21/models/responses/assistant_response.py | 3 +-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/ai21/clients/common/assistant/assistant.py b/ai21/clients/common/assistant/assistant.py index 24eb1508..c2ad588a 100644 --- a/ai21/clients/common/assistant/assistant.py +++ b/ai21/clients/common/assistant/assistant.py @@ -7,7 +7,6 @@ AssistantResponse, Optimization, ToolResources, - Model, Tool, ListAssistantResponse, ) @@ -26,7 +25,7 @@ def create( description: str | NotGiven = NOT_GIVEN, optimization: Optimization | NotGiven = NOT_GIVEN, avatar: str | NotGiven = NOT_GIVEN, - models: List[Model] | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, tools: List[Tool] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, **kwargs, @@ -76,7 +75,7 @@ def modify( optimization: Optimization | NotGiven = NOT_GIVEN, avatar: str | NotGiven = NOT_GIVEN, is_archived: bool | NotGiven = NOT_GIVEN, - models: List[Model] | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, tools: List[Tool] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, ) -> AssistantResponse: diff --git a/ai21/clients/studio/resources/assistant/studio_assistant.py b/ai21/clients/studio/resources/assistant/studio_assistant.py index 4c336a55..82014880 100644 --- a/ai21/clients/studio/resources/assistant/studio_assistant.py +++ b/ai21/clients/studio/resources/assistant/studio_assistant.py @@ -9,7 +9,6 @@ ) from ai21.models.responses.assistant_response import ( AssistantResponse, - Model, Tool, ToolResources, ListAssistantResponse, @@ -25,7 +24,7 @@ def create( description: str | NotGiven = NOT_GIVEN, optimization: str | NotGiven = NOT_GIVEN, avatar: str | NotGiven = NOT_GIVEN, - models: List[Model] | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, tools: List[Tool] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, **kwargs, @@ -58,7 +57,7 @@ def modify( optimization: str | NotGiven = NOT_GIVEN, avatar: str | NotGiven = NOT_GIVEN, is_archived: bool | NotGiven = NOT_GIVEN, - models: List[Model] | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, tools: List[Tool] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, ) -> AssistantResponse: @@ -84,7 +83,7 @@ async def create( description: str | NotGiven = NOT_GIVEN, optimization: str | NotGiven = NOT_GIVEN, avatar: str | NotGiven = NOT_GIVEN, - models: List[Model] | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, tools: List[Tool] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, **kwargs, @@ -117,7 +116,7 @@ async def modify( optimization: str | NotGiven = NOT_GIVEN, avatar: str | NotGiven = NOT_GIVEN, is_archived: bool | NotGiven = NOT_GIVEN, - models: List[Model] | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, tools: List[Tool] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, ) -> AssistantResponse: diff --git a/ai21/models/responses/assistant_response.py b/ai21/models/responses/assistant_response.py index 9eb2ac2e..f6a54cd7 100644 --- a/ai21/models/responses/assistant_response.py +++ b/ai21/models/responses/assistant_response.py @@ -5,7 +5,6 @@ Optimization = Literal["cost", "latency"] -Model = Literal["jamba-1-5", "jamba-1-5-large"] Tool = Literal["rag", "internet_research", "plan_approval"] @@ -21,7 +20,7 @@ class AssistantResponse(AI21BaseModel): updated_at: datetime object: str name: str - description: Optional[str] + description: Optional[str] = None optimization: str organization_id: str user_id: str From 5de2d8c0af03b7e1fb95bf7302422374e0d77954 Mon Sep 17 00:00:00 2001 From: benshuk Date: Thu, 28 Nov 2024 17:03:09 +0200 Subject: [PATCH 06/50] fix: :label: tool_resources use type --- ai21/models/responses/assistant_response.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ai21/models/responses/assistant_response.py b/ai21/models/responses/assistant_response.py index f6a54cd7..453d1c46 100644 --- a/ai21/models/responses/assistant_response.py +++ b/ai21/models/responses/assistant_response.py @@ -28,7 +28,7 @@ class AssistantResponse(AI21BaseModel): is_archived: bool = False models: Optional[List[str]] = None tools: Optional[List[str]] = None - tool_resources: Optional[dict] = None + tool_resources: Optional[ToolResources] = None class ListAssistantResponse(AI21BaseModel): From a9f7d67feaa088ffa97f87220e3198cf0d5eb0b3 Mon Sep 17 00:00:00 2001 From: benshuk Date: Thu, 28 Nov 2024 17:10:19 +0200 Subject: [PATCH 07/50] fix: :green_heart: imports --- ai21/models/responses/assistant_response.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ai21/models/responses/assistant_response.py b/ai21/models/responses/assistant_response.py index 453d1c46..d7b0f186 100644 --- a/ai21/models/responses/assistant_response.py +++ b/ai21/models/responses/assistant_response.py @@ -1,5 +1,7 @@ from datetime import datetime -from typing import Optional, List, Literal, TypedDict +from typing import Optional, List, Literal + +from typing_extensions import TypedDict from ai21.models.ai21_base_model import AI21BaseModel From 4b31a42351d42b6604a9b05ea9bc0b19413d91d8 Mon Sep 17 00:00:00 2001 From: benshuk Date: Wed, 27 Nov 2024 18:36:59 +0200 Subject: [PATCH 08/50] feat: :sparkles: add support for Assistant resource under `beta` --- ai21/clients/common/assistant/__init__.py | 0 ai21/clients/common/assistant/assistant.py | 131 ++++++++++++++++++ .../studio/resources/assistant/__init__.py | 0 .../resources/assistant/studio_assistant.py | 131 ++++++++++++++++++ .../studio/resources/beta/async_beta.py | 2 + ai21/clients/studio/resources/beta/beta.py | 2 + .../studio/resources/studio_resource.py | 12 ++ ai21/models/responses/assistant_response.py | 21 +++ examples/studio/assistant/__init__.py | 0 9 files changed, 299 insertions(+) create mode 100644 ai21/clients/common/assistant/__init__.py create mode 100644 ai21/clients/common/assistant/assistant.py create mode 100644 ai21/clients/studio/resources/assistant/__init__.py create mode 100644 ai21/clients/studio/resources/assistant/studio_assistant.py create mode 100644 ai21/models/responses/assistant_response.py create mode 100644 examples/studio/assistant/__init__.py diff --git a/ai21/clients/common/assistant/__init__.py b/ai21/clients/common/assistant/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/ai21/clients/common/assistant/assistant.py b/ai21/clients/common/assistant/assistant.py new file mode 100644 index 00000000..a646a917 --- /dev/null +++ b/ai21/clients/common/assistant/assistant.py @@ -0,0 +1,131 @@ +from __future__ import annotations + +from abc import ABC, abstractmethod +from typing import Any, Dict, List + +from ai21.models.responses.assistant_response import AssistantResponse +from ai21.types import NotGiven, NOT_GIVEN +from ai21.utils.typing import remove_not_given + + +class Assistant(ABC): + _module_name = "assistants" + + @abstractmethod + def create( + self, + name: str, + *, + description: str | NotGiven = NOT_GIVEN, + optimization: str | NotGiven = NOT_GIVEN, + avatar: str | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, + tools: List[str] | NotGiven = NOT_GIVEN, + tool_resources: dict | NotGiven = NOT_GIVEN, + **kwargs, + ) -> AssistantResponse: + """ + :param name: The name of the assistant. + :param description: The description of the assistant. + :param optimization: The optimization to use. + :param avatar: The avatar to use. + :param models: The models to use. + :param tools: The tools to use. + :param tool_resources: The tool resources to use. + :param kwargs: Additional keyword arguments. + :return: The response object. + """ + pass + + def _create_body( + self, + name: str, + *, + description: str | NotGiven, + optimization: str | NotGiven, + avatar: str | NotGiven, + models: List[str] | NotGiven, + tools: List[str] | NotGiven, + tool_resources: dict | NotGiven, + **kwargs, + ) -> Dict[str, Any]: + return remove_not_given( + { + "name": name, + "description": description, + "optimization": optimization, + "avatar": avatar, + "models": models, + "tools": tools, + "tool_resources": tool_resources, + **kwargs, + } + ) + + @abstractmethod + def list(self) -> List[AssistantResponse]: + """ + :return: The response object. + """ + pass + + @abstractmethod + def get(self, assistant_id: str) -> AssistantResponse: + """ + :param assistant_id: The ID of the assistant. + :return: The response object. + """ + pass + + @abstractmethod + def modify( + self, + assistant_id: str, + *, + name: str | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + optimization: str | NotGiven = NOT_GIVEN, + avatar: str | NotGiven = NOT_GIVEN, + is_archived: bool | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, + tools: List[str] | NotGiven = NOT_GIVEN, + tool_resources: dict | NotGiven = NOT_GIVEN, + ) -> AssistantResponse: + """ + :param assistant_id: The ID of the assistant. + :param name: The name of the assistant. + :param description: The description of the assistant. + :param optimization: The optimization to use. + :param avatar: The avatar to use. + :param is_archived: Whether the assistant is archived. + :param models: The models to use. + :param tools: The tools to use. + :param tool_resources: The tool resources to use. + :param kwargs: Additional keyword arguments. + :return: The response object. + """ + pass + + def _modify_body( + self, + name: str, + description: str | NotGiven, + optimization: str | NotGiven, + avatar: str | NotGiven, + is_archived: bool | NotGiven, + models: List[str] | NotGiven, + tools: List[str] | NotGiven, + tool_resources: dict | NotGiven, + ) -> Dict[str, Any]: + return remove_not_given( + { + "name": name, + "description": description, + "optimization": optimization, + "avatar": avatar, + "is_archived": is_archived, + "models": models, + "tools": tools, + "tool_resources": tool_resources, + } + ) diff --git a/ai21/clients/studio/resources/assistant/__init__.py b/ai21/clients/studio/resources/assistant/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/ai21/clients/studio/resources/assistant/studio_assistant.py b/ai21/clients/studio/resources/assistant/studio_assistant.py new file mode 100644 index 00000000..0fea72a3 --- /dev/null +++ b/ai21/clients/studio/resources/assistant/studio_assistant.py @@ -0,0 +1,131 @@ +from __future__ import annotations + +from typing import List + +from ai21.clients.common.assistant.assistant import Assistant +from ai21.clients.studio.resources.studio_resource import ( + AsyncStudioResource, + StudioResource, +) +from ai21.models.responses.assistant_response import AssistantResponse +from ai21.types import NotGiven, NOT_GIVEN + + +class StudioAssistant(StudioResource, Assistant): + def create( + self, + name: str, + *, + description: str | NotGiven = NOT_GIVEN, + optimization: str | NotGiven = NOT_GIVEN, + avatar: str | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, + tools: List[str] | NotGiven = NOT_GIVEN, + tool_resources: dict | NotGiven = NOT_GIVEN, + **kwargs, + ) -> AssistantResponse: + body = self._create_body( + name=name, + description=description, + optimization=optimization, + avatar=avatar, + models=models, + tools=tools, + tool_resources=tool_resources, + **kwargs, + ) + + return self._post(path=f"/{self._module_name}", body=body, response_cls=AssistantResponse) + + def get(self, assistant_id: str) -> AssistantResponse: + return self._get(path=f"/{self._module_name}/{assistant_id}", response_cls=AssistantResponse) + + def list(self) -> List[AssistantResponse]: + response = self._get(path=f"/{self._module_name}") + return response["results"] + + def modify( + self, + assistant_id: str, + *, + name: str | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + optimization: str | NotGiven = NOT_GIVEN, + avatar: str | NotGiven = NOT_GIVEN, + is_archived: bool | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, + tools: List[str] | NotGiven = NOT_GIVEN, + tool_resources: dict | NotGiven = NOT_GIVEN, + ) -> AssistantResponse: + body = self._modify_body( + name=name, + description=description, + optimization=optimization, + avatar=avatar, + 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) + + +class AsyncStudioAssistant(AsyncStudioResource, Assistant): + async def create( + self, + name: str, + *, + description: str | NotGiven = NOT_GIVEN, + optimization: str | NotGiven = NOT_GIVEN, + avatar: str | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, + tools: List[str] | NotGiven = NOT_GIVEN, + tool_resources: dict | NotGiven = NOT_GIVEN, + **kwargs, + ) -> AssistantResponse: + body = self._create_body( + name=name, + description=description, + optimization=optimization, + avatar=avatar, + models=models, + tools=tools, + tool_resources=tool_resources, + **kwargs, + ) + + return self._post(path=f"/{self._module_name}", body=body, response_cls=AssistantResponse) + + async def get(self, assistant_id: str) -> AssistantResponse: + return await self._get(path=f"/{self._module_name}/{assistant_id}", response_cls=AssistantResponse) + + async def list(self) -> List[AssistantResponse]: + response = await self._get(path=f"/{self._module_name}") + return response["results"] + + async def modify( + self, + assistant_id: str, + *, + name: str | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + optimization: str | NotGiven = NOT_GIVEN, + avatar: str | NotGiven = NOT_GIVEN, + is_archived: bool | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, + tools: List[str] | NotGiven = NOT_GIVEN, + tool_resources: dict | NotGiven = NOT_GIVEN, + ) -> AssistantResponse: + body = self._modify_body( + name=name, + description=description, + optimization=optimization, + avatar=avatar, + 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) diff --git a/ai21/clients/studio/resources/beta/async_beta.py b/ai21/clients/studio/resources/beta/async_beta.py index a94ddc95..521c7a13 100644 --- a/ai21/clients/studio/resources/beta/async_beta.py +++ b/ai21/clients/studio/resources/beta/async_beta.py @@ -1,3 +1,4 @@ +from ai21.clients.studio.resources.assistant.studio_assistant import AsyncStudioAssistant 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 @@ -8,3 +9,4 @@ def __init__(self, client: AsyncAI21HTTPClient): super().__init__(client) self.conversational_rag = AsyncStudioConversationalRag(client) + self.assistants = AsyncStudioAssistant(client) diff --git a/ai21/clients/studio/resources/beta/beta.py b/ai21/clients/studio/resources/beta/beta.py index 1269f970..8560597a 100644 --- a/ai21/clients/studio/resources/beta/beta.py +++ b/ai21/clients/studio/resources/beta/beta.py @@ -1,3 +1,4 @@ +from ai21.clients.studio.resources.assistant.studio_assistant import StudioAssistant 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 @@ -8,3 +9,4 @@ def __init__(self, client: AI21HTTPClient): super().__init__(client) self.conversational_rag = StudioConversationalRag(client) + self.assistants = StudioAssistant(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/models/responses/assistant_response.py b/ai21/models/responses/assistant_response.py new file mode 100644 index 00000000..dea5833d --- /dev/null +++ b/ai21/models/responses/assistant_response.py @@ -0,0 +1,21 @@ +from datetime import datetime +from typing import Optional + +from ai21.models.ai21_base_model import AI21BaseModel + + +class AssistantResponse(AI21BaseModel): + id: str + created_at: datetime + updated_at: datetime + object: str + name: str + description: Optional[str] + optimization: str + organization_id: str + user_id: str + avatar: Optional[str] = None + is_archived: bool = False + models: Optional[list[str]] = None + tools: Optional[list[str]] = None + tool_resources: Optional[dict] = None diff --git a/examples/studio/assistant/__init__.py b/examples/studio/assistant/__init__.py new file mode 100644 index 00000000..e69de29b From 3128145a85283c8f7ed0984fffee7febb32f3ae0 Mon Sep 17 00:00:00 2001 From: benshuk Date: Thu, 28 Nov 2024 10:38:48 +0200 Subject: [PATCH 09/50] fix: :bug: use `List` for typing instead of `list` --- ai21/models/responses/assistant_response.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ai21/models/responses/assistant_response.py b/ai21/models/responses/assistant_response.py index dea5833d..9863f106 100644 --- a/ai21/models/responses/assistant_response.py +++ b/ai21/models/responses/assistant_response.py @@ -1,5 +1,5 @@ from datetime import datetime -from typing import Optional +from typing import Optional, List from ai21.models.ai21_base_model import AI21BaseModel @@ -16,6 +16,6 @@ class AssistantResponse(AI21BaseModel): user_id: str avatar: Optional[str] = None is_archived: bool = False - models: Optional[list[str]] = None - tools: Optional[list[str]] = None + models: Optional[List[str]] = None + tools: Optional[List[str]] = None tool_resources: Optional[dict] = None From a03deab60a4a4be43a3211959a16c4ea132bf63f Mon Sep 17 00:00:00 2001 From: benshuk Date: Thu, 28 Nov 2024 15:33:26 +0200 Subject: [PATCH 10/50] fix: :label: better typing & remove doc string --- ai21/clients/common/assistant/assistant.py | 49 ++++----------------- ai21/models/responses/assistant_response.py | 13 +++++- 2 files changed, 21 insertions(+), 41 deletions(-) diff --git a/ai21/clients/common/assistant/assistant.py b/ai21/clients/common/assistant/assistant.py index a646a917..2a2fc135 100644 --- a/ai21/clients/common/assistant/assistant.py +++ b/ai21/clients/common/assistant/assistant.py @@ -3,7 +3,7 @@ from abc import ABC, abstractmethod from typing import Any, Dict, List -from ai21.models.responses.assistant_response import AssistantResponse +from ai21.models.responses.assistant_response import AssistantResponse, Optimization, ToolsResources, Model, Tool from ai21.types import NotGiven, NOT_GIVEN from ai21.utils.typing import remove_not_given @@ -17,24 +17,13 @@ def create( name: str, *, description: str | NotGiven = NOT_GIVEN, - optimization: str | NotGiven = NOT_GIVEN, + optimization: Optimization | NotGiven = NOT_GIVEN, avatar: str | NotGiven = NOT_GIVEN, - models: List[str] | NotGiven = NOT_GIVEN, - tools: List[str] | NotGiven = NOT_GIVEN, - tool_resources: dict | NotGiven = NOT_GIVEN, + models: List[Model] | NotGiven = NOT_GIVEN, + tools: List[Tool] | NotGiven = NOT_GIVEN, + tool_resources: ToolsResources | NotGiven = NOT_GIVEN, **kwargs, ) -> AssistantResponse: - """ - :param name: The name of the assistant. - :param description: The description of the assistant. - :param optimization: The optimization to use. - :param avatar: The avatar to use. - :param models: The models to use. - :param tools: The tools to use. - :param tool_resources: The tool resources to use. - :param kwargs: Additional keyword arguments. - :return: The response object. - """ pass def _create_body( @@ -64,17 +53,10 @@ def _create_body( @abstractmethod def list(self) -> List[AssistantResponse]: - """ - :return: The response object. - """ pass @abstractmethod def get(self, assistant_id: str) -> AssistantResponse: - """ - :param assistant_id: The ID of the assistant. - :return: The response object. - """ pass @abstractmethod @@ -84,26 +66,13 @@ def modify( *, name: str | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, - optimization: str | NotGiven = NOT_GIVEN, + optimization: Optimization | NotGiven = NOT_GIVEN, avatar: str | NotGiven = NOT_GIVEN, is_archived: bool | NotGiven = NOT_GIVEN, - models: List[str] | NotGiven = NOT_GIVEN, - tools: List[str] | NotGiven = NOT_GIVEN, - tool_resources: dict | NotGiven = NOT_GIVEN, + models: List[Model] | NotGiven = NOT_GIVEN, + tools: List[Tool] | NotGiven = NOT_GIVEN, + tool_resources: ToolsResources | NotGiven = NOT_GIVEN, ) -> AssistantResponse: - """ - :param assistant_id: The ID of the assistant. - :param name: The name of the assistant. - :param description: The description of the assistant. - :param optimization: The optimization to use. - :param avatar: The avatar to use. - :param is_archived: Whether the assistant is archived. - :param models: The models to use. - :param tools: The tools to use. - :param tool_resources: The tool resources to use. - :param kwargs: Additional keyword arguments. - :return: The response object. - """ pass def _modify_body( diff --git a/ai21/models/responses/assistant_response.py b/ai21/models/responses/assistant_response.py index 9863f106..5b0d0769 100644 --- a/ai21/models/responses/assistant_response.py +++ b/ai21/models/responses/assistant_response.py @@ -1,9 +1,20 @@ from datetime import datetime -from typing import Optional, List +from typing import Optional, List, Literal, TypedDict from ai21.models.ai21_base_model import AI21BaseModel +Optimization = Literal["cost", "latency"] +Model = Literal["jamba-1-5", "jamba-1-5-large"] +Tool = Literal["rag", "internet_research", "plan_approval"] + + +class ToolsResources(TypedDict, total=False): + rag: Optional[dict] + internet_research: Optional[dict] + plan_approval: Optional[dict] + + class AssistantResponse(AI21BaseModel): id: str created_at: datetime From dd7d71d82eda94ef2a72fdb1492015d57444bf4e Mon Sep 17 00:00:00 2001 From: benshuk Date: Thu, 28 Nov 2024 16:38:08 +0200 Subject: [PATCH 11/50] fix: :bug: pr fixes --- ai21/clients/common/assistant/assistant.py | 41 +++++------------ .../resources/assistant/studio_assistant.py | 46 ++++++++++--------- ai21/models/responses/assistant_response.py | 6 ++- 3 files changed, 42 insertions(+), 51 deletions(-) diff --git a/ai21/clients/common/assistant/assistant.py b/ai21/clients/common/assistant/assistant.py index 2a2fc135..24eb1508 100644 --- a/ai21/clients/common/assistant/assistant.py +++ b/ai21/clients/common/assistant/assistant.py @@ -3,7 +3,14 @@ from abc import ABC, abstractmethod from typing import Any, Dict, List -from ai21.models.responses.assistant_response import AssistantResponse, Optimization, ToolsResources, Model, Tool +from ai21.models.responses.assistant_response import ( + AssistantResponse, + Optimization, + ToolResources, + Model, + Tool, + ListAssistantResponse, +) from ai21.types import NotGiven, NOT_GIVEN from ai21.utils.typing import remove_not_given @@ -21,15 +28,15 @@ def create( avatar: str | NotGiven = NOT_GIVEN, models: List[Model] | NotGiven = NOT_GIVEN, tools: List[Tool] | NotGiven = NOT_GIVEN, - tool_resources: ToolsResources | NotGiven = NOT_GIVEN, + tool_resources: ToolResources | NotGiven = NOT_GIVEN, **kwargs, ) -> AssistantResponse: pass def _create_body( self, - name: str, *, + name: str, description: str | NotGiven, optimization: str | NotGiven, avatar: str | NotGiven, @@ -52,7 +59,7 @@ def _create_body( ) @abstractmethod - def list(self) -> List[AssistantResponse]: + def list(self) -> ListAssistantResponse: pass @abstractmethod @@ -71,30 +78,6 @@ def modify( is_archived: bool | NotGiven = NOT_GIVEN, models: List[Model] | NotGiven = NOT_GIVEN, tools: List[Tool] | NotGiven = NOT_GIVEN, - tool_resources: ToolsResources | NotGiven = NOT_GIVEN, + tool_resources: ToolResources | NotGiven = NOT_GIVEN, ) -> AssistantResponse: pass - - def _modify_body( - self, - name: str, - description: str | NotGiven, - optimization: str | NotGiven, - avatar: str | NotGiven, - is_archived: bool | NotGiven, - models: List[str] | NotGiven, - tools: List[str] | NotGiven, - tool_resources: dict | NotGiven, - ) -> Dict[str, Any]: - return remove_not_given( - { - "name": name, - "description": description, - "optimization": optimization, - "avatar": avatar, - "is_archived": is_archived, - "models": models, - "tools": tools, - "tool_resources": tool_resources, - } - ) diff --git a/ai21/clients/studio/resources/assistant/studio_assistant.py b/ai21/clients/studio/resources/assistant/studio_assistant.py index 0fea72a3..4c336a55 100644 --- a/ai21/clients/studio/resources/assistant/studio_assistant.py +++ b/ai21/clients/studio/resources/assistant/studio_assistant.py @@ -7,7 +7,13 @@ AsyncStudioResource, StudioResource, ) -from ai21.models.responses.assistant_response import AssistantResponse +from ai21.models.responses.assistant_response import ( + AssistantResponse, + Model, + Tool, + ToolResources, + ListAssistantResponse, +) from ai21.types import NotGiven, NOT_GIVEN @@ -19,9 +25,9 @@ def create( description: str | NotGiven = NOT_GIVEN, optimization: str | NotGiven = NOT_GIVEN, avatar: str | NotGiven = NOT_GIVEN, - models: List[str] | NotGiven = NOT_GIVEN, - tools: List[str] | NotGiven = NOT_GIVEN, - tool_resources: dict | NotGiven = NOT_GIVEN, + models: List[Model] | NotGiven = NOT_GIVEN, + tools: List[Tool] | NotGiven = NOT_GIVEN, + tool_resources: ToolResources | NotGiven = NOT_GIVEN, **kwargs, ) -> AssistantResponse: body = self._create_body( @@ -40,9 +46,8 @@ def create( def get(self, assistant_id: str) -> AssistantResponse: return self._get(path=f"/{self._module_name}/{assistant_id}", response_cls=AssistantResponse) - def list(self) -> List[AssistantResponse]: - response = self._get(path=f"/{self._module_name}") - return response["results"] + def list(self) -> ListAssistantResponse: + return self._get(path=f"/{self._module_name}", response_cls=ListAssistantResponse) def modify( self, @@ -53,11 +58,11 @@ def modify( optimization: str | NotGiven = NOT_GIVEN, avatar: str | NotGiven = NOT_GIVEN, is_archived: bool | NotGiven = NOT_GIVEN, - models: List[str] | NotGiven = NOT_GIVEN, - tools: List[str] | NotGiven = NOT_GIVEN, - tool_resources: dict | NotGiven = NOT_GIVEN, + models: List[Model] | NotGiven = NOT_GIVEN, + tools: List[Tool] | NotGiven = NOT_GIVEN, + tool_resources: ToolResources | NotGiven = NOT_GIVEN, ) -> AssistantResponse: - body = self._modify_body( + body = self._create_body( name=name, description=description, optimization=optimization, @@ -79,9 +84,9 @@ async def create( description: str | NotGiven = NOT_GIVEN, optimization: str | NotGiven = NOT_GIVEN, avatar: str | NotGiven = NOT_GIVEN, - models: List[str] | NotGiven = NOT_GIVEN, - tools: List[str] | NotGiven = NOT_GIVEN, - tool_resources: dict | NotGiven = NOT_GIVEN, + models: List[Model] | NotGiven = NOT_GIVEN, + tools: List[Tool] | NotGiven = NOT_GIVEN, + tool_resources: ToolResources | NotGiven = NOT_GIVEN, **kwargs, ) -> AssistantResponse: body = self._create_body( @@ -100,9 +105,8 @@ async def create( async def get(self, assistant_id: str) -> AssistantResponse: return await self._get(path=f"/{self._module_name}/{assistant_id}", response_cls=AssistantResponse) - async def list(self) -> List[AssistantResponse]: - response = await self._get(path=f"/{self._module_name}") - return response["results"] + async def list(self) -> ListAssistantResponse: + return await self._get(path=f"/{self._module_name}", response_cls=ListAssistantResponse) async def modify( self, @@ -113,11 +117,11 @@ async def modify( optimization: str | NotGiven = NOT_GIVEN, avatar: str | NotGiven = NOT_GIVEN, is_archived: bool | NotGiven = NOT_GIVEN, - models: List[str] | NotGiven = NOT_GIVEN, - tools: List[str] | NotGiven = NOT_GIVEN, - tool_resources: dict | NotGiven = NOT_GIVEN, + models: List[Model] | NotGiven = NOT_GIVEN, + tools: List[Tool] | NotGiven = NOT_GIVEN, + tool_resources: ToolResources | NotGiven = NOT_GIVEN, ) -> AssistantResponse: - body = self._modify_body( + body = self._create_body( name=name, description=description, optimization=optimization, diff --git a/ai21/models/responses/assistant_response.py b/ai21/models/responses/assistant_response.py index 5b0d0769..9eb2ac2e 100644 --- a/ai21/models/responses/assistant_response.py +++ b/ai21/models/responses/assistant_response.py @@ -9,7 +9,7 @@ Tool = Literal["rag", "internet_research", "plan_approval"] -class ToolsResources(TypedDict, total=False): +class ToolResources(TypedDict, total=False): rag: Optional[dict] internet_research: Optional[dict] plan_approval: Optional[dict] @@ -30,3 +30,7 @@ class AssistantResponse(AI21BaseModel): models: Optional[List[str]] = None tools: Optional[List[str]] = None tool_resources: Optional[dict] = None + + +class ListAssistantResponse(AI21BaseModel): + results: List[AssistantResponse] From 17af071f1a8d3dc7913ee7922884eedf1468f157 Mon Sep 17 00:00:00 2001 From: benshuk Date: Thu, 28 Nov 2024 16:57:28 +0200 Subject: [PATCH 12/50] fix: :label: remove `Model` Literal typing --- ai21/clients/common/assistant/assistant.py | 5 ++--- .../studio/resources/assistant/studio_assistant.py | 9 ++++----- ai21/models/responses/assistant_response.py | 3 +-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/ai21/clients/common/assistant/assistant.py b/ai21/clients/common/assistant/assistant.py index 24eb1508..c2ad588a 100644 --- a/ai21/clients/common/assistant/assistant.py +++ b/ai21/clients/common/assistant/assistant.py @@ -7,7 +7,6 @@ AssistantResponse, Optimization, ToolResources, - Model, Tool, ListAssistantResponse, ) @@ -26,7 +25,7 @@ def create( description: str | NotGiven = NOT_GIVEN, optimization: Optimization | NotGiven = NOT_GIVEN, avatar: str | NotGiven = NOT_GIVEN, - models: List[Model] | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, tools: List[Tool] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, **kwargs, @@ -76,7 +75,7 @@ def modify( optimization: Optimization | NotGiven = NOT_GIVEN, avatar: str | NotGiven = NOT_GIVEN, is_archived: bool | NotGiven = NOT_GIVEN, - models: List[Model] | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, tools: List[Tool] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, ) -> AssistantResponse: diff --git a/ai21/clients/studio/resources/assistant/studio_assistant.py b/ai21/clients/studio/resources/assistant/studio_assistant.py index 4c336a55..82014880 100644 --- a/ai21/clients/studio/resources/assistant/studio_assistant.py +++ b/ai21/clients/studio/resources/assistant/studio_assistant.py @@ -9,7 +9,6 @@ ) from ai21.models.responses.assistant_response import ( AssistantResponse, - Model, Tool, ToolResources, ListAssistantResponse, @@ -25,7 +24,7 @@ def create( description: str | NotGiven = NOT_GIVEN, optimization: str | NotGiven = NOT_GIVEN, avatar: str | NotGiven = NOT_GIVEN, - models: List[Model] | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, tools: List[Tool] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, **kwargs, @@ -58,7 +57,7 @@ def modify( optimization: str | NotGiven = NOT_GIVEN, avatar: str | NotGiven = NOT_GIVEN, is_archived: bool | NotGiven = NOT_GIVEN, - models: List[Model] | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, tools: List[Tool] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, ) -> AssistantResponse: @@ -84,7 +83,7 @@ async def create( description: str | NotGiven = NOT_GIVEN, optimization: str | NotGiven = NOT_GIVEN, avatar: str | NotGiven = NOT_GIVEN, - models: List[Model] | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, tools: List[Tool] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, **kwargs, @@ -117,7 +116,7 @@ async def modify( optimization: str | NotGiven = NOT_GIVEN, avatar: str | NotGiven = NOT_GIVEN, is_archived: bool | NotGiven = NOT_GIVEN, - models: List[Model] | NotGiven = NOT_GIVEN, + models: List[str] | NotGiven = NOT_GIVEN, tools: List[Tool] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, ) -> AssistantResponse: diff --git a/ai21/models/responses/assistant_response.py b/ai21/models/responses/assistant_response.py index 9eb2ac2e..f6a54cd7 100644 --- a/ai21/models/responses/assistant_response.py +++ b/ai21/models/responses/assistant_response.py @@ -5,7 +5,6 @@ Optimization = Literal["cost", "latency"] -Model = Literal["jamba-1-5", "jamba-1-5-large"] Tool = Literal["rag", "internet_research", "plan_approval"] @@ -21,7 +20,7 @@ class AssistantResponse(AI21BaseModel): updated_at: datetime object: str name: str - description: Optional[str] + description: Optional[str] = None optimization: str organization_id: str user_id: str From c8ee04176eeb3cf70591048a7fcf516dab99c5f4 Mon Sep 17 00:00:00 2001 From: benshuk Date: Thu, 28 Nov 2024 17:03:09 +0200 Subject: [PATCH 13/50] fix: :label: tool_resources use type --- ai21/models/responses/assistant_response.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ai21/models/responses/assistant_response.py b/ai21/models/responses/assistant_response.py index f6a54cd7..453d1c46 100644 --- a/ai21/models/responses/assistant_response.py +++ b/ai21/models/responses/assistant_response.py @@ -28,7 +28,7 @@ class AssistantResponse(AI21BaseModel): is_archived: bool = False models: Optional[List[str]] = None tools: Optional[List[str]] = None - tool_resources: Optional[dict] = None + tool_resources: Optional[ToolResources] = None class ListAssistantResponse(AI21BaseModel): From f9e695bd5e51b49ade8342cb4796cf2b1b97e630 Mon Sep 17 00:00:00 2001 From: benshuk Date: Thu, 28 Nov 2024 17:10:19 +0200 Subject: [PATCH 14/50] fix: :green_heart: imports --- ai21/models/responses/assistant_response.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ai21/models/responses/assistant_response.py b/ai21/models/responses/assistant_response.py index 453d1c46..d7b0f186 100644 --- a/ai21/models/responses/assistant_response.py +++ b/ai21/models/responses/assistant_response.py @@ -1,5 +1,7 @@ from datetime import datetime -from typing import Optional, List, Literal, TypedDict +from typing import Optional, List, Literal + +from typing_extensions import TypedDict from ai21.models.ai21_base_model import AI21BaseModel From 62566cd1fd0b42bfcd181ebb5b5032e62a15730b Mon Sep 17 00:00:00 2001 From: benshuk Date: Sun, 1 Dec 2024 13:06:54 +0200 Subject: [PATCH 15/50] feat: :sparkles: add support for Thread resource --- ai21/clients/common/assistant/thread.py | 22 ++++++++++ .../resources/assistant/studio_assistant.py | 2 +- .../resources/assistant/studio_thread.py | 35 ++++++++++++++++ .../studio/resources/beta/async_beta.py | 4 +- ai21/clients/studio/resources/beta/beta.py | 4 +- ai21/models/responses/assistant_response.py | 2 +- ai21/models/responses/thread_response.py | 41 +++++++++++++++++++ 7 files changed, 106 insertions(+), 4 deletions(-) create mode 100644 ai21/clients/common/assistant/thread.py create mode 100644 ai21/clients/studio/resources/assistant/studio_thread.py create mode 100644 ai21/models/responses/thread_response.py diff --git a/ai21/clients/common/assistant/thread.py b/ai21/clients/common/assistant/thread.py new file mode 100644 index 00000000..1a074db2 --- /dev/null +++ b/ai21/clients/common/assistant/thread.py @@ -0,0 +1,22 @@ +from __future__ import annotations + +from abc import ABC, abstractmethod +from typing import List + +from ai21.models.responses.thread_response import ThreadResponse, CreateMessagePayload + + +class Thread(ABC): + _module_name = "threads" + + @abstractmethod + def create( + self, + messages: List[CreateMessagePayload], + **kwargs, + ) -> ThreadResponse: + pass + + @abstractmethod + def get(self, thread_id: str) -> ThreadResponse: + pass diff --git a/ai21/clients/studio/resources/assistant/studio_assistant.py b/ai21/clients/studio/resources/assistant/studio_assistant.py index 82014880..2f1a67eb 100644 --- a/ai21/clients/studio/resources/assistant/studio_assistant.py +++ b/ai21/clients/studio/resources/assistant/studio_assistant.py @@ -99,7 +99,7 @@ async def create( **kwargs, ) - return self._post(path=f"/{self._module_name}", body=body, response_cls=AssistantResponse) + return await self._post(path=f"/{self._module_name}", body=body, response_cls=AssistantResponse) async def get(self, assistant_id: str) -> AssistantResponse: return await self._get(path=f"/{self._module_name}/{assistant_id}", response_cls=AssistantResponse) diff --git a/ai21/clients/studio/resources/assistant/studio_thread.py b/ai21/clients/studio/resources/assistant/studio_thread.py new file mode 100644 index 00000000..71e54a25 --- /dev/null +++ b/ai21/clients/studio/resources/assistant/studio_thread.py @@ -0,0 +1,35 @@ +from __future__ import annotations + +from typing import List + +from ai21.clients.common.assistant.thread import Thread +from ai21.clients.studio.resources.studio_resource import StudioResource, AsyncStudioResource +from ai21.models.responses.thread_response import CreateMessagePayload, ThreadResponse + + +class StudioThread(StudioResource, Thread): + def create( + self, + messages: List[CreateMessagePayload], + **kwargs, + ) -> ThreadResponse: + body = dict(messages=messages) + + return self._post(path=f"/{self._module_name}", body=body, response_cls=ThreadResponse) + + def get(self, thread_id: str) -> ThreadResponse: + return self._get(path=f"/{self._module_name}/{thread_id}", response_cls=ThreadResponse) + + +class AsyncStudioThread(AsyncStudioResource, Thread): + async def create( + self, + messages: List[CreateMessagePayload], + **kwargs, + ) -> ThreadResponse: + body = dict(messages=messages) + + return await self._post(path=f"/{self._module_name}", body=body, response_cls=ThreadResponse) + + async def get(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/async_beta.py b/ai21/clients/studio/resources/beta/async_beta.py index 521c7a13..1bb13bbe 100644 --- a/ai21/clients/studio/resources/beta/async_beta.py +++ b/ai21/clients/studio/resources/beta/async_beta.py @@ -1,4 +1,5 @@ from ai21.clients.studio.resources.assistant.studio_assistant import AsyncStudioAssistant +from ai21.clients.studio.resources.assistant.studio_thread import AsyncStudioThread 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 @@ -8,5 +9,6 @@ class AsyncBeta(AsyncStudioResource): def __init__(self, client: AsyncAI21HTTPClient): super().__init__(client) - self.conversational_rag = AsyncStudioConversationalRag(client) self.assistants = AsyncStudioAssistant(client) + self.conversational_rag = AsyncStudioConversationalRag(client) + self.threads = AsyncStudioThread(client) diff --git a/ai21/clients/studio/resources/beta/beta.py b/ai21/clients/studio/resources/beta/beta.py index 8560597a..affede10 100644 --- a/ai21/clients/studio/resources/beta/beta.py +++ b/ai21/clients/studio/resources/beta/beta.py @@ -1,4 +1,5 @@ from ai21.clients.studio.resources.assistant.studio_assistant import StudioAssistant +from ai21.clients.studio.resources.assistant.studio_thread import StudioThread 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 @@ -8,5 +9,6 @@ class Beta(StudioResource): def __init__(self, client: AI21HTTPClient): super().__init__(client) - self.conversational_rag = StudioConversationalRag(client) self.assistants = StudioAssistant(client) + self.conversational_rag = StudioConversationalRag(client) + self.threads = StudioThread(client) diff --git a/ai21/models/responses/assistant_response.py b/ai21/models/responses/assistant_response.py index d7b0f186..000b0346 100644 --- a/ai21/models/responses/assistant_response.py +++ b/ai21/models/responses/assistant_response.py @@ -20,7 +20,7 @@ class AssistantResponse(AI21BaseModel): id: str created_at: datetime updated_at: datetime - object: str + object: Literal["assistant"] = "assistant" name: str description: Optional[str] = None optimization: str diff --git a/ai21/models/responses/thread_response.py b/ai21/models/responses/thread_response.py new file mode 100644 index 00000000..662047bb --- /dev/null +++ b/ai21/models/responses/thread_response.py @@ -0,0 +1,41 @@ +from datetime import datetime +from typing import Optional, List, Literal + +from typing_extensions import TypedDict + +from ai21.models.ai21_base_model import AI21BaseModel + + +MessageRole = Literal["assistant", "user"] + + +class MessageContentText(TypedDict): + type: Literal["text"] + text: str + + +class CreateMessagePayload(TypedDict): + role: MessageRole + content: MessageContentText + + +class ThreadMessageResponse(AI21BaseModel): + id: str + created_at: datetime + updated_at: datetime + object: Literal["message"] = "message" + role: MessageRole + content: MessageContentText + run_id: Optional[str] = None + assistant_id: Optional[str] = None + + +class ThreadResponse(AI21BaseModel): + id: str + created_at: datetime + updated_at: datetime + object: Literal["thread"] = "thread" + + +class ListThreadResponse(AI21BaseModel): + results: List[ThreadResponse] From ae7a3e40dd13c3feb0b41af8bbef3ed4b2490ca9 Mon Sep 17 00:00:00 2001 From: benshuk Date: Sun, 1 Dec 2024 15:03:19 +0200 Subject: [PATCH 16/50] fix: :truck: rename classes and such --- .../assistant/{assistant.py => assistants.py} | 17 ++++---- ai21/clients/common/assistant/thread.py | 22 ---------- ai21/clients/common/assistant/threads.py | 23 ++++++++++ .../resources/assistant/studio_assistant.py | 42 +++++++++---------- .../resources/assistant/studio_thread.py | 28 ++++++------- ai21/models/assistant/__init__.py | 0 ai21/models/assistant/assistant.py | 12 ++++++ ai21/models/assistant/thread_message.py | 15 +++++++ ai21/models/responses/assistant_response.py | 19 ++------- ai21/models/responses/thread_response.py | 28 ++++--------- 10 files changed, 104 insertions(+), 102 deletions(-) rename ai21/clients/common/assistant/{assistant.py => assistants.py} (88%) delete mode 100644 ai21/clients/common/assistant/thread.py create mode 100644 ai21/clients/common/assistant/threads.py create mode 100644 ai21/models/assistant/__init__.py create mode 100644 ai21/models/assistant/assistant.py create mode 100644 ai21/models/assistant/thread_message.py diff --git a/ai21/clients/common/assistant/assistant.py b/ai21/clients/common/assistant/assistants.py similarity index 88% rename from ai21/clients/common/assistant/assistant.py rename to ai21/clients/common/assistant/assistants.py index c2ad588a..0fd08d7b 100644 --- a/ai21/clients/common/assistant/assistant.py +++ b/ai21/clients/common/assistant/assistants.py @@ -3,18 +3,17 @@ from abc import ABC, abstractmethod from typing import Any, Dict, List +from ai21.models.assistant.assistant import Optimization, Tool from ai21.models.responses.assistant_response import ( - AssistantResponse, - Optimization, + Assistant, ToolResources, - Tool, - ListAssistantResponse, + ListAssistant, ) from ai21.types import NotGiven, NOT_GIVEN from ai21.utils.typing import remove_not_given -class Assistant(ABC): +class Assistants(ABC): _module_name = "assistants" @abstractmethod @@ -29,7 +28,7 @@ def create( tools: List[Tool] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, **kwargs, - ) -> AssistantResponse: + ) -> Assistant: pass def _create_body( @@ -58,11 +57,11 @@ def _create_body( ) @abstractmethod - def list(self) -> ListAssistantResponse: + def list(self) -> ListAssistant: pass @abstractmethod - def get(self, assistant_id: str) -> AssistantResponse: + def get(self, assistant_id: str) -> Assistant: pass @abstractmethod @@ -78,5 +77,5 @@ def modify( models: List[str] | NotGiven = NOT_GIVEN, tools: List[Tool] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, - ) -> AssistantResponse: + ) -> Assistant: pass diff --git a/ai21/clients/common/assistant/thread.py b/ai21/clients/common/assistant/thread.py deleted file mode 100644 index 1a074db2..00000000 --- a/ai21/clients/common/assistant/thread.py +++ /dev/null @@ -1,22 +0,0 @@ -from __future__ import annotations - -from abc import ABC, abstractmethod -from typing import List - -from ai21.models.responses.thread_response import ThreadResponse, CreateMessagePayload - - -class Thread(ABC): - _module_name = "threads" - - @abstractmethod - def create( - self, - messages: List[CreateMessagePayload], - **kwargs, - ) -> ThreadResponse: - pass - - @abstractmethod - def get(self, thread_id: str) -> ThreadResponse: - pass diff --git a/ai21/clients/common/assistant/threads.py b/ai21/clients/common/assistant/threads.py new file mode 100644 index 00000000..f68bc82b --- /dev/null +++ b/ai21/clients/common/assistant/threads.py @@ -0,0 +1,23 @@ +from __future__ import annotations + +from abc import ABC, abstractmethod +from typing import List + +from ai21.models.assistant.thread_message import CreateThreadMessagePayload +from ai21.models.responses.thread_response import Thread + + +class Threads(ABC): + _module_name = "threads" + + @abstractmethod + def create( + self, + messages: List[CreateThreadMessagePayload], + **kwargs, + ) -> Thread: + pass + + @abstractmethod + def get(self, thread_id: str) -> Thread: + pass diff --git a/ai21/clients/studio/resources/assistant/studio_assistant.py b/ai21/clients/studio/resources/assistant/studio_assistant.py index 2f1a67eb..ec14758a 100644 --- a/ai21/clients/studio/resources/assistant/studio_assistant.py +++ b/ai21/clients/studio/resources/assistant/studio_assistant.py @@ -2,21 +2,21 @@ from typing import List -from ai21.clients.common.assistant.assistant import Assistant +from ai21.clients.common.assistant.assistants import Assistants from ai21.clients.studio.resources.studio_resource import ( AsyncStudioResource, StudioResource, ) from ai21.models.responses.assistant_response import ( - AssistantResponse, + Assistant, Tool, ToolResources, - ListAssistantResponse, + ListAssistant, ) from ai21.types import NotGiven, NOT_GIVEN -class StudioAssistant(StudioResource, Assistant): +class StudioAssistant(StudioResource, Assistants): def create( self, name: str, @@ -28,7 +28,7 @@ def create( tools: List[Tool] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, **kwargs, - ) -> AssistantResponse: + ) -> Assistant: body = self._create_body( name=name, description=description, @@ -40,13 +40,13 @@ def create( **kwargs, ) - return self._post(path=f"/{self._module_name}", body=body, response_cls=AssistantResponse) + return self._post(path=f"/{self._module_name}", body=body, response_cls=Assistant) - def get(self, assistant_id: str) -> AssistantResponse: - return self._get(path=f"/{self._module_name}/{assistant_id}", response_cls=AssistantResponse) + def get(self, assistant_id: str) -> Assistant: + return self._get(path=f"/{self._module_name}/{assistant_id}", response_cls=Assistant) - def list(self) -> ListAssistantResponse: - return self._get(path=f"/{self._module_name}", response_cls=ListAssistantResponse) + def list(self) -> ListAssistant: + return self._get(path=f"/{self._module_name}", response_cls=ListAssistant) def modify( self, @@ -60,7 +60,7 @@ def modify( models: List[str] | NotGiven = NOT_GIVEN, tools: List[Tool] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, - ) -> AssistantResponse: + ) -> Assistant: body = self._create_body( name=name, description=description, @@ -72,10 +72,10 @@ def modify( tool_resources=tool_resources, ) - return self._patch(path=f"/{self._module_name}/{assistant_id}", body=body, response_cls=AssistantResponse) + return self._patch(path=f"/{self._module_name}/{assistant_id}", body=body, response_cls=Assistant) -class AsyncStudioAssistant(AsyncStudioResource, Assistant): +class AsyncStudioAssistant(AsyncStudioResource, Assistants): async def create( self, name: str, @@ -87,7 +87,7 @@ async def create( tools: List[Tool] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, **kwargs, - ) -> AssistantResponse: + ) -> Assistant: body = self._create_body( name=name, description=description, @@ -99,13 +99,13 @@ async def create( **kwargs, ) - return await self._post(path=f"/{self._module_name}", body=body, response_cls=AssistantResponse) + return await self._post(path=f"/{self._module_name}", body=body, response_cls=Assistant) - async def get(self, assistant_id: str) -> AssistantResponse: - return await self._get(path=f"/{self._module_name}/{assistant_id}", response_cls=AssistantResponse) + async def get(self, assistant_id: str) -> Assistant: + return await self._get(path=f"/{self._module_name}/{assistant_id}", response_cls=Assistant) - async def list(self) -> ListAssistantResponse: - return await self._get(path=f"/{self._module_name}", response_cls=ListAssistantResponse) + async def list(self) -> ListAssistant: + return await self._get(path=f"/{self._module_name}", response_cls=ListAssistant) async def modify( self, @@ -119,7 +119,7 @@ async def modify( models: List[str] | NotGiven = NOT_GIVEN, tools: List[Tool] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, - ) -> AssistantResponse: + ) -> Assistant: body = self._create_body( name=name, description=description, @@ -131,4 +131,4 @@ async def modify( tool_resources=tool_resources, ) - return await self._patch(path=f"/{self._module_name}/{assistant_id}", body=body, response_cls=AssistantResponse) + return await self._patch(path=f"/{self._module_name}/{assistant_id}", body=body, response_cls=Assistant) diff --git a/ai21/clients/studio/resources/assistant/studio_thread.py b/ai21/clients/studio/resources/assistant/studio_thread.py index 71e54a25..c8aac8cf 100644 --- a/ai21/clients/studio/resources/assistant/studio_thread.py +++ b/ai21/clients/studio/resources/assistant/studio_thread.py @@ -2,34 +2,34 @@ from typing import List -from ai21.clients.common.assistant.thread import Thread +from ai21.clients.common.assistant.threads import Threads from ai21.clients.studio.resources.studio_resource import StudioResource, AsyncStudioResource -from ai21.models.responses.thread_response import CreateMessagePayload, ThreadResponse +from ai21.models.responses.thread_response import CreateThreadMessagePayload, Thread -class StudioThread(StudioResource, Thread): +class StudioThread(StudioResource, Threads): def create( self, - messages: List[CreateMessagePayload], + messages: List[CreateThreadMessagePayload], **kwargs, - ) -> ThreadResponse: + ) -> Thread: body = dict(messages=messages) - return self._post(path=f"/{self._module_name}", body=body, response_cls=ThreadResponse) + return self._post(path=f"/{self._module_name}", body=body, response_cls=Thread) - def get(self, thread_id: str) -> ThreadResponse: - return self._get(path=f"/{self._module_name}/{thread_id}", response_cls=ThreadResponse) + def get(self, thread_id: str) -> Thread: + return self._get(path=f"/{self._module_name}/{thread_id}", response_cls=Thread) -class AsyncStudioThread(AsyncStudioResource, Thread): +class AsyncStudioThread(AsyncStudioResource, Threads): async def create( self, - messages: List[CreateMessagePayload], + messages: List[CreateThreadMessagePayload], **kwargs, - ) -> ThreadResponse: + ) -> Thread: body = dict(messages=messages) - return await self._post(path=f"/{self._module_name}", body=body, response_cls=ThreadResponse) + return await self._post(path=f"/{self._module_name}", body=body, response_cls=Thread) - async def get(self, thread_id: str) -> ThreadResponse: - return await self._get(path=f"/{self._module_name}/{thread_id}", response_cls=ThreadResponse) + async def get(self, thread_id: str) -> Thread: + return await self._get(path=f"/{self._module_name}/{thread_id}", response_cls=Thread) 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..44c3ed06 --- /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["rag", "internet_research", "plan_approval"] + + +class ToolResources(TypedDict, total=False): + rag: Optional[dict] + internet_research: Optional[dict] + plan_approval: Optional[dict] diff --git a/ai21/models/assistant/thread_message.py b/ai21/models/assistant/thread_message.py new file mode 100644 index 00000000..87ef50e3 --- /dev/null +++ b/ai21/models/assistant/thread_message.py @@ -0,0 +1,15 @@ +from typing import Literal + +from typing_extensions import TypedDict + +ThreadMessageRole = Literal["assistant", "user"] + + +class ThreadMessageContentText(TypedDict): + type: Literal["text"] + text: str + + +class CreateThreadMessagePayload(TypedDict): + role: ThreadMessageRole + content: ThreadMessageContentText diff --git a/ai21/models/responses/assistant_response.py b/ai21/models/responses/assistant_response.py index 000b0346..3263b5a8 100644 --- a/ai21/models/responses/assistant_response.py +++ b/ai21/models/responses/assistant_response.py @@ -1,22 +1,11 @@ from datetime import datetime from typing import Optional, List, Literal -from typing_extensions import TypedDict - from ai21.models.ai21_base_model import AI21BaseModel +from ai21.models.assistant.assistant import ToolResources -Optimization = Literal["cost", "latency"] -Tool = Literal["rag", "internet_research", "plan_approval"] - - -class ToolResources(TypedDict, total=False): - rag: Optional[dict] - internet_research: Optional[dict] - plan_approval: Optional[dict] - - -class AssistantResponse(AI21BaseModel): +class Assistant(AI21BaseModel): id: str created_at: datetime updated_at: datetime @@ -33,5 +22,5 @@ class AssistantResponse(AI21BaseModel): tool_resources: Optional[ToolResources] = None -class ListAssistantResponse(AI21BaseModel): - results: List[AssistantResponse] +class ListAssistant(AI21BaseModel): + results: List[Assistant] diff --git a/ai21/models/responses/thread_response.py b/ai21/models/responses/thread_response.py index 662047bb..6cb06443 100644 --- a/ai21/models/responses/thread_response.py +++ b/ai21/models/responses/thread_response.py @@ -1,41 +1,27 @@ from datetime import datetime from typing import Optional, List, Literal -from typing_extensions import TypedDict - from ai21.models.ai21_base_model import AI21BaseModel +from ai21.models.assistant.thread_message import ThreadMessageRole, ThreadMessageContentText -MessageRole = Literal["assistant", "user"] - - -class MessageContentText(TypedDict): - type: Literal["text"] - text: str - - -class CreateMessagePayload(TypedDict): - role: MessageRole - content: MessageContentText - - -class ThreadMessageResponse(AI21BaseModel): +class ThreadMessage(AI21BaseModel): id: str created_at: datetime updated_at: datetime object: Literal["message"] = "message" - role: MessageRole - content: MessageContentText + role: ThreadMessageRole + content: ThreadMessageContentText run_id: Optional[str] = None assistant_id: Optional[str] = None -class ThreadResponse(AI21BaseModel): +class Thread(AI21BaseModel): id: str created_at: datetime updated_at: datetime object: Literal["thread"] = "thread" -class ListThreadResponse(AI21BaseModel): - results: List[ThreadResponse] +class ListThread(AI21BaseModel): + results: List[Thread] From c944172571e10452b93542944794e6bcaeaff2c7 Mon Sep 17 00:00:00 2001 From: benshuk Date: Sun, 1 Dec 2024 16:04:01 +0200 Subject: [PATCH 17/50] fix: :truck: move classes and such --- ai21/clients/common/assistant/assistants.py | 8 ++--- ai21/clients/common/assistant/threads.py | 8 ++--- .../resources/assistant/studio_assistant.py | 8 ++--- .../resources/assistant/studio_thread.py | 15 +++------- ai21/models/assistant/message.py | 29 +++++++++++++++++++ ai21/models/assistant/thread_message.py | 15 ---------- ai21/models/responses/thread_response.py | 14 +-------- 7 files changed, 40 insertions(+), 57 deletions(-) create mode 100644 ai21/models/assistant/message.py delete mode 100644 ai21/models/assistant/thread_message.py diff --git a/ai21/clients/common/assistant/assistants.py b/ai21/clients/common/assistant/assistants.py index 0fd08d7b..e773f89a 100644 --- a/ai21/clients/common/assistant/assistants.py +++ b/ai21/clients/common/assistant/assistants.py @@ -3,12 +3,8 @@ from abc import ABC, abstractmethod from typing import Any, Dict, List -from ai21.models.assistant.assistant import Optimization, Tool -from ai21.models.responses.assistant_response import ( - Assistant, - ToolResources, - ListAssistant, -) +from ai21.models.assistant.assistant import Optimization, Tool, ToolResources +from ai21.models.responses.assistant_response import Assistant, ListAssistant from ai21.types import NotGiven, NOT_GIVEN from ai21.utils.typing import remove_not_given diff --git a/ai21/clients/common/assistant/threads.py b/ai21/clients/common/assistant/threads.py index f68bc82b..5025ccc2 100644 --- a/ai21/clients/common/assistant/threads.py +++ b/ai21/clients/common/assistant/threads.py @@ -3,7 +3,7 @@ from abc import ABC, abstractmethod from typing import List -from ai21.models.assistant.thread_message import CreateThreadMessagePayload +from ai21.models.assistant.message import Message from ai21.models.responses.thread_response import Thread @@ -11,11 +11,7 @@ class Threads(ABC): _module_name = "threads" @abstractmethod - def create( - self, - messages: List[CreateThreadMessagePayload], - **kwargs, - ) -> Thread: + def create(self, messages: List[Message], **kwargs) -> Thread: pass @abstractmethod diff --git a/ai21/clients/studio/resources/assistant/studio_assistant.py b/ai21/clients/studio/resources/assistant/studio_assistant.py index ec14758a..fa008695 100644 --- a/ai21/clients/studio/resources/assistant/studio_assistant.py +++ b/ai21/clients/studio/resources/assistant/studio_assistant.py @@ -7,12 +7,8 @@ AsyncStudioResource, StudioResource, ) -from ai21.models.responses.assistant_response import ( - Assistant, - Tool, - ToolResources, - ListAssistant, -) +from ai21.models.assistant.assistant import Tool, ToolResources +from ai21.models.responses.assistant_response import Assistant, ListAssistant from ai21.types import NotGiven, NOT_GIVEN diff --git a/ai21/clients/studio/resources/assistant/studio_thread.py b/ai21/clients/studio/resources/assistant/studio_thread.py index c8aac8cf..fd48563e 100644 --- a/ai21/clients/studio/resources/assistant/studio_thread.py +++ b/ai21/clients/studio/resources/assistant/studio_thread.py @@ -4,15 +4,12 @@ from ai21.clients.common.assistant.threads import Threads from ai21.clients.studio.resources.studio_resource import StudioResource, AsyncStudioResource -from ai21.models.responses.thread_response import CreateThreadMessagePayload, Thread +from ai21.models.assistant.message import Message +from ai21.models.responses.thread_response import Thread class StudioThread(StudioResource, Threads): - def create( - self, - messages: List[CreateThreadMessagePayload], - **kwargs, - ) -> Thread: + def create(self, messages: List[Message], **kwargs) -> Thread: body = dict(messages=messages) return self._post(path=f"/{self._module_name}", body=body, response_cls=Thread) @@ -22,11 +19,7 @@ def get(self, thread_id: str) -> Thread: class AsyncStudioThread(AsyncStudioResource, Threads): - async def create( - self, - messages: List[CreateThreadMessagePayload], - **kwargs, - ) -> Thread: + async def create(self, messages: List[Message], **kwargs) -> Thread: body = dict(messages=messages) return await self._post(path=f"/{self._module_name}", body=body, response_cls=Thread) diff --git a/ai21/models/assistant/message.py b/ai21/models/assistant/message.py new file mode 100644 index 00000000..f3ec7d8d --- /dev/null +++ b/ai21/models/assistant/message.py @@ -0,0 +1,29 @@ +from datetime import datetime +from typing import Literal, Optional + +from typing_extensions import TypedDict + +from ai21.models.ai21_base_model import AI21BaseModel + +ThreadMessageRole = Literal["assistant", "user"] + + +class MessageContentText(TypedDict): + type: Literal["text"] + text: str + + +class Message(TypedDict): + role: ThreadMessageRole + content: MessageContentText + + +class MessageResponse(AI21BaseModel): + id: str + created_at: datetime + updated_at: datetime + object: Literal["message"] = "message" + role: ThreadMessageRole + content: MessageContentText + run_id: Optional[str] = None + assistant_id: Optional[str] = None diff --git a/ai21/models/assistant/thread_message.py b/ai21/models/assistant/thread_message.py deleted file mode 100644 index 87ef50e3..00000000 --- a/ai21/models/assistant/thread_message.py +++ /dev/null @@ -1,15 +0,0 @@ -from typing import Literal - -from typing_extensions import TypedDict - -ThreadMessageRole = Literal["assistant", "user"] - - -class ThreadMessageContentText(TypedDict): - type: Literal["text"] - text: str - - -class CreateThreadMessagePayload(TypedDict): - role: ThreadMessageRole - content: ThreadMessageContentText diff --git a/ai21/models/responses/thread_response.py b/ai21/models/responses/thread_response.py index 6cb06443..b2c9bbc7 100644 --- a/ai21/models/responses/thread_response.py +++ b/ai21/models/responses/thread_response.py @@ -1,19 +1,7 @@ from datetime import datetime -from typing import Optional, List, Literal +from typing import List, Literal from ai21.models.ai21_base_model import AI21BaseModel -from ai21.models.assistant.thread_message import ThreadMessageRole, ThreadMessageContentText - - -class ThreadMessage(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 Thread(AI21BaseModel): From d2747a56169c8c68cd9701291fab72509835f830 Mon Sep 17 00:00:00 2001 From: benshuk Date: Mon, 2 Dec 2024 11:49:36 +0200 Subject: [PATCH 18/50] fix: :truck: rename `get` method to `retrieve` --- ai21/clients/common/assistant/assistants.py | 2 +- ai21/clients/common/assistant/threads.py | 2 +- ai21/clients/studio/resources/assistant/studio_assistant.py | 4 ++-- ai21/clients/studio/resources/assistant/studio_thread.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ai21/clients/common/assistant/assistants.py b/ai21/clients/common/assistant/assistants.py index e773f89a..1beb2b7f 100644 --- a/ai21/clients/common/assistant/assistants.py +++ b/ai21/clients/common/assistant/assistants.py @@ -57,7 +57,7 @@ def list(self) -> ListAssistant: pass @abstractmethod - def get(self, assistant_id: str) -> Assistant: + def retrieve(self, assistant_id: str) -> Assistant: pass @abstractmethod diff --git a/ai21/clients/common/assistant/threads.py b/ai21/clients/common/assistant/threads.py index 5025ccc2..d24ead91 100644 --- a/ai21/clients/common/assistant/threads.py +++ b/ai21/clients/common/assistant/threads.py @@ -15,5 +15,5 @@ def create(self, messages: List[Message], **kwargs) -> Thread: pass @abstractmethod - def get(self, thread_id: str) -> Thread: + def retrieve(self, thread_id: str) -> Thread: pass diff --git a/ai21/clients/studio/resources/assistant/studio_assistant.py b/ai21/clients/studio/resources/assistant/studio_assistant.py index fa008695..f2a3c306 100644 --- a/ai21/clients/studio/resources/assistant/studio_assistant.py +++ b/ai21/clients/studio/resources/assistant/studio_assistant.py @@ -38,7 +38,7 @@ def create( return self._post(path=f"/{self._module_name}", body=body, response_cls=Assistant) - def get(self, assistant_id: str) -> Assistant: + def retrieve(self, assistant_id: str) -> Assistant: return self._get(path=f"/{self._module_name}/{assistant_id}", response_cls=Assistant) def list(self) -> ListAssistant: @@ -97,7 +97,7 @@ async def create( return await self._post(path=f"/{self._module_name}", body=body, response_cls=Assistant) - async def get(self, assistant_id: str) -> Assistant: + async def retrieve(self, assistant_id: str) -> Assistant: return await self._get(path=f"/{self._module_name}/{assistant_id}", response_cls=Assistant) async def list(self) -> ListAssistant: diff --git a/ai21/clients/studio/resources/assistant/studio_thread.py b/ai21/clients/studio/resources/assistant/studio_thread.py index fd48563e..2ecd7199 100644 --- a/ai21/clients/studio/resources/assistant/studio_thread.py +++ b/ai21/clients/studio/resources/assistant/studio_thread.py @@ -14,7 +14,7 @@ def create(self, messages: List[Message], **kwargs) -> Thread: return self._post(path=f"/{self._module_name}", body=body, response_cls=Thread) - def get(self, thread_id: str) -> Thread: + def retrieve(self, thread_id: str) -> Thread: return self._get(path=f"/{self._module_name}/{thread_id}", response_cls=Thread) @@ -24,5 +24,5 @@ async def create(self, messages: List[Message], **kwargs) -> Thread: return await self._post(path=f"/{self._module_name}", body=body, response_cls=Thread) - async def get(self, thread_id: str) -> Thread: + async def retrieve(self, thread_id: str) -> Thread: return await self._get(path=f"/{self._module_name}/{thread_id}", response_cls=Thread) From 151f5acfa2d83fccb8b9bc459fce761324542ce5 Mon Sep 17 00:00:00 2001 From: benshuk Date: Mon, 2 Dec 2024 11:50:53 +0200 Subject: [PATCH 19/50] refactor: :truck: move `MessageResponse` type to a separate file --- ai21/models/assistant/message.py | 16 +--------------- ai21/models/responses/message_response.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 15 deletions(-) create mode 100644 ai21/models/responses/message_response.py diff --git a/ai21/models/assistant/message.py b/ai21/models/assistant/message.py index f3ec7d8d..22ea77a2 100644 --- a/ai21/models/assistant/message.py +++ b/ai21/models/assistant/message.py @@ -1,10 +1,7 @@ -from datetime import datetime -from typing import Literal, Optional +from typing import Literal from typing_extensions import TypedDict -from ai21.models.ai21_base_model import AI21BaseModel - ThreadMessageRole = Literal["assistant", "user"] @@ -16,14 +13,3 @@ class MessageContentText(TypedDict): class Message(TypedDict): role: ThreadMessageRole content: MessageContentText - - -class MessageResponse(AI21BaseModel): - id: str - created_at: datetime - updated_at: datetime - object: Literal["message"] = "message" - role: ThreadMessageRole - content: MessageContentText - run_id: Optional[str] = None - assistant_id: Optional[str] = None diff --git a/ai21/models/responses/message_response.py b/ai21/models/responses/message_response.py new file mode 100644 index 00000000..e19fa665 --- /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, MessageContentText + + +class MessageResponse(AI21BaseModel): + id: str + created_at: datetime + updated_at: datetime + object: Literal["message"] = "message" + role: ThreadMessageRole + content: MessageContentText + run_id: Optional[str] = None + assistant_id: Optional[str] = None + + +class ListMessageResponse(AI21BaseModel): + results: List[MessageResponse] From b483e704743a2d9e8fbd5da99f97bf348263a4d5 Mon Sep 17 00:00:00 2001 From: benshuk Date: Mon, 2 Dec 2024 13:45:14 +0200 Subject: [PATCH 20/50] feat: :sparkles: add support for Message resource --- ai21/clients/common/assistant/messages.py | 20 ++++++++++ ai21/clients/common/assistant/threads.py | 2 + .../resources/assistant/studio_thread.py | 13 +++++++ .../assistant/studio_thread_message.py | 38 +++++++++++++++++++ 4 files changed, 73 insertions(+) create mode 100644 ai21/clients/common/assistant/messages.py create mode 100644 ai21/clients/studio/resources/assistant/studio_thread_message.py diff --git a/ai21/clients/common/assistant/messages.py b/ai21/clients/common/assistant/messages.py new file mode 100644 index 00000000..6200ca76 --- /dev/null +++ b/ai21/clients/common/assistant/messages.py @@ -0,0 +1,20 @@ +from __future__ import annotations + +from abc import ABC, abstractmethod + +from ai21.models.assistant.message import ThreadMessageRole, MessageContentText +from ai21.models.responses.message_response import MessageResponse, ListMessageResponse + + +class Messages(ABC): + _module_name = "messages" + + @abstractmethod + def create( + self, thread_id: str, *, role: ThreadMessageRole, content: MessageContentText, **kwargs + ) -> MessageResponse: + pass + + @abstractmethod + def list(self, thread_id: str) -> ListMessageResponse: + pass diff --git a/ai21/clients/common/assistant/threads.py b/ai21/clients/common/assistant/threads.py index d24ead91..89b44965 100644 --- a/ai21/clients/common/assistant/threads.py +++ b/ai21/clients/common/assistant/threads.py @@ -3,12 +3,14 @@ from abc import ABC, abstractmethod from typing import List +from ai21.clients.common.assistant.messages import Messages from ai21.models.assistant.message import Message from ai21.models.responses.thread_response import Thread class Threads(ABC): _module_name = "threads" + messages: Messages @abstractmethod def create(self, messages: List[Message], **kwargs) -> Thread: diff --git a/ai21/clients/studio/resources/assistant/studio_thread.py b/ai21/clients/studio/resources/assistant/studio_thread.py index 2ecd7199..4c41249c 100644 --- a/ai21/clients/studio/resources/assistant/studio_thread.py +++ b/ai21/clients/studio/resources/assistant/studio_thread.py @@ -3,12 +3,20 @@ from typing import List from ai21.clients.common.assistant.threads import Threads +from ai21.clients.studio.resources.assistant.studio_thread_message import StudioThreadMessage, AsyncStudioThreadMessage 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 Thread class StudioThread(StudioResource, Threads): + def __init__(self, client: AI21HTTPClient): + super().__init__(client) + + self.messages = StudioThreadMessage(client) + def create(self, messages: List[Message], **kwargs) -> Thread: body = dict(messages=messages) @@ -19,6 +27,11 @@ def retrieve(self, thread_id: str) -> Thread: class AsyncStudioThread(AsyncStudioResource, Threads): + def __init__(self, client: AsyncAI21HTTPClient): + super().__init__(client) + + self.messages = AsyncStudioThreadMessage(client) + async def create(self, messages: List[Message], **kwargs) -> Thread: body = dict(messages=messages) diff --git a/ai21/clients/studio/resources/assistant/studio_thread_message.py b/ai21/clients/studio/resources/assistant/studio_thread_message.py new file mode 100644 index 00000000..ce94c966 --- /dev/null +++ b/ai21/clients/studio/resources/assistant/studio_thread_message.py @@ -0,0 +1,38 @@ +from __future__ import annotations + +from ai21.clients.common.assistant.messages import Messages +from ai21.clients.studio.resources.studio_resource import StudioResource, AsyncStudioResource +from ai21.models.assistant.message import ThreadMessageRole, MessageContentText +from ai21.models.responses.message_response import MessageResponse, ListMessageResponse + + +class StudioThreadMessage(StudioResource, Messages): + def create( + self, thread_id: str, *, role: ThreadMessageRole, content: MessageContentText, **kwargs + ) -> MessageResponse: + body = dict( + 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 AsyncStudioThreadMessage(AsyncStudioResource, Messages): + async def create( + self, thread_id: str, *, role: ThreadMessageRole, content: MessageContentText, **kwargs + ) -> MessageResponse: + body = dict( + 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) From a8c345e81f2b29dd14e5ec118d5f4068792198df Mon Sep 17 00:00:00 2001 From: benshuk Date: Mon, 2 Dec 2024 15:00:10 +0200 Subject: [PATCH 21/50] refactor: :art: reformat functions with 2+ arguments --- ai21/clients/common/assistant/messages.py | 7 ++++++- ai21/clients/common/assistant/threads.py | 6 +++++- .../studio/resources/assistant/studio_thread.py | 12 ++++++++++-- .../resources/assistant/studio_thread_message.py | 14 ++++++++++++-- 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/ai21/clients/common/assistant/messages.py b/ai21/clients/common/assistant/messages.py index 6200ca76..0ccbde79 100644 --- a/ai21/clients/common/assistant/messages.py +++ b/ai21/clients/common/assistant/messages.py @@ -11,7 +11,12 @@ class Messages(ABC): @abstractmethod def create( - self, thread_id: str, *, role: ThreadMessageRole, content: MessageContentText, **kwargs + self, + thread_id: str, + *, + role: ThreadMessageRole, + content: MessageContentText, + **kwargs, ) -> MessageResponse: pass diff --git a/ai21/clients/common/assistant/threads.py b/ai21/clients/common/assistant/threads.py index 89b44965..9b64580d 100644 --- a/ai21/clients/common/assistant/threads.py +++ b/ai21/clients/common/assistant/threads.py @@ -13,7 +13,11 @@ class Threads(ABC): messages: Messages @abstractmethod - def create(self, messages: List[Message], **kwargs) -> Thread: + def create( + self, + messages: List[Message], + **kwargs, + ) -> Thread: pass @abstractmethod diff --git a/ai21/clients/studio/resources/assistant/studio_thread.py b/ai21/clients/studio/resources/assistant/studio_thread.py index 4c41249c..60c88e22 100644 --- a/ai21/clients/studio/resources/assistant/studio_thread.py +++ b/ai21/clients/studio/resources/assistant/studio_thread.py @@ -17,7 +17,11 @@ def __init__(self, client: AI21HTTPClient): self.messages = StudioThreadMessage(client) - def create(self, messages: List[Message], **kwargs) -> Thread: + def create( + self, + messages: List[Message], + **kwargs, + ) -> Thread: body = dict(messages=messages) return self._post(path=f"/{self._module_name}", body=body, response_cls=Thread) @@ -32,7 +36,11 @@ def __init__(self, client: AsyncAI21HTTPClient): self.messages = AsyncStudioThreadMessage(client) - async def create(self, messages: List[Message], **kwargs) -> Thread: + async def create( + self, + messages: List[Message], + **kwargs, + ) -> Thread: body = dict(messages=messages) return await self._post(path=f"/{self._module_name}", body=body, response_cls=Thread) diff --git a/ai21/clients/studio/resources/assistant/studio_thread_message.py b/ai21/clients/studio/resources/assistant/studio_thread_message.py index ce94c966..95cb1b47 100644 --- a/ai21/clients/studio/resources/assistant/studio_thread_message.py +++ b/ai21/clients/studio/resources/assistant/studio_thread_message.py @@ -8,7 +8,12 @@ class StudioThreadMessage(StudioResource, Messages): def create( - self, thread_id: str, *, role: ThreadMessageRole, content: MessageContentText, **kwargs + self, + thread_id: str, + *, + role: ThreadMessageRole, + content: MessageContentText, + **kwargs, ) -> MessageResponse: body = dict( role=role, @@ -23,7 +28,12 @@ def list(self, thread_id: str) -> ListMessageResponse: class AsyncStudioThreadMessage(AsyncStudioResource, Messages): async def create( - self, thread_id: str, *, role: ThreadMessageRole, content: MessageContentText, **kwargs + self, + thread_id: str, + *, + role: ThreadMessageRole, + content: MessageContentText, + **kwargs, ) -> MessageResponse: body = dict( role=role, From d4beb227242d6e2055f1279b6ba9f453a5c0233b Mon Sep 17 00:00:00 2001 From: Ben <23212294+benshuk@users.noreply.github.com> Date: Wed, 4 Dec 2024 10:55:37 +0200 Subject: [PATCH 22/50] =?UTF-8?q?feat:=20=E2=9C=A8=20add=20support=20for?= =?UTF-8?q?=20Run=20resource=20(#236)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- README.md | 36 ++++++ .../common/{assistant => beta}/__init__.py | 0 .../beta}/assistant/__init__.py | 0 .../common/{ => beta}/assistant/assistants.py | 12 +- .../common/{ => beta}/assistant/messages.py | 0 ai21/clients/common/beta/assistant/runs.py | 67 +++++++++++ .../common/{ => beta}/assistant/threads.py | 8 +- .../resources/beta/assistant/__init__.py | 0 .../assistant/assistant.py} | 40 +++---- .../assistant/thread.py} | 33 +++--- .../assistant/thread_message.py} | 6 +- .../resources/beta/assistant/thread_run.py | 104 ++++++++++++++++++ .../studio/resources/beta/async_beta.py | 8 +- ai21/clients/studio/resources/beta/beta.py | 8 +- ai21/models/assistant/run.py | 41 +++++++ ai21/models/responses/assistant_response.py | 4 +- ai21/models/responses/run_response.py | 19 ++++ ai21/models/responses/thread_response.py | 4 +- examples/studio/assistant/assistant.py | 47 ++++++++ examples/studio/assistant/async_assistant.py | 49 +++++++++ .../integration_tests/clients/test_studio.py | 4 + 21 files changed, 424 insertions(+), 66 deletions(-) rename ai21/clients/common/{assistant => beta}/__init__.py (100%) rename ai21/clients/{studio/resources => common/beta}/assistant/__init__.py (100%) rename ai21/clients/common/{ => beta}/assistant/assistants.py (85%) rename ai21/clients/common/{ => beta}/assistant/messages.py (100%) create mode 100644 ai21/clients/common/beta/assistant/runs.py rename ai21/clients/common/{ => beta}/assistant/threads.py (63%) create mode 100644 ai21/clients/studio/resources/beta/assistant/__init__.py rename ai21/clients/studio/resources/{assistant/studio_assistant.py => beta/assistant/assistant.py} (78%) rename ai21/clients/studio/resources/{assistant/studio_thread.py => beta/assistant/thread.py} (52%) rename ai21/clients/studio/resources/{assistant/studio_thread_message.py => beta/assistant/thread_message.py} (89%) create mode 100644 ai21/clients/studio/resources/beta/assistant/thread_run.py create mode 100644 ai21/models/assistant/run.py create mode 100644 ai21/models/responses/run_response.py create mode 100644 examples/studio/assistant/assistant.py create mode 100644 examples/studio/assistant/async_assistant.py 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/assistant/__init__.py b/ai21/clients/common/beta/__init__.py similarity index 100% rename from ai21/clients/common/assistant/__init__.py rename to ai21/clients/common/beta/__init__.py diff --git a/ai21/clients/studio/resources/assistant/__init__.py b/ai21/clients/common/beta/assistant/__init__.py similarity index 100% rename from ai21/clients/studio/resources/assistant/__init__.py rename to ai21/clients/common/beta/assistant/__init__.py diff --git a/ai21/clients/common/assistant/assistants.py b/ai21/clients/common/beta/assistant/assistants.py similarity index 85% rename from ai21/clients/common/assistant/assistants.py rename to ai21/clients/common/beta/assistant/assistants.py index 1beb2b7f..65bbabf2 100644 --- a/ai21/clients/common/assistant/assistants.py +++ b/ai21/clients/common/beta/assistant/assistants.py @@ -4,7 +4,7 @@ from typing import Any, Dict, List from ai21.models.assistant.assistant import Optimization, Tool, ToolResources -from ai21.models.responses.assistant_response import Assistant, ListAssistant +from ai21.models.responses.assistant_response import AssistantResponse, ListAssistant from ai21.types import NotGiven, NOT_GIVEN from ai21.utils.typing import remove_not_given @@ -19,12 +19,11 @@ def create( *, description: str | NotGiven = NOT_GIVEN, optimization: Optimization | NotGiven = NOT_GIVEN, - avatar: str | NotGiven = NOT_GIVEN, models: List[str] | NotGiven = NOT_GIVEN, tools: List[Tool] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, **kwargs, - ) -> Assistant: + ) -> AssistantResponse: pass def _create_body( @@ -33,7 +32,6 @@ def _create_body( name: str, description: str | NotGiven, optimization: str | NotGiven, - avatar: str | NotGiven, models: List[str] | NotGiven, tools: List[str] | NotGiven, tool_resources: dict | NotGiven, @@ -44,7 +42,6 @@ def _create_body( "name": name, "description": description, "optimization": optimization, - "avatar": avatar, "models": models, "tools": tools, "tool_resources": tool_resources, @@ -57,7 +54,7 @@ def list(self) -> ListAssistant: pass @abstractmethod - def retrieve(self, assistant_id: str) -> Assistant: + def retrieve(self, assistant_id: str) -> AssistantResponse: pass @abstractmethod @@ -68,10 +65,9 @@ def modify( name: str | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, optimization: Optimization | NotGiven = NOT_GIVEN, - avatar: str | NotGiven = NOT_GIVEN, is_archived: bool | NotGiven = NOT_GIVEN, models: List[str] | NotGiven = NOT_GIVEN, tools: List[Tool] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, - ) -> Assistant: + ) -> AssistantResponse: pass diff --git a/ai21/clients/common/assistant/messages.py b/ai21/clients/common/beta/assistant/messages.py similarity index 100% rename from ai21/clients/common/assistant/messages.py rename to ai21/clients/common/beta/assistant/messages.py diff --git a/ai21/clients/common/beta/assistant/runs.py b/ai21/clients/common/beta/assistant/runs.py new file mode 100644 index 00000000..656bf26e --- /dev/null +++ b/ai21/clients/common/beta/assistant/runs.py @@ -0,0 +1,67 @@ +from __future__ import annotations + +from abc import ABC, abstractmethod +from typing import 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 Runs(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 diff --git a/ai21/clients/common/assistant/threads.py b/ai21/clients/common/beta/assistant/threads.py similarity index 63% rename from ai21/clients/common/assistant/threads.py rename to ai21/clients/common/beta/assistant/threads.py index 9b64580d..75674fc9 100644 --- a/ai21/clients/common/assistant/threads.py +++ b/ai21/clients/common/beta/assistant/threads.py @@ -3,9 +3,9 @@ from abc import ABC, abstractmethod from typing import List -from ai21.clients.common.assistant.messages import Messages +from ai21.clients.common.beta.assistant.messages import Messages from ai21.models.assistant.message import Message -from ai21.models.responses.thread_response import Thread +from ai21.models.responses.thread_response import ThreadResponse class Threads(ABC): @@ -17,9 +17,9 @@ def create( self, messages: List[Message], **kwargs, - ) -> Thread: + ) -> ThreadResponse: pass @abstractmethod - def retrieve(self, thread_id: str) -> Thread: + 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/assistant/studio_assistant.py b/ai21/clients/studio/resources/beta/assistant/assistant.py similarity index 78% rename from ai21/clients/studio/resources/assistant/studio_assistant.py rename to ai21/clients/studio/resources/beta/assistant/assistant.py index f2a3c306..7b49a4c6 100644 --- a/ai21/clients/studio/resources/assistant/studio_assistant.py +++ b/ai21/clients/studio/resources/beta/assistant/assistant.py @@ -2,44 +2,42 @@ from typing import List -from ai21.clients.common.assistant.assistants import Assistants +from ai21.clients.common.beta.assistant.assistants import Assistants from ai21.clients.studio.resources.studio_resource import ( AsyncStudioResource, StudioResource, ) from ai21.models.assistant.assistant import Tool, ToolResources -from ai21.models.responses.assistant_response import Assistant, ListAssistant +from ai21.models.responses.assistant_response import AssistantResponse, ListAssistant from ai21.types import NotGiven, NOT_GIVEN -class StudioAssistant(StudioResource, Assistants): +class Assistant(StudioResource, Assistants): def create( self, name: str, *, description: str | NotGiven = NOT_GIVEN, optimization: str | NotGiven = NOT_GIVEN, - avatar: str | NotGiven = NOT_GIVEN, models: List[str] | NotGiven = NOT_GIVEN, tools: List[Tool] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, **kwargs, - ) -> Assistant: + ) -> AssistantResponse: body = self._create_body( name=name, description=description, optimization=optimization, - avatar=avatar, models=models, tools=tools, tool_resources=tool_resources, **kwargs, ) - return self._post(path=f"/{self._module_name}", body=body, response_cls=Assistant) + return self._post(path=f"/{self._module_name}", body=body, response_cls=AssistantResponse) - def retrieve(self, assistant_id: str) -> Assistant: - return self._get(path=f"/{self._module_name}/{assistant_id}", response_cls=Assistant) + 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) @@ -51,54 +49,50 @@ def modify( name: str | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, optimization: str | NotGiven = NOT_GIVEN, - avatar: str | NotGiven = NOT_GIVEN, is_archived: bool | NotGiven = NOT_GIVEN, models: List[str] | NotGiven = NOT_GIVEN, tools: List[Tool] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, - ) -> Assistant: + ) -> AssistantResponse: body = self._create_body( name=name, description=description, optimization=optimization, - avatar=avatar, 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=Assistant) + return self._patch(path=f"/{self._module_name}/{assistant_id}", body=body, response_cls=AssistantResponse) -class AsyncStudioAssistant(AsyncStudioResource, Assistants): +class AsyncAssistant(AsyncStudioResource, Assistants): async def create( self, name: str, *, description: str | NotGiven = NOT_GIVEN, optimization: str | NotGiven = NOT_GIVEN, - avatar: str | NotGiven = NOT_GIVEN, models: List[str] | NotGiven = NOT_GIVEN, tools: List[Tool] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, **kwargs, - ) -> Assistant: + ) -> AssistantResponse: body = self._create_body( name=name, description=description, optimization=optimization, - avatar=avatar, models=models, tools=tools, tool_resources=tool_resources, **kwargs, ) - return await self._post(path=f"/{self._module_name}", body=body, response_cls=Assistant) + return await self._post(path=f"/{self._module_name}", body=body, response_cls=AssistantResponse) - async def retrieve(self, assistant_id: str) -> Assistant: - return await self._get(path=f"/{self._module_name}/{assistant_id}", response_cls=Assistant) + 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) @@ -110,21 +104,19 @@ async def modify( name: str | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, optimization: str | NotGiven = NOT_GIVEN, - avatar: str | NotGiven = NOT_GIVEN, is_archived: bool | NotGiven = NOT_GIVEN, models: List[str] | NotGiven = NOT_GIVEN, tools: List[Tool] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, - ) -> Assistant: + ) -> AssistantResponse: body = self._create_body( name=name, description=description, optimization=optimization, - avatar=avatar, 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=Assistant) + return await self._patch(path=f"/{self._module_name}/{assistant_id}", body=body, response_cls=AssistantResponse) diff --git a/ai21/clients/studio/resources/assistant/studio_thread.py b/ai21/clients/studio/resources/beta/assistant/thread.py similarity index 52% rename from ai21/clients/studio/resources/assistant/studio_thread.py rename to ai21/clients/studio/resources/beta/assistant/thread.py index 60c88e22..b2fdf57b 100644 --- a/ai21/clients/studio/resources/assistant/studio_thread.py +++ b/ai21/clients/studio/resources/beta/assistant/thread.py @@ -2,48 +2,51 @@ from typing import List -from ai21.clients.common.assistant.threads import Threads -from ai21.clients.studio.resources.assistant.studio_thread_message import StudioThreadMessage, AsyncStudioThreadMessage +from ai21.clients.common.beta.assistant.threads import Threads +from ai21.clients.studio.resources.beta.assistant.thread_message import ThreadMessage, AsyncThreadMessage +from ai21.clients.studio.resources.beta.assistant.thread_run import AsyncThreadRun, ThreadRun 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 Thread +from ai21.models.responses.thread_response import ThreadResponse -class StudioThread(StudioResource, Threads): +class Thread(StudioResource, Threads): def __init__(self, client: AI21HTTPClient): super().__init__(client) - self.messages = StudioThreadMessage(client) + self.messages = ThreadMessage(client) + self.runs = ThreadRun(client) def create( self, messages: List[Message], **kwargs, - ) -> Thread: + ) -> ThreadResponse: body = dict(messages=messages) - return self._post(path=f"/{self._module_name}", body=body, response_cls=Thread) + return self._post(path=f"/{self._module_name}", body=body, response_cls=ThreadResponse) - def retrieve(self, thread_id: str) -> Thread: - return self._get(path=f"/{self._module_name}/{thread_id}", response_cls=Thread) + def retrieve(self, thread_id: str) -> ThreadResponse: + return self._get(path=f"/{self._module_name}/{thread_id}", response_cls=ThreadResponse) -class AsyncStudioThread(AsyncStudioResource, Threads): +class AsyncThread(AsyncStudioResource, Threads): def __init__(self, client: AsyncAI21HTTPClient): super().__init__(client) - self.messages = AsyncStudioThreadMessage(client) + self.messages = AsyncThreadMessage(client) + self.runs = AsyncThreadRun(client) async def create( self, messages: List[Message], **kwargs, - ) -> Thread: + ) -> ThreadResponse: body = dict(messages=messages) - return await self._post(path=f"/{self._module_name}", body=body, response_cls=Thread) + return await self._post(path=f"/{self._module_name}", body=body, response_cls=ThreadResponse) - async def retrieve(self, thread_id: str) -> Thread: - return await self._get(path=f"/{self._module_name}/{thread_id}", response_cls=Thread) + 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/assistant/studio_thread_message.py b/ai21/clients/studio/resources/beta/assistant/thread_message.py similarity index 89% rename from ai21/clients/studio/resources/assistant/studio_thread_message.py rename to ai21/clients/studio/resources/beta/assistant/thread_message.py index 95cb1b47..f8a8ee10 100644 --- a/ai21/clients/studio/resources/assistant/studio_thread_message.py +++ b/ai21/clients/studio/resources/beta/assistant/thread_message.py @@ -1,12 +1,12 @@ from __future__ import annotations -from ai21.clients.common.assistant.messages import Messages +from ai21.clients.common.beta.assistant.messages import Messages from ai21.clients.studio.resources.studio_resource import StudioResource, AsyncStudioResource from ai21.models.assistant.message import ThreadMessageRole, MessageContentText from ai21.models.responses.message_response import MessageResponse, ListMessageResponse -class StudioThreadMessage(StudioResource, Messages): +class ThreadMessage(StudioResource, Messages): def create( self, thread_id: str, @@ -26,7 +26,7 @@ def list(self, thread_id: str) -> ListMessageResponse: return self._get(path=f"/threads/{thread_id}/{self._module_name}", response_cls=ListMessageResponse) -class AsyncStudioThreadMessage(AsyncStudioResource, Messages): +class AsyncThreadMessage(AsyncStudioResource, Messages): async def create( self, thread_id: str, diff --git a/ai21/clients/studio/resources/beta/assistant/thread_run.py b/ai21/clients/studio/resources/beta/assistant/thread_run.py new file mode 100644 index 00000000..71955363 --- /dev/null +++ b/ai21/clients/studio/resources/beta/assistant/thread_run.py @@ -0,0 +1,104 @@ +from __future__ import annotations + +from typing import List + +from ai21.clients.common.beta.assistant.runs import Runs +from ai21.clients.studio.resources.studio_resource import StudioResource, AsyncStudioResource +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 NotGiven, NOT_GIVEN + + +class ThreadRun(StudioResource, Runs): + 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, + ) + + +class AsyncThreadRun(AsyncStudioResource, Runs): + 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, + ) diff --git a/ai21/clients/studio/resources/beta/async_beta.py b/ai21/clients/studio/resources/beta/async_beta.py index 1bb13bbe..5c93b9f6 100644 --- a/ai21/clients/studio/resources/beta/async_beta.py +++ b/ai21/clients/studio/resources/beta/async_beta.py @@ -1,5 +1,5 @@ -from ai21.clients.studio.resources.assistant.studio_assistant import AsyncStudioAssistant -from ai21.clients.studio.resources.assistant.studio_thread import AsyncStudioThread +from ai21.clients.studio.resources.beta.assistant.assistant import AsyncAssistant +from ai21.clients.studio.resources.beta.assistant.thread import AsyncThread 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 @@ -9,6 +9,6 @@ class AsyncBeta(AsyncStudioResource): def __init__(self, client: AsyncAI21HTTPClient): super().__init__(client) - self.assistants = AsyncStudioAssistant(client) + self.assistants = AsyncAssistant(client) self.conversational_rag = AsyncStudioConversationalRag(client) - self.threads = AsyncStudioThread(client) + self.threads = AsyncThread(client) diff --git a/ai21/clients/studio/resources/beta/beta.py b/ai21/clients/studio/resources/beta/beta.py index affede10..62b55e80 100644 --- a/ai21/clients/studio/resources/beta/beta.py +++ b/ai21/clients/studio/resources/beta/beta.py @@ -1,5 +1,5 @@ -from ai21.clients.studio.resources.assistant.studio_assistant import StudioAssistant -from ai21.clients.studio.resources.assistant.studio_thread import StudioThread +from ai21.clients.studio.resources.beta.assistant.assistant import Assistant +from ai21.clients.studio.resources.beta.assistant.thread import Thread 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 @@ -9,6 +9,6 @@ class Beta(StudioResource): def __init__(self, client: AI21HTTPClient): super().__init__(client) - self.assistants = StudioAssistant(client) + self.assistants = Assistant(client) self.conversational_rag = StudioConversationalRag(client) - self.threads = StudioThread(client) + self.threads = Thread(client) diff --git a/ai21/models/assistant/run.py b/ai21/models/assistant/run.py new file mode 100644 index 00000000..ed118545 --- /dev/null +++ b/ai21/models/assistant/run.py @@ -0,0 +1,41 @@ +from typing import Literal, Any, List + +from typing_extensions import TypedDict + + +RunStatus = Literal[ + "cancelled", + "cancelling", + "completed", + "expired", + "failed", + "incomplete", + "in_progress", + "queued", + "requires_action", +] + + +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 RequiredAction(TypedDict): + type: Literal["submit_tool_outputs"] + submit_tool_outputs: SubmitToolCallOutputs diff --git a/ai21/models/responses/assistant_response.py b/ai21/models/responses/assistant_response.py index 3263b5a8..0bf40c5f 100644 --- a/ai21/models/responses/assistant_response.py +++ b/ai21/models/responses/assistant_response.py @@ -5,7 +5,7 @@ from ai21.models.assistant.assistant import ToolResources -class Assistant(AI21BaseModel): +class AssistantResponse(AI21BaseModel): id: str created_at: datetime updated_at: datetime @@ -23,4 +23,4 @@ class Assistant(AI21BaseModel): class ListAssistant(AI21BaseModel): - results: List[Assistant] + results: List[AssistantResponse] diff --git a/ai21/models/responses/run_response.py b/ai21/models/responses/run_response.py new file mode 100644 index 00000000..0a260235 --- /dev/null +++ b/ai21/models/responses/run_response.py @@ -0,0 +1,19 @@ +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 diff --git a/ai21/models/responses/thread_response.py b/ai21/models/responses/thread_response.py index b2c9bbc7..f7206a40 100644 --- a/ai21/models/responses/thread_response.py +++ b/ai21/models/responses/thread_response.py @@ -4,7 +4,7 @@ from ai21.models.ai21_base_model import AI21BaseModel -class Thread(AI21BaseModel): +class ThreadResponse(AI21BaseModel): id: str created_at: datetime updated_at: datetime @@ -12,4 +12,4 @@ class Thread(AI21BaseModel): class ListThread(AI21BaseModel): - results: List[Thread] + results: List[ThreadResponse] diff --git a/examples/studio/assistant/assistant.py b/examples/studio/assistant/assistant.py new file mode 100644 index 00000000..ebe3100f --- /dev/null +++ b/examples/studio/assistant/assistant.py @@ -0,0 +1,47 @@ +import time + +from ai21 import AI21Client + +TIMEOUT = 20 + + +def main(): + ai21_client = AI21Client() + + assistant = ai21_client.beta.assistants.create(name="My Assistant") + + thread = ai21_client.beta.threads.create( + messages=[ + { + "role": "user", + "content": { + "type": "text", + "text": "Hello", + }, + }, + ] + ) + + run = ai21_client.beta.threads.runs.create( + thread_id=thread.id, + assistant_id=assistant.id, + ) + + start = time.time() + + while run.status == "in_progress": + run = ai21_client.beta.threads.runs.retrieve(thread_id=thread.id, run_id=run.id) + if time.time() - start > TIMEOUT: + break + time.sleep(1) + + 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: + raise Exception(f"Run failed. 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..3f68805f --- /dev/null +++ b/examples/studio/assistant/async_assistant.py @@ -0,0 +1,49 @@ +import asyncio +import time + +from ai21 import AsyncAI21Client + + +TIMEOUT = 20 + + +async def main(): + ai21_client = AsyncAI21Client() + + assistant = await ai21_client.beta.assistants.create(name="My Assistant") + + thread = await ai21_client.beta.threads.create( + messages=[ + { + "role": "user", + "content": { + "type": "text", + "text": "Hello", + }, + }, + ] + ) + + run = await ai21_client.beta.threads.runs.create( + thread_id=thread.id, + assistant_id=assistant.id, + ) + + start = time.time() + + while run.status == "in_progress": + run = await ai21_client.beta.threads.runs.retrieve(thread_id=thread.id, run_id=run.id) + if time.time() - start > TIMEOUT: + break + time.sleep(1) + + 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)) + else: + raise Exception(f"Run failed. Status: {run.status}") + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/tests/integration_tests/clients/test_studio.py b/tests/integration_tests/clients/test_studio.py index 5cd0d4dd..4a581b0e 100644 --- a/tests/integration_tests/clients/test_studio.py +++ b/tests/integration_tests/clients/test_studio.py @@ -55,6 +55,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 +64,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): From f1f5cbccb894fdd2ccb8680376801cd9c9bc4391 Mon Sep 17 00:00:00 2001 From: Ben <23212294+benshuk@users.noreply.github.com> Date: Wed, 4 Dec 2024 17:37:14 +0200 Subject: [PATCH 23/50] feat: :sparkles: add support for `Plan` and `Route` resources (#238) * 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 --- .../common/beta/assistant/assistants.py | 6 +- .../clients/common/beta/assistant/messages.py | 2 +- ai21/clients/common/beta/assistant/plans.py | 61 +++++++ ai21/clients/common/beta/assistant/routes.py | 77 +++++++++ ai21/clients/common/beta/assistant/runs.py | 2 +- ai21/clients/common/beta/assistant/threads.py | 6 +- .../resources/beta/assistant/assistant.py | 22 ++- .../beta/assistant/assistant_routes.py | 149 ++++++++++++++++++ .../beta/assistant/assistants_plans.py | 98 ++++++++++++ .../studio/resources/beta/assistant/thread.py | 18 +-- .../{thread_message.py => thread_messages.py} | 6 +- .../{thread_run.py => thread_runs.py} | 6 +- .../studio/resources/beta/async_beta.py | 8 +- ai21/clients/studio/resources/beta/beta.py | 8 +- ai21/models/responses/plan_response.py | 22 +++ ai21/models/responses/route_response.py | 19 +++ 16 files changed, 478 insertions(+), 32 deletions(-) create mode 100644 ai21/clients/common/beta/assistant/plans.py create mode 100644 ai21/clients/common/beta/assistant/routes.py create mode 100644 ai21/clients/studio/resources/beta/assistant/assistant_routes.py create mode 100644 ai21/clients/studio/resources/beta/assistant/assistants_plans.py rename ai21/clients/studio/resources/beta/assistant/{thread_message.py => thread_messages.py} (88%) rename ai21/clients/studio/resources/beta/assistant/{thread_run.py => thread_runs.py} (95%) create mode 100644 ai21/models/responses/plan_response.py create mode 100644 ai21/models/responses/route_response.py diff --git a/ai21/clients/common/beta/assistant/assistants.py b/ai21/clients/common/beta/assistant/assistants.py index 65bbabf2..7552cdbe 100644 --- a/ai21/clients/common/beta/assistant/assistants.py +++ b/ai21/clients/common/beta/assistant/assistants.py @@ -3,14 +3,18 @@ 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 from ai21.types import NotGiven, NOT_GIVEN from ai21.utils.typing import remove_not_given -class Assistants(ABC): +class BaseAssistants(ABC): _module_name = "assistants" + plans: BasePlans + routes: BaseRoutes @abstractmethod def create( diff --git a/ai21/clients/common/beta/assistant/messages.py b/ai21/clients/common/beta/assistant/messages.py index 0ccbde79..9ecbe991 100644 --- a/ai21/clients/common/beta/assistant/messages.py +++ b/ai21/clients/common/beta/assistant/messages.py @@ -6,7 +6,7 @@ from ai21.models.responses.message_response import MessageResponse, ListMessageResponse -class Messages(ABC): +class BaseMessages(ABC): _module_name = "messages" @abstractmethod diff --git a/ai21/clients/common/beta/assistant/plans.py b/ai21/clients/common/beta/assistant/plans.py new file mode 100644 index 00000000..e4248f68 --- /dev/null +++ b/ai21/clients/common/beta/assistant/plans.py @@ -0,0 +1,61 @@ +from __future__ import annotations + +from abc import ABC, abstractmethod +from typing import Any, Dict + +from ai21.models.responses.plan_response import PlanResponse, ListPlanResponse +from ai21.utils.typing import remove_not_given + + +class BasePlans(ABC): + _module_name = "plans" + + @abstractmethod + def create( + self, + *, + assistant_id: str, + code: str, + **kwargs, + ) -> PlanResponse: + pass + + def _create_body( + self, + *, + code: str, + **kwargs, + ) -> Dict[str, Any]: + return remove_not_given( + { + "code": code, + **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, + ) -> 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..38f0fff1 --- /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, + description: str, + examples: List[str], + **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 index 656bf26e..0ea681a6 100644 --- a/ai21/clients/common/beta/assistant/runs.py +++ b/ai21/clients/common/beta/assistant/runs.py @@ -10,7 +10,7 @@ from ai21.utils.typing import remove_not_given -class Runs(ABC): +class BaseRuns(ABC): _module_name = "runs" @abstractmethod diff --git a/ai21/clients/common/beta/assistant/threads.py b/ai21/clients/common/beta/assistant/threads.py index 75674fc9..ff67ed60 100644 --- a/ai21/clients/common/beta/assistant/threads.py +++ b/ai21/clients/common/beta/assistant/threads.py @@ -3,14 +3,14 @@ from abc import ABC, abstractmethod from typing import List -from ai21.clients.common.beta.assistant.messages import Messages +from ai21.clients.common.beta.assistant.messages import BaseMessages from ai21.models.assistant.message import Message from ai21.models.responses.thread_response import ThreadResponse -class Threads(ABC): +class BaseThreads(ABC): _module_name = "threads" - messages: Messages + messages: BaseMessages @abstractmethod def create( diff --git a/ai21/clients/studio/resources/beta/assistant/assistant.py b/ai21/clients/studio/resources/beta/assistant/assistant.py index 7b49a4c6..af129f12 100644 --- a/ai21/clients/studio/resources/beta/assistant/assistant.py +++ b/ai21/clients/studio/resources/beta/assistant/assistant.py @@ -2,17 +2,27 @@ from typing import List -from ai21.clients.common.beta.assistant.assistants import Assistants +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 from ai21.types import NotGiven, NOT_GIVEN -class Assistant(StudioResource, Assistants): +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, @@ -67,7 +77,13 @@ def modify( return self._patch(path=f"/{self._module_name}/{assistant_id}", body=body, response_cls=AssistantResponse) -class AsyncAssistant(AsyncStudioResource, Assistants): +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, 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..7916b31d --- /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 + + +class AssistantRoutes(StudioResource, BaseRoutes): + def create( + self, + *, + assistant_id: str, + plan_id: str, + name: str, + description: str, + 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 = NotGiven, + ) -> 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 = NotGiven, + examples: List[str] | NotGiven = NotGiven, + ) -> 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, + 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 = NotGiven, + ) -> 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 = NotGiven, + examples: List[str] | NotGiven = NotGiven, + ) -> 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..aa6a66d4 --- /dev/null +++ b/ai21/clients/studio/resources/beta/assistant/assistants_plans.py @@ -0,0 +1,98 @@ +from __future__ import annotations + +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 + + +class AssistantPlans(StudioResource, BasePlans): + def create( + self, + *, + assistant_id: str, + code: str, + **kwargs, + ) -> PlanResponse: + body = self._create_body( + code=code, + **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, + ) -> PlanResponse: + body = dict(code=code) + + 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, + **kwargs, + ) -> PlanResponse: + body = self._create_body( + code=code, + **kwargs, + ) + + return 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, + ) -> PlanResponse: + body = dict(code=code) + + 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 index b2fdf57b..50ed0e16 100644 --- a/ai21/clients/studio/resources/beta/assistant/thread.py +++ b/ai21/clients/studio/resources/beta/assistant/thread.py @@ -2,9 +2,9 @@ from typing import List -from ai21.clients.common.beta.assistant.threads import Threads -from ai21.clients.studio.resources.beta.assistant.thread_message import ThreadMessage, AsyncThreadMessage -from ai21.clients.studio.resources.beta.assistant.thread_run import AsyncThreadRun, ThreadRun +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 @@ -12,12 +12,12 @@ from ai21.models.responses.thread_response import ThreadResponse -class Thread(StudioResource, Threads): +class Threads(StudioResource, BaseThreads): def __init__(self, client: AI21HTTPClient): super().__init__(client) - self.messages = ThreadMessage(client) - self.runs = ThreadRun(client) + self.messages = ThreadMessages(client) + self.runs = ThreadRuns(client) def create( self, @@ -32,12 +32,12 @@ def retrieve(self, thread_id: str) -> ThreadResponse: return self._get(path=f"/{self._module_name}/{thread_id}", response_cls=ThreadResponse) -class AsyncThread(AsyncStudioResource, Threads): +class AsyncThreads(AsyncStudioResource, BaseThreads): def __init__(self, client: AsyncAI21HTTPClient): super().__init__(client) - self.messages = AsyncThreadMessage(client) - self.runs = AsyncThreadRun(client) + self.messages = AsyncThreadMessages(client) + self.runs = AsyncThreadRuns(client) async def create( self, diff --git a/ai21/clients/studio/resources/beta/assistant/thread_message.py b/ai21/clients/studio/resources/beta/assistant/thread_messages.py similarity index 88% rename from ai21/clients/studio/resources/beta/assistant/thread_message.py rename to ai21/clients/studio/resources/beta/assistant/thread_messages.py index f8a8ee10..2cdd6d6d 100644 --- a/ai21/clients/studio/resources/beta/assistant/thread_message.py +++ b/ai21/clients/studio/resources/beta/assistant/thread_messages.py @@ -1,12 +1,12 @@ from __future__ import annotations -from ai21.clients.common.beta.assistant.messages import Messages +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, MessageContentText from ai21.models.responses.message_response import MessageResponse, ListMessageResponse -class ThreadMessage(StudioResource, Messages): +class ThreadMessages(StudioResource, BaseMessages): def create( self, thread_id: str, @@ -26,7 +26,7 @@ def list(self, thread_id: str) -> ListMessageResponse: return self._get(path=f"/threads/{thread_id}/{self._module_name}", response_cls=ListMessageResponse) -class AsyncThreadMessage(AsyncStudioResource, Messages): +class AsyncThreadMessages(AsyncStudioResource, BaseMessages): async def create( self, thread_id: str, diff --git a/ai21/clients/studio/resources/beta/assistant/thread_run.py b/ai21/clients/studio/resources/beta/assistant/thread_runs.py similarity index 95% rename from ai21/clients/studio/resources/beta/assistant/thread_run.py rename to ai21/clients/studio/resources/beta/assistant/thread_runs.py index 71955363..04908fc5 100644 --- a/ai21/clients/studio/resources/beta/assistant/thread_run.py +++ b/ai21/clients/studio/resources/beta/assistant/thread_runs.py @@ -2,7 +2,7 @@ from typing import List -from ai21.clients.common.beta.assistant.runs import Runs +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 @@ -10,7 +10,7 @@ from ai21.types import NotGiven, NOT_GIVEN -class ThreadRun(StudioResource, Runs): +class ThreadRuns(StudioResource, BaseRuns): def create( self, *, @@ -56,7 +56,7 @@ def submit_tool_outputs(self, *, thread_id: str, run_id: str, tool_outputs: List ) -class AsyncThreadRun(AsyncStudioResource, Runs): +class AsyncThreadRuns(AsyncStudioResource, BaseRuns): async def create( self, *, diff --git a/ai21/clients/studio/resources/beta/async_beta.py b/ai21/clients/studio/resources/beta/async_beta.py index 5c93b9f6..5a29cb9e 100644 --- a/ai21/clients/studio/resources/beta/async_beta.py +++ b/ai21/clients/studio/resources/beta/async_beta.py @@ -1,5 +1,5 @@ -from ai21.clients.studio.resources.beta.assistant.assistant import AsyncAssistant -from ai21.clients.studio.resources.beta.assistant.thread import AsyncThread +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 @@ -9,6 +9,6 @@ class AsyncBeta(AsyncStudioResource): def __init__(self, client: AsyncAI21HTTPClient): super().__init__(client) - self.assistants = AsyncAssistant(client) + self.assistants = AsyncAssistants(client) self.conversational_rag = AsyncStudioConversationalRag(client) - self.threads = AsyncThread(client) + self.threads = AsyncThreads(client) diff --git a/ai21/clients/studio/resources/beta/beta.py b/ai21/clients/studio/resources/beta/beta.py index 62b55e80..d2d36a1d 100644 --- a/ai21/clients/studio/resources/beta/beta.py +++ b/ai21/clients/studio/resources/beta/beta.py @@ -1,5 +1,5 @@ -from ai21.clients.studio.resources.beta.assistant.assistant import Assistant -from ai21.clients.studio.resources.beta.assistant.thread import Thread +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 @@ -9,6 +9,6 @@ class Beta(StudioResource): def __init__(self, client: AI21HTTPClient): super().__init__(client) - self.assistants = Assistant(client) + self.assistants = Assistants(client) self.conversational_rag = StudioConversationalRag(client) - self.threads = Thread(client) + self.threads = Threads(client) diff --git a/ai21/models/responses/plan_response.py b/ai21/models/responses/plan_response.py new file mode 100644 index 00000000..3f87152d --- /dev/null +++ b/ai21/models/responses/plan_response.py @@ -0,0 +1,22 @@ +from datetime import datetime +from typing import List, Optional + +from ai21.models.ai21_base_model import AI21BaseModel + + +class PlanResponse(AI21BaseModel): + id: str + created_at: datetime + updated_at: datetime + assistant_id: str + code: str + + +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] From 3bdad90a0dd7ac5e7ace2acdea58d18cf6b6599b Mon Sep 17 00:00:00 2001 From: semantic-release Date: Wed, 4 Dec 2024 15:46:15 +0000 Subject: [PATCH 24/50] chore(release): v3.1.0-rc.1 [skip ci] --- CHANGELOG.md | 140 ++++++++++++++++++++++++++++++++++++++++++++++++ ai21/version.py | 2 +- pyproject.toml | 2 +- 3 files changed, 142 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15291a4b..ae4c1461 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,144 @@ # CHANGELOG +## v3.1.0-rc.1 (2024-12-04) + +### Chores + +* chore(deps): bump pypa/gh-action-pypi-publish from 1.10.3 to 1.12.2 (#227) + +Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.10.3 to 1.12.2. +- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) +- [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 +... + +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> ([`4247632`](https://github.com/AI21Labs/ai21-python/commit/4247632694cee72baf6208ff61a806611a5f2ebe)) + +### Features + +* feat: :sparkles: add support for `Plan` and `Route` resources (#238) + +* 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 ([`f1f5cbc`](https://github.com/AI21Labs/ai21-python/commit/f1f5cbccb894fdd2ccb8680376801cd9c9bc4391)) + +* feat: ✨ add support for Run resource (#236) + +* 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 ([`d4beb22`](https://github.com/AI21Labs/ai21-python/commit/d4beb227242d6e2055f1279b6ba9f453a5c0233b)) + +* feat: :sparkles: add support for Message resource ([`b483e70`](https://github.com/AI21Labs/ai21-python/commit/b483e704743a2d9e8fbd5da99f97bf348263a4d5)) + +* feat: :sparkles: add support for Thread resource ([`62566cd`](https://github.com/AI21Labs/ai21-python/commit/62566cd1fd0b42bfcd181ebb5b5032e62a15730b)) + +* feat: :sparkles: add support for Assistant resource + +under `beta` ([`16ef903`](https://github.com/AI21Labs/ai21-python/commit/16ef9038dc50f4c7731953bdc51073ba45655b03)) + +* feat: :sparkles: add support for Assistant resource + +under `beta` ([`4b31a42`](https://github.com/AI21Labs/ai21-python/commit/4b31a42351d42b6604a9b05ea9bc0b19413d91d8)) + +### Fixes + +* fix: :truck: rename `get` method to `retrieve` ([`d2747a5`](https://github.com/AI21Labs/ai21-python/commit/d2747a56169c8c68cd9701291fab72509835f830)) + +* fix: :truck: move classes and such ([`c944172`](https://github.com/AI21Labs/ai21-python/commit/c944172571e10452b93542944794e6bcaeaff2c7)) + +* fix: :truck: rename classes and such ([`ae7a3e4`](https://github.com/AI21Labs/ai21-python/commit/ae7a3e40dd13c3feb0b41af8bbef3ed4b2490ca9)) + +* fix: :green_heart: imports ([`a9f7d67`](https://github.com/AI21Labs/ai21-python/commit/a9f7d67feaa088ffa97f87220e3198cf0d5eb0b3)) + +* fix: :label: tool_resources use type ([`5de2d8c`](https://github.com/AI21Labs/ai21-python/commit/5de2d8c0af03b7e1fb95bf7302422374e0d77954)) + +* fix: :label: remove `Model` Literal typing ([`90f44f5`](https://github.com/AI21Labs/ai21-python/commit/90f44f575b3031f4b11edcbc6e9fef4a8b2e1c62)) + +* fix: :bug: pr fixes ([`c46e517`](https://github.com/AI21Labs/ai21-python/commit/c46e517cfd8619e4cb25581f5e714ee8fc919e47)) + +* fix: :label: better typing & remove doc string ([`18d0092`](https://github.com/AI21Labs/ai21-python/commit/18d009202b64a41e70c9824fa14256e4c741606f)) + +* fix: :bug: use `List` for typing instead of `list` ([`fc45f19`](https://github.com/AI21Labs/ai21-python/commit/fc45f19027b9f21cbf3c711952a6b1ddc3db932c)) + +* fix: :green_heart: imports ([`f9e695b`](https://github.com/AI21Labs/ai21-python/commit/f9e695bd5e51b49ade8342cb4796cf2b1b97e630)) + +* fix: :label: tool_resources use type ([`c8ee041`](https://github.com/AI21Labs/ai21-python/commit/c8ee04176eeb3cf70591048a7fcf516dab99c5f4)) + +* fix: :label: remove `Model` Literal typing ([`17af071`](https://github.com/AI21Labs/ai21-python/commit/17af071f1a8d3dc7913ee7922884eedf1468f157)) + +* fix: :bug: pr fixes ([`dd7d71d`](https://github.com/AI21Labs/ai21-python/commit/dd7d71d82eda94ef2a72fdb1492015d57444bf4e)) + +* fix: :label: better typing & remove doc string ([`a03deab`](https://github.com/AI21Labs/ai21-python/commit/a03deab60a4a4be43a3211959a16c4ea132bf63f)) + +* fix: :bug: use `List` for typing instead of `list` ([`3128145`](https://github.com/AI21Labs/ai21-python/commit/3128145a85283c8f7ed0984fffee7febb32f3ae0)) + +### Refactoring + +* refactor: :art: reformat functions with 2+ arguments ([`a8c345e`](https://github.com/AI21Labs/ai21-python/commit/a8c345e81f2b29dd14e5ec118d5f4068792198df)) + +* refactor: :truck: move `MessageResponse` type to a separate file ([`151f5ac`](https://github.com/AI21Labs/ai21-python/commit/151f5acfa2d83fccb8b9bc459fce761324542ce5)) + +### Unknown + +* Merge pull request #234 from AI21Labs/messages + +feat: :sparkles: add support for Message resource ([`abcc2f9`](https://github.com/AI21Labs/ai21-python/commit/abcc2f9fc465244f35ae11cf6cd910f03016a722)) + +* Merge pull request #232 from AI21Labs/threads + +feat: :sparkles: add support for Thread resource ([`29fb8ce`](https://github.com/AI21Labs/ai21-python/commit/29fb8ce68a48ce94196059eadd0664726e59207a)) + +* Merge remote-tracking branch 'origin/rc_assistant_api_support' into rc_assistant_api_support ([`2cf1a85`](https://github.com/AI21Labs/ai21-python/commit/2cf1a85950dd6b52dc1ded2606cef21fe358f224)) + +* Merge pull request #231 from AI21Labs/assistant + +feat: :sparkles: add support for Assistant resource ([`139887d`](https://github.com/AI21Labs/ai21-python/commit/139887d99edf8d8fb23e43e40511cb5b6753d577)) + + ## v3.0.0 (2024-11-11) ### Breaking @@ -9,6 +147,8 @@ ### Chores +* chore(release): v3.0.0 [skip ci] ([`7457c5b`](https://github.com/AI21Labs/ai21-python/commit/7457c5b2c2d9dab24b1cf863786db710bd16f7a6)) + * chore(release): v2.16.0 [skip ci] ([`d8a6ecc`](https://github.com/AI21Labs/ai21-python/commit/d8a6ecc0da4f19183cdba826cf6641ad39dafbe8)) ### Features diff --git a/ai21/version.py b/ai21/version.py index ea9d6945..7a32f041 100644 --- a/ai21/version.py +++ b/ai21/version.py @@ -1 +1 @@ -VERSION = "3.0.0" +VERSION = "3.1.0-rc.1" diff --git a/pyproject.toml b/pyproject.toml index 89296790..7ea4eb09 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ exclude_lines = [ [tool.poetry] name = "ai21" -version = "3.0.0" +version = "3.1.0-rc.1" description = "" authors = ["AI21 Labs"] readme = "README.md" From 770c6c51fd7ea287d2485a3048fe748db5b636b3 Mon Sep 17 00:00:00 2001 From: Ben <23212294+benshuk@users.noreply.github.com> Date: Wed, 11 Dec 2024 10:56:45 +0200 Subject: [PATCH 25/50] chore: :truck: rename `internet_research` to `web_search` (#241) EXEC-470 Co-authored-by: benshuk --- ai21/models/assistant/assistant.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ai21/models/assistant/assistant.py b/ai21/models/assistant/assistant.py index 44c3ed06..cdb39f36 100644 --- a/ai21/models/assistant/assistant.py +++ b/ai21/models/assistant/assistant.py @@ -3,10 +3,10 @@ from typing_extensions import TypedDict Optimization = Literal["cost", "latency"] -Tool = Literal["rag", "internet_research", "plan_approval"] +Tool = Literal["rag", "web_search", "plan_approval"] class ToolResources(TypedDict, total=False): rag: Optional[dict] - internet_research: Optional[dict] + web_search: Optional[dict] plan_approval: Optional[dict] From 78c58d588b91f64bebd53445a1585b008011afe7 Mon Sep 17 00:00:00 2001 From: MichalAI21 <101511249+MichalAI21@users.noreply.github.com> Date: Mon, 16 Dec 2024 14:35:30 +0200 Subject: [PATCH 26/50] fix: Adapt assistant sdk to hlp (#242) * 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: adapt code to 3.8 * fix: support model schemas of python 3.11 * fix: support model schemas of python 3.11 * fix: PR comments * fix: PR comments * fix: add user defined plan example to integration tests --- ai21/clients/common/beta/assistant/plans.py | 37 ++++- .../beta/assistant/assistants_plans.py | 21 ++- ai21/errors.py | 7 + ai21/models/_pydantic_compatibility.py | 9 +- ai21/models/responses/plan_response.py | 3 +- .../studio/assistant/user_defined_plans.py | 25 ++++ .../integration_tests/clients/test_studio.py | 2 + .../studio/resources/assistant/__init__.py | 0 .../resources/assistant/plans/__init__.py | 0 .../plans/test_plan_body_creation.py | 130 ++++++++++++++++++ 10 files changed, 226 insertions(+), 8 deletions(-) create mode 100644 examples/studio/assistant/user_defined_plans.py create mode 100644 tests/unittests/clients/studio/resources/assistant/__init__.py create mode 100644 tests/unittests/clients/studio/resources/assistant/plans/__init__.py create mode 100644 tests/unittests/clients/studio/resources/assistant/plans/test_plan_body_creation.py diff --git a/ai21/clients/common/beta/assistant/plans.py b/ai21/clients/common/beta/assistant/plans.py index e4248f68..6923cf75 100644 --- a/ai21/clients/common/beta/assistant/plans.py +++ b/ai21/clients/common/beta/assistant/plans.py @@ -1,21 +1,43 @@ from __future__ import annotations +import inspect from abc import ABC, abstractmethod -from typing import Any, Dict +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, + code: str | Callable, + schemas: List[Dict[str, Any]] | List[Type[BaseModel]] | NotGiven = NOT_GIVEN, **kwargs, ) -> PlanResponse: pass @@ -23,12 +45,18 @@ def create( def _create_body( self, *, - code: str, + 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, + "code": code_str, + "schemas": ( + [self._parse_schema(schema) for schema in schemas] if schemas is not NOT_GIVEN else NOT_GIVEN + ), **kwargs, } ) @@ -57,5 +85,6 @@ def modify( assistant_id: str, plan_id: str, code: str, + schemas: List[Dict[str, Any]] | NotGiven = NOT_GIVEN, ) -> PlanResponse: pass diff --git a/ai21/clients/studio/resources/beta/assistant/assistants_plans.py b/ai21/clients/studio/resources/beta/assistant/assistants_plans.py index aa6a66d4..81d78eee 100644 --- a/ai21/clients/studio/resources/beta/assistant/assistants_plans.py +++ b/ai21/clients/studio/resources/beta/assistant/assistants_plans.py @@ -1,11 +1,16 @@ 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): @@ -14,10 +19,12 @@ def create( *, 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, ) @@ -44,8 +51,12 @@ def modify( assistant_id: str, plan_id: str, code: str, + schemas: List[Dict[str, Any]] | List[Type[BaseModel]] | NotGiven = NOT_GIVEN, ) -> PlanResponse: - body = dict(code=code) + 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 @@ -58,10 +69,12 @@ async def create( *, 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, ) @@ -90,8 +103,12 @@ async def modify( assistant_id: str, plan_id: str, code: str, + schemas: List[Dict[str, Any]] | List[Type[BaseModel]] | NotGiven = NOT_GIVEN, ) -> PlanResponse: - body = dict(code=code) + 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/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/responses/plan_response.py b/ai21/models/responses/plan_response.py index 3f87152d..db0876a3 100644 --- a/ai21/models/responses/plan_response.py +++ b/ai21/models/responses/plan_response.py @@ -1,5 +1,5 @@ from datetime import datetime -from typing import List, Optional +from typing import List, Optional, Dict, Any from ai21.models.ai21_base_model import AI21BaseModel @@ -10,6 +10,7 @@ class PlanResponse(AI21BaseModel): updated_at: datetime assistant_id: str code: str + schemas: List[Dict[str, Any]] class ListPlanResponse(AI21BaseModel): diff --git a/examples/studio/assistant/user_defined_plans.py b/examples/studio/assistant/user_defined_plans.py new file mode 100644 index 00000000..ba8e1f54 --- /dev/null +++ b/examples/studio/assistant/user_defined_plans.py @@ -0,0 +1,25 @@ +from ai21 import AI21Client +from pydantic import BaseModel + +TIMEOUT = 20 + + +def test_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=test_func, schemas=[ExampleSchema]) + route = ai21_client.beta.assistants.routes.create( + assistant_id=assistant.id, plan_id=plan.id, name="My Route", examples=["hi"], description="My Route Description" + ) + print(f"Route: {route}") diff --git a/tests/integration_tests/clients/test_studio.py b/tests/integration_tests/clients/test_studio.py index 4a581b0e..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): 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) From 5deee97bfdf97e7e15203c2267983c55e695cfde Mon Sep 17 00:00:00 2001 From: semantic-release Date: Sun, 22 Dec 2024 15:33:02 +0000 Subject: [PATCH 27/50] chore(release): v3.1.0-rc.2 [skip ci] --- CHANGELOG.md | 43 +++++++++++++++++++++++++++++++++++++++++++ ai21/version.py | 2 +- pyproject.toml | 2 +- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae4c1461..58ec94a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,53 @@ # CHANGELOG +## v3.1.0-rc.2 (2024-12-22) + +### Chores + +* chore: :truck: rename `internet_research` to `web_search` (#241) + +EXEC-470 + +Co-authored-by: benshuk ([`770c6c5`](https://github.com/AI21Labs/ai21-python/commit/770c6c51fd7ea287d2485a3048fe748db5b636b3)) + +### Fixes + +* fix: Adapt assistant sdk to hlp (#242) + +* 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: adapt code to 3.8 + +* fix: support model schemas of python 3.11 + +* fix: support model schemas of python 3.11 + +* fix: PR comments + +* fix: PR comments + +* fix: add user defined plan example to integration tests ([`78c58d5`](https://github.com/AI21Labs/ai21-python/commit/78c58d588b91f64bebd53445a1585b008011afe7)) + + ## v3.1.0-rc.1 (2024-12-04) ### Chores +* chore(release): v3.1.0-rc.1 [skip ci] ([`3bdad90`](https://github.com/AI21Labs/ai21-python/commit/3bdad90a0dd7ac5e7ace2acdea58d18cf6b6599b)) + * chore(deps): bump pypa/gh-action-pypi-publish from 1.10.3 to 1.12.2 (#227) Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.10.3 to 1.12.2. diff --git a/ai21/version.py b/ai21/version.py index 7a32f041..b7d3c121 100644 --- a/ai21/version.py +++ b/ai21/version.py @@ -1 +1 @@ -VERSION = "3.1.0-rc.1" +VERSION = "3.1.0-rc.2" diff --git a/pyproject.toml b/pyproject.toml index 7ea4eb09..c555d5e0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ exclude_lines = [ [tool.poetry] name = "ai21" -version = "3.1.0-rc.1" +version = "3.1.0-rc.2" description = "" authors = ["AI21 Labs"] readme = "README.md" From 5782127fbc805b68345ba68de2508a94306f50f4 Mon Sep 17 00:00:00 2001 From: MichalAI21 <101511249+MichalAI21@users.noreply.github.com> Date: Tue, 24 Dec 2024 13:20:52 +0200 Subject: [PATCH 28/50] fix: not given as a constant not class (#244) --- .../resources/beta/assistant/assistant_routes.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ai21/clients/studio/resources/beta/assistant/assistant_routes.py b/ai21/clients/studio/resources/beta/assistant/assistant_routes.py index 7916b31d..d5fabb07 100644 --- a/ai21/clients/studio/resources/beta/assistant/assistant_routes.py +++ b/ai21/clients/studio/resources/beta/assistant/assistant_routes.py @@ -8,7 +8,7 @@ StudioResource, ) from ai21.models.responses.route_response import RouteResponse, ListRouteResponse -from ai21.types import NotGiven +from ai21.types import NotGiven, NOT_GIVEN class AssistantRoutes(StudioResource, BaseRoutes): @@ -36,7 +36,7 @@ def list( self, *, assistant_id: str, - name: str | NotGiven = NotGiven, + name: str | NotGiven = NOT_GIVEN, ) -> ListRouteResponse: params = self._create_body(name=name) @@ -57,8 +57,8 @@ def modify( *, assistant_id: str, route_id: str, - description: str | NotGiven = NotGiven, - examples: List[str] | NotGiven = NotGiven, + description: str | NotGiven = NOT_GIVEN, + examples: List[str] | NotGiven = NOT_GIVEN, ) -> RouteResponse: body = self._create_body( description=description, @@ -105,7 +105,7 @@ async def list( self, *, assistant_id: str, - name: str | NotGiven = NotGiven, + name: str | NotGiven = NOT_GIVEN, ) -> ListRouteResponse: params = self._create_body(name=name) @@ -128,8 +128,8 @@ async def modify( *, assistant_id: str, route_id: str, - description: str | NotGiven = NotGiven, - examples: List[str] | NotGiven = NotGiven, + description: str | NotGiven = NOT_GIVEN, + examples: List[str] | NotGiven = NOT_GIVEN, ) -> RouteResponse: body = self._create_body( description=description, From d1ec5ff4de12054d3e76022445e075a41bc8b22d Mon Sep 17 00:00:00 2001 From: semantic-release Date: Thu, 26 Dec 2024 08:07:21 +0000 Subject: [PATCH 29/50] chore(release): v3.1.0-rc.3 [skip ci] --- CHANGELOG.md | 9 +++++++++ ai21/version.py | 2 +- pyproject.toml | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58ec94a9..d36e9be3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,19 @@ # CHANGELOG +## v3.1.0-rc.3 (2024-12-26) + +### Fixes + +* fix: not given as a constant not class (#244) ([`5782127`](https://github.com/AI21Labs/ai21-python/commit/5782127fbc805b68345ba68de2508a94306f50f4)) + + ## v3.1.0-rc.2 (2024-12-22) ### Chores +* chore(release): v3.1.0-rc.2 [skip ci] ([`5deee97`](https://github.com/AI21Labs/ai21-python/commit/5deee97bfdf97e7e15203c2267983c55e695cfde)) + * chore: :truck: rename `internet_research` to `web_search` (#241) EXEC-470 diff --git a/ai21/version.py b/ai21/version.py index b7d3c121..aefeac31 100644 --- a/ai21/version.py +++ b/ai21/version.py @@ -1 +1 @@ -VERSION = "3.1.0-rc.2" +VERSION = "3.1.0-rc.3" diff --git a/pyproject.toml b/pyproject.toml index c555d5e0..663baa2b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ exclude_lines = [ [tool.poetry] name = "ai21" -version = "3.1.0-rc.2" +version = "3.1.0-rc.3" description = "" authors = ["AI21 Labs"] readme = "README.md" From 23772dc5971914ce32853dcac38b3a0b59c9121c Mon Sep 17 00:00:00 2001 From: Ben <23212294+benshuk@users.noreply.github.com> Date: Mon, 6 Jan 2025 16:38:43 +0200 Subject: [PATCH 30/50] feat: :sparkles: add support for `str` message content (#245) * feat: :sparkles: add support for `str` message content * fix: :label: typing * fix: :label: typing again * fix: :label: typing thingy --------- Co-authored-by: benshuk --- .../clients/common/beta/assistant/messages.py | 4 ++-- .../studio/resources/beta/assistant/thread.py | 6 +++--- .../beta/assistant/thread_messages.py | 17 ++++++--------- ai21/models/assistant/message.py | 21 ++++++++++++++++--- ai21/models/responses/message_response.py | 4 ++-- examples/studio/assistant/assistant.py | 5 +---- examples/studio/assistant/async_assistant.py | 5 +---- 7 files changed, 33 insertions(+), 29 deletions(-) diff --git a/ai21/clients/common/beta/assistant/messages.py b/ai21/clients/common/beta/assistant/messages.py index 9ecbe991..5ebc8966 100644 --- a/ai21/clients/common/beta/assistant/messages.py +++ b/ai21/clients/common/beta/assistant/messages.py @@ -2,7 +2,7 @@ from abc import ABC, abstractmethod -from ai21.models.assistant.message import ThreadMessageRole, MessageContentText +from ai21.models.assistant.message import ThreadMessageRole, ThreadMessageContent from ai21.models.responses.message_response import MessageResponse, ListMessageResponse @@ -15,7 +15,7 @@ def create( thread_id: str, *, role: ThreadMessageRole, - content: MessageContentText, + content: ThreadMessageContent, **kwargs, ) -> MessageResponse: pass diff --git a/ai21/clients/studio/resources/beta/assistant/thread.py b/ai21/clients/studio/resources/beta/assistant/thread.py index 50ed0e16..54ef0c1d 100644 --- a/ai21/clients/studio/resources/beta/assistant/thread.py +++ b/ai21/clients/studio/resources/beta/assistant/thread.py @@ -8,7 +8,7 @@ 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.assistant.message import Message, modify_message_content from ai21.models.responses.thread_response import ThreadResponse @@ -24,7 +24,7 @@ def create( messages: List[Message], **kwargs, ) -> ThreadResponse: - body = dict(messages=messages) + body = dict(messages=[modify_message_content(message) for message in messages]) return self._post(path=f"/{self._module_name}", body=body, response_cls=ThreadResponse) @@ -44,7 +44,7 @@ async def create( messages: List[Message], **kwargs, ) -> ThreadResponse: - body = dict(messages=messages) + body = dict(messages=[modify_message_content(message) for message in messages]) return await self._post(path=f"/{self._module_name}", body=body, 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 index 2cdd6d6d..167c39bc 100644 --- a/ai21/clients/studio/resources/beta/assistant/thread_messages.py +++ b/ai21/clients/studio/resources/beta/assistant/thread_messages.py @@ -1,8 +1,9 @@ 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, MessageContentText +from ai21.models.assistant.message import ThreadMessageRole, modify_message_content, Message, ThreadMessageContent from ai21.models.responses.message_response import MessageResponse, ListMessageResponse @@ -12,13 +13,10 @@ def create( thread_id: str, *, role: ThreadMessageRole, - content: MessageContentText, + content: ThreadMessageContent, **kwargs, ) -> MessageResponse: - body = dict( - role=role, - content=content, - ) + 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) @@ -32,13 +30,10 @@ async def create( thread_id: str, *, role: ThreadMessageRole, - content: MessageContentText, + content: ThreadMessageContent, **kwargs, ) -> MessageResponse: - body = dict( - role=role, - content=content, - ) + 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 diff --git a/ai21/models/assistant/message.py b/ai21/models/assistant/message.py index 22ea77a2..ace7c146 100644 --- a/ai21/models/assistant/message.py +++ b/ai21/models/assistant/message.py @@ -1,15 +1,30 @@ -from typing import Literal +from __future__ import annotations +from typing import Literal, Union from typing_extensions import TypedDict + ThreadMessageRole = Literal["assistant", "user"] -class MessageContentText(TypedDict): +class ThreadMessageContentText(TypedDict): type: Literal["text"] text: str +ThreadMessageContent = Union[str, ThreadMessageContentText] + + class Message(TypedDict): role: ThreadMessageRole - content: MessageContentText + 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/responses/message_response.py b/ai21/models/responses/message_response.py index e19fa665..10426c19 100644 --- a/ai21/models/responses/message_response.py +++ b/ai21/models/responses/message_response.py @@ -2,7 +2,7 @@ from typing import Literal, Optional, List from ai21.models.ai21_base_model import AI21BaseModel -from ai21.models.assistant.message import ThreadMessageRole, MessageContentText +from ai21.models.assistant.message import ThreadMessageRole, ThreadMessageContentText class MessageResponse(AI21BaseModel): @@ -11,7 +11,7 @@ class MessageResponse(AI21BaseModel): updated_at: datetime object: Literal["message"] = "message" role: ThreadMessageRole - content: MessageContentText + content: ThreadMessageContentText run_id: Optional[str] = None assistant_id: Optional[str] = None diff --git a/examples/studio/assistant/assistant.py b/examples/studio/assistant/assistant.py index ebe3100f..bbd1eb1d 100644 --- a/examples/studio/assistant/assistant.py +++ b/examples/studio/assistant/assistant.py @@ -14,10 +14,7 @@ def main(): messages=[ { "role": "user", - "content": { - "type": "text", - "text": "Hello", - }, + "content": "Hello", }, ] ) diff --git a/examples/studio/assistant/async_assistant.py b/examples/studio/assistant/async_assistant.py index 3f68805f..19cf3d04 100644 --- a/examples/studio/assistant/async_assistant.py +++ b/examples/studio/assistant/async_assistant.py @@ -16,10 +16,7 @@ async def main(): messages=[ { "role": "user", - "content": { - "type": "text", - "text": "Hello", - }, + "content": "Hello", }, ] ) From 787d7d3f5d612106dcd55f35894953564ce4fd2d Mon Sep 17 00:00:00 2001 From: Ben <23212294+benshuk@users.noreply.github.com> Date: Tue, 7 Jan 2025 11:38:55 +0200 Subject: [PATCH 31/50] chore: add `error` to `RunResponse` model (#248) Co-authored-by: benshuk --- ai21/models/responses/run_response.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ai21/models/responses/run_response.py b/ai21/models/responses/run_response.py index 0a260235..63ae4400 100644 --- a/ai21/models/responses/run_response.py +++ b/ai21/models/responses/run_response.py @@ -17,3 +17,4 @@ class RunResponse(AI21BaseModel): optimization: Optimization execution_id: Optional[str] = None required_action: Optional[RequiredAction] = None + error: Optional[str] = None From 7ff423dbb00bb9aa83c80d280195ad13ec80fd3d Mon Sep 17 00:00:00 2001 From: Ben <23212294+benshuk@users.noreply.github.com> Date: Tue, 7 Jan 2025 17:23:47 +0200 Subject: [PATCH 32/50] feat: :sparkles: add support for status polling for `Run` (#249) * 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 --- ai21/clients/common/beta/assistant/runs.py | 20 +++++ .../resources/beta/assistant/thread_runs.py | 79 ++++++++++++++++++- ai21/models/assistant/run.py | 6 +- examples/studio/assistant/assistant.py | 16 +--- examples/studio/assistant/async_assistant.py | 18 +---- 5 files changed, 109 insertions(+), 30 deletions(-) diff --git a/ai21/clients/common/beta/assistant/runs.py b/ai21/clients/common/beta/assistant/runs.py index 0ea681a6..77c9af4e 100644 --- a/ai21/clients/common/beta/assistant/runs.py +++ b/ai21/clients/common/beta/assistant/runs.py @@ -65,3 +65,23 @@ def cancel( @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 diff --git a/ai21/clients/studio/resources/beta/assistant/thread_runs.py b/ai21/clients/studio/resources/beta/assistant/thread_runs.py index 04908fc5..19038cca 100644 --- a/ai21/clients/studio/resources/beta/assistant/thread_runs.py +++ b/ai21/clients/studio/resources/beta/assistant/thread_runs.py @@ -1,11 +1,18 @@ from __future__ import annotations +import asyncio +import time from typing import 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 +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 @@ -55,6 +62,41 @@ def submit_tool_outputs(self, *, thread_id: str, run_id: str, tool_outputs: List 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 + ) + class AsyncThreadRuns(AsyncStudioResource, BaseRuns): async def create( @@ -102,3 +144,38 @@ async def submit_tool_outputs(self, *, thread_id: str, run_id: str, 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 + ) diff --git a/ai21/models/assistant/run.py b/ai21/models/assistant/run.py index ed118545..850cf765 100644 --- a/ai21/models/assistant/run.py +++ b/ai21/models/assistant/run.py @@ -1,4 +1,4 @@ -from typing import Literal, Any, List +from typing import Literal, Any, List, Set from typing_extensions import TypedDict @@ -15,6 +15,10 @@ "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 diff --git a/examples/studio/assistant/assistant.py b/examples/studio/assistant/assistant.py index bbd1eb1d..a3ba465c 100644 --- a/examples/studio/assistant/assistant.py +++ b/examples/studio/assistant/assistant.py @@ -1,9 +1,5 @@ -import time - from ai21 import AI21Client -TIMEOUT = 20 - def main(): ai21_client = AI21Client() @@ -19,25 +15,17 @@ def main(): ] ) - run = ai21_client.beta.threads.runs.create( + run = ai21_client.beta.threads.runs.create_and_poll( thread_id=thread.id, assistant_id=assistant.id, ) - start = time.time() - - while run.status == "in_progress": - run = ai21_client.beta.threads.runs.retrieve(thread_id=thread.id, run_id=run.id) - if time.time() - start > TIMEOUT: - break - time.sleep(1) - 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: - raise Exception(f"Run failed. Status: {run.status}") + print(f"Run status: {run.status}") if __name__ == "__main__": diff --git a/examples/studio/assistant/async_assistant.py b/examples/studio/assistant/async_assistant.py index 19cf3d04..f0cf4b90 100644 --- a/examples/studio/assistant/async_assistant.py +++ b/examples/studio/assistant/async_assistant.py @@ -1,12 +1,8 @@ import asyncio -import time from ai21 import AsyncAI21Client -TIMEOUT = 20 - - async def main(): ai21_client = AsyncAI21Client() @@ -21,25 +17,19 @@ async def main(): ] ) - run = await ai21_client.beta.threads.runs.create( + run = await ai21_client.beta.threads.runs.create_and_poll( thread_id=thread.id, assistant_id=assistant.id, ) - start = time.time() - - while run.status == "in_progress": - run = await ai21_client.beta.threads.runs.retrieve(thread_id=thread.id, run_id=run.id) - if time.time() - start > TIMEOUT: - break - time.sleep(1) - 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)) - else: + elif run.status == "failed": raise Exception(f"Run failed. Status: {run.status}") + else: + print(f"Run status: {run.status}") if __name__ == "__main__": From 175c686cc457bdda0fe0650c1de92a51969b0eb5 Mon Sep 17 00:00:00 2001 From: guyl25 <144776634+guyl25@users.noreply.github.com> Date: Wed, 8 Jan 2025 09:51:58 +0200 Subject: [PATCH 33/50] feat: add submit_input method for thread run (#250) * feat: add submit_input method for thread run * fix: change gt to gte operator in poll_for_status * fix: add =None to optionals --- ai21/clients/common/beta/assistant/runs.py | 18 ++++++- .../resources/beta/assistant/thread_runs.py | 54 +++++++++++++++++-- ai21/models/assistant/run.py | 12 +++-- 3 files changed, 77 insertions(+), 7 deletions(-) diff --git a/ai21/clients/common/beta/assistant/runs.py b/ai21/clients/common/beta/assistant/runs.py index 77c9af4e..13131b16 100644 --- a/ai21/clients/common/beta/assistant/runs.py +++ b/ai21/clients/common/beta/assistant/runs.py @@ -1,7 +1,7 @@ from __future__ import annotations from abc import ABC, abstractmethod -from typing import List +from typing import Any, List from ai21.models.assistant.assistant import Optimization from ai21.models.assistant.run import ToolOutput @@ -85,3 +85,19 @@ def create_and_poll( **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/studio/resources/beta/assistant/thread_runs.py b/ai21/clients/studio/resources/beta/assistant/thread_runs.py index 19038cca..0ee5b217 100644 --- a/ai21/clients/studio/resources/beta/assistant/thread_runs.py +++ b/ai21/clients/studio/resources/beta/assistant/thread_runs.py @@ -2,7 +2,7 @@ import asyncio import time -from typing import List +from typing import Any, List from ai21.clients.common.beta.assistant.runs import BaseRuns from ai21.clients.studio.resources.studio_resource import StudioResource, AsyncStudioResource @@ -73,7 +73,7 @@ def _poll_for_status( if run.status in TERMINATED_RUN_STATUSES: return run - if (time.time() - start_time) > poll_timeout: + if (time.time() - start_time) >= poll_timeout: return run time.sleep(poll_interval) @@ -97,6 +97,30 @@ def create_and_poll( 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( @@ -156,7 +180,7 @@ async def _poll_for_status( if run.status in TERMINATED_RUN_STATUSES: return run - if (time.time() - start_time) > poll_timeout: + if (time.time() - start_time) >= poll_timeout: return run await asyncio.sleep(poll_interval) @@ -179,3 +203,27 @@ async def create_and_poll( 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_inputs", + 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/models/assistant/run.py b/ai21/models/assistant/run.py index 850cf765..715488e3 100644 --- a/ai21/models/assistant/run.py +++ b/ai21/models/assistant/run.py @@ -1,4 +1,4 @@ -from typing import Literal, Any, List, Set +from typing import Dict, Literal, Any, List, Set, Optional from typing_extensions import TypedDict @@ -40,6 +40,12 @@ class SubmitToolCallOutputs(TypedDict): tool_calls: List[ToolOutput] +class SubmitInput(TypedDict): + event_name: str + data: Dict[str, Any] + + class RequiredAction(TypedDict): - type: Literal["submit_tool_outputs"] - submit_tool_outputs: SubmitToolCallOutputs + type: Literal["submit_tool_outputs", "submit_input"] + submit_tool_outputs: Optional[SubmitToolCallOutputs] = None + submit_input: Optional[SubmitInput] = None From 4327dbbd38dcf1dead95eda3dcc88f0e03aedd70 Mon Sep 17 00:00:00 2001 From: semantic-release Date: Wed, 8 Jan 2025 09:15:11 +0000 Subject: [PATCH 34/50] chore(release): v3.1.0-rc.4 [skip ci] --- CHANGELOG.md | 2485 +++++++++++++++++++++++------------------------ ai21/version.py | 2 +- pyproject.toml | 2 +- 3 files changed, 1226 insertions(+), 1263 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d36e9be3..b1f61aaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,28 +1,165 @@ # CHANGELOG -## v3.1.0-rc.3 (2024-12-26) +## v3.1.0-rc.4 (2025-01-08) + +### Chores -### Fixes +- Add `error` to `RunResponse` model ([#248](https://github.com/AI21Labs/ai21-python/pull/248), + [`787d7d3`](https://github.com/AI21Labs/ai21-python/commit/787d7d3f5d612106dcd55f35894953564ce4fd2d)) -* fix: not given as a constant not class (#244) ([`5782127`](https://github.com/AI21Labs/ai21-python/commit/5782127fbc805b68345ba68de2508a94306f50f4)) +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)) -## v3.1.0-rc.2 (2024-12-22) +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> + +### 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 + +- Logger to be local ([#235](https://github.com/AI21Labs/ai21-python/pull/235), + [`689c987`](https://github.com/AI21Labs/ai21-python/commit/689c98758d02e713b44b9756c74b158ed3974389)) ### Chores -* chore(release): v3.1.0-rc.2 [skip ci] ([`5deee97`](https://github.com/AI21Labs/ai21-python/commit/5deee97bfdf97e7e15203c2267983c55e695cfde)) +- **deps**: Bump python-semantic-release/python-semantic-release + ([#230](https://github.com/AI21Labs/ai21-python/pull/230), + [`276653e`](https://github.com/AI21Labs/ai21-python/commit/276653eb795f2a553c0aedf23de1f9d29a4af792)) -* chore: :truck: rename `internet_research` to `web_search` (#241) +Bumps + [python-semantic-release/python-semantic-release](https://github.com/python-semantic-release/python-semantic-release) + from 9.10.1 to 9.14.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.10.1...v9.14.0) -EXEC-470 +--- 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> -Co-authored-by: benshuk ([`770c6c5`](https://github.com/AI21Labs/ai21-python/commit/770c6c51fd7ea287d2485a3048fe748db5b636b3)) +- **release**: V3.0.1 [skip ci] + ([`4d42360`](https://github.com/AI21Labs/ai21-python/commit/4d42360564d73f1045b9f7cf98bc47938a813fc7)) -### Fixes -* fix: Adapt assistant sdk to hlp (#242) +## 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 @@ -38,417 +175,502 @@ Co-authored-by: benshuk ([`770c6c5`](https://github.com/AI21Labs * fix: adapt code to 3.8 -* fix: adapt code to 3.8 - -* fix: support model schemas of python 3.11 - * fix: support model schemas of python 3.11 * fix: PR comments -* fix: PR comments +* fix: add user defined plan example to integration tests -* fix: add user defined plan example to integration tests ([`78c58d5`](https://github.com/AI21Labs/ai21-python/commit/78c58d588b91f64bebd53445a1585b008011afe7)) +### 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)) -## v3.1.0-rc.1 (2024-12-04) +EXEC-470 -### Chores +Co-authored-by: benshuk -* chore(release): v3.1.0-rc.1 [skip ci] ([`3bdad90`](https://github.com/AI21Labs/ai21-python/commit/3bdad90a0dd7ac5e7ace2acdea58d18cf6b6599b)) +- **release**: V3.1.0-rc.2 [skip ci] + ([`5deee97`](https://github.com/AI21Labs/ai21-python/commit/5deee97bfdf97e7e15203c2267983c55e695cfde)) -* chore(deps): bump pypa/gh-action-pypi-publish from 1.10.3 to 1.12.2 (#227) -Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.10.3 to 1.12.2. -- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) -- [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/f7600683efdcb7656dec5b29656edb7bc586e597...15c56dba361d8335944d31a2ecd17d700fc7bcbc) +## v3.1.0-rc.1 (2024-12-04) ---- -updated-dependencies: -- dependency-name: pypa/gh-action-pypi-publish - dependency-type: direct:production - update-type: version-update:semver-minor -... +### Bug Fixes -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> ([`4247632`](https://github.com/AI21Labs/ai21-python/commit/4247632694cee72baf6208ff61a806611a5f2ebe)) +- :bug: pr fixes + ([`c46e517`](https://github.com/AI21Labs/ai21-python/commit/c46e517cfd8619e4cb25581f5e714ee8fc919e47)) -### Features +- :bug: pr fixes + ([`dd7d71d`](https://github.com/AI21Labs/ai21-python/commit/dd7d71d82eda94ef2a72fdb1492015d57444bf4e)) -* feat: :sparkles: add support for `Plan` and `Route` resources (#238) +- :bug: use `List` for typing instead of `list` + ([`fc45f19`](https://github.com/AI21Labs/ai21-python/commit/fc45f19027b9f21cbf3c711952a6b1ddc3db932c)) -* feat: :sparkles: add support for Plan resource +- :bug: use `List` for typing instead of `list` + ([`3128145`](https://github.com/AI21Labs/ai21-python/commit/3128145a85283c8f7ed0984fffee7febb32f3ae0)) -* feat: :sparkles: add support for Route resource +- :green_heart: imports + ([`a9f7d67`](https://github.com/AI21Labs/ai21-python/commit/a9f7d67feaa088ffa97f87220e3198cf0d5eb0b3)) -* fix: :label: List instead of list +- :green_heart: imports + ([`f9e695b`](https://github.com/AI21Labs/ai21-python/commit/f9e695bd5e51b49ade8342cb4796cf2b1b97e630)) -* refactor: :truck: rename classes and files +- :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)) -Co-authored-by: benshuk ([`f1f5cbc`](https://github.com/AI21Labs/ai21-python/commit/f1f5cbccb894fdd2ccb8680376801cd9c9bc4391)) +- :label: remove `Model` Literal typing + ([`90f44f5`](https://github.com/AI21Labs/ai21-python/commit/90f44f575b3031f4b11edcbc6e9fef4a8b2e1c62)) -* feat: ✨ add support for Run resource (#236) +- :label: remove `Model` Literal typing + ([`17af071`](https://github.com/AI21Labs/ai21-python/commit/17af071f1a8d3dc7913ee7922884eedf1468f157)) -* feat: :sparkles: add support for Run resource +- :label: tool_resources use type + ([`5de2d8c`](https://github.com/AI21Labs/ai21-python/commit/5de2d8c0af03b7e1fb95bf7302422374e0d77954)) -* fix: :label: typing backwards compatability +- :label: tool_resources use type + ([`c8ee041`](https://github.com/AI21Labs/ai21-python/commit/c8ee04176eeb3cf70591048a7fcf516dab99c5f4)) -* refactor: :truck: rename classes & types and such +- :truck: move classes and such + ([`c944172`](https://github.com/AI21Labs/ai21-python/commit/c944172571e10452b93542944794e6bcaeaff2c7)) -* refactor: :fire: remove `avatar` option +- :truck: rename `get` method to `retrieve` + ([`d2747a5`](https://github.com/AI21Labs/ai21-python/commit/d2747a56169c8c68cd9701291fab72509835f830)) -* fix: :label: typing yay +- :truck: rename classes and such + ([`ae7a3e4`](https://github.com/AI21Labs/ai21-python/commit/ae7a3e40dd13c3feb0b41af8bbef3ed4b2490ca9)) -* feat: :sparkles: add examples +### Chores -* fix: :label: make `description` optional +- **deps**: Bump pypa/gh-action-pypi-publish from 1.10.3 to 1.12.2 + ([#227](https://github.com/AI21Labs/ai21-python/pull/227), + [`4247632`](https://github.com/AI21Labs/ai21-python/commit/4247632694cee72baf6208ff61a806611a5f2ebe)) -* docs: :memo: add assistants info to README +Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.10.3 to + 1.12.2. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - + [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/f7600683efdcb7656dec5b29656edb7bc586e597...15c56dba361d8335944d31a2ecd17d700fc7bcbc) -also, add examples +--- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: + direct:production -* test: :white_check_mark: add assistants to tests +update-type: version-update:semver-minor -* docs: :memo: update docs about Assistants +... -* docs: :memo: better example +Signed-off-by: dependabot[bot] -* chore: :truck: move files +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> -* docs: :memo: examples fixes +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)) -Co-authored-by: benshuk ([`d4beb22`](https://github.com/AI21Labs/ai21-python/commit/d4beb227242d6e2055f1279b6ba9f453a5c0233b)) +### Features -* feat: :sparkles: add support for Message resource ([`b483e70`](https://github.com/AI21Labs/ai21-python/commit/b483e704743a2d9e8fbd5da99f97bf348263a4d5)) +- :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 Thread resource ([`62566cd`](https://github.com/AI21Labs/ai21-python/commit/62566cd1fd0b42bfcd181ebb5b5032e62a15730b)) +* feat: :sparkles: add support for Plan resource -* feat: :sparkles: add support for Assistant resource +* feat: :sparkles: add support for Route resource -under `beta` ([`16ef903`](https://github.com/AI21Labs/ai21-python/commit/16ef9038dc50f4c7731953bdc51073ba45655b03)) +* fix: :label: List instead of list -* feat: :sparkles: add support for Assistant resource +* refactor: :truck: rename classes and files -under `beta` ([`4b31a42`](https://github.com/AI21Labs/ai21-python/commit/4b31a42351d42b6604a9b05ea9bc0b19413d91d8)) +--------- -### Fixes +Co-authored-by: benshuk -* fix: :truck: rename `get` method to `retrieve` ([`d2747a5`](https://github.com/AI21Labs/ai21-python/commit/d2747a56169c8c68cd9701291fab72509835f830)) +- :sparkles: add support for Assistant resource + ([`16ef903`](https://github.com/AI21Labs/ai21-python/commit/16ef9038dc50f4c7731953bdc51073ba45655b03)) -* fix: :truck: move classes and such ([`c944172`](https://github.com/AI21Labs/ai21-python/commit/c944172571e10452b93542944794e6bcaeaff2c7)) +under `beta` -* fix: :truck: rename classes and such ([`ae7a3e4`](https://github.com/AI21Labs/ai21-python/commit/ae7a3e40dd13c3feb0b41af8bbef3ed4b2490ca9)) +- :sparkles: add support for Assistant resource + ([`4b31a42`](https://github.com/AI21Labs/ai21-python/commit/4b31a42351d42b6604a9b05ea9bc0b19413d91d8)) -* fix: :green_heart: imports ([`a9f7d67`](https://github.com/AI21Labs/ai21-python/commit/a9f7d67feaa088ffa97f87220e3198cf0d5eb0b3)) +under `beta` -* fix: :label: tool_resources use type ([`5de2d8c`](https://github.com/AI21Labs/ai21-python/commit/5de2d8c0af03b7e1fb95bf7302422374e0d77954)) +- :sparkles: add support for Message resource + ([`b483e70`](https://github.com/AI21Labs/ai21-python/commit/b483e704743a2d9e8fbd5da99f97bf348263a4d5)) -* fix: :label: remove `Model` Literal typing ([`90f44f5`](https://github.com/AI21Labs/ai21-python/commit/90f44f575b3031f4b11edcbc6e9fef4a8b2e1c62)) +- :sparkles: add support for Thread resource + ([`62566cd`](https://github.com/AI21Labs/ai21-python/commit/62566cd1fd0b42bfcd181ebb5b5032e62a15730b)) -* fix: :bug: pr fixes ([`c46e517`](https://github.com/AI21Labs/ai21-python/commit/c46e517cfd8619e4cb25581f5e714ee8fc919e47)) +- ✨ add support for Run resource ([#236](https://github.com/AI21Labs/ai21-python/pull/236), + [`d4beb22`](https://github.com/AI21Labs/ai21-python/commit/d4beb227242d6e2055f1279b6ba9f453a5c0233b)) -* fix: :label: better typing & remove doc string ([`18d0092`](https://github.com/AI21Labs/ai21-python/commit/18d009202b64a41e70c9824fa14256e4c741606f)) +* feat: :sparkles: add support for Run resource -* fix: :bug: use `List` for typing instead of `list` ([`fc45f19`](https://github.com/AI21Labs/ai21-python/commit/fc45f19027b9f21cbf3c711952a6b1ddc3db932c)) +* fix: :label: typing backwards compatability -* fix: :green_heart: imports ([`f9e695b`](https://github.com/AI21Labs/ai21-python/commit/f9e695bd5e51b49ade8342cb4796cf2b1b97e630)) +* refactor: :truck: rename classes & types and such -* fix: :label: tool_resources use type ([`c8ee041`](https://github.com/AI21Labs/ai21-python/commit/c8ee04176eeb3cf70591048a7fcf516dab99c5f4)) +* refactor: :fire: remove `avatar` option -* fix: :label: remove `Model` Literal typing ([`17af071`](https://github.com/AI21Labs/ai21-python/commit/17af071f1a8d3dc7913ee7922884eedf1468f157)) +* fix: :label: typing yay -* fix: :bug: pr fixes ([`dd7d71d`](https://github.com/AI21Labs/ai21-python/commit/dd7d71d82eda94ef2a72fdb1492015d57444bf4e)) +* feat: :sparkles: add examples -* fix: :label: better typing & remove doc string ([`a03deab`](https://github.com/AI21Labs/ai21-python/commit/a03deab60a4a4be43a3211959a16c4ea132bf63f)) +* fix: :label: make `description` optional -* fix: :bug: use `List` for typing instead of `list` ([`3128145`](https://github.com/AI21Labs/ai21-python/commit/3128145a85283c8f7ed0984fffee7febb32f3ae0)) +* docs: :memo: add assistants info to README -### Refactoring +also, add examples -* refactor: :art: reformat functions with 2+ arguments ([`a8c345e`](https://github.com/AI21Labs/ai21-python/commit/a8c345e81f2b29dd14e5ec118d5f4068792198df)) +* test: :white_check_mark: add assistants to tests -* refactor: :truck: move `MessageResponse` type to a separate file ([`151f5ac`](https://github.com/AI21Labs/ai21-python/commit/151f5acfa2d83fccb8b9bc459fce761324542ce5)) +* docs: :memo: update docs about Assistants -### Unknown +* docs: :memo: better example -* Merge pull request #234 from AI21Labs/messages +* chore: :truck: move files -feat: :sparkles: add support for Message resource ([`abcc2f9`](https://github.com/AI21Labs/ai21-python/commit/abcc2f9fc465244f35ae11cf6cd910f03016a722)) +* docs: :memo: examples fixes -* Merge pull request #232 from AI21Labs/threads +--------- -feat: :sparkles: add support for Thread resource ([`29fb8ce`](https://github.com/AI21Labs/ai21-python/commit/29fb8ce68a48ce94196059eadd0664726e59207a)) +Co-authored-by: benshuk -* Merge remote-tracking branch 'origin/rc_assistant_api_support' into rc_assistant_api_support ([`2cf1a85`](https://github.com/AI21Labs/ai21-python/commit/2cf1a85950dd6b52dc1ded2606cef21fe358f224)) +### Refactoring -* Merge pull request #231 from AI21Labs/assistant +- :art: reformat functions with 2+ arguments + ([`a8c345e`](https://github.com/AI21Labs/ai21-python/commit/a8c345e81f2b29dd14e5ec118d5f4068792198df)) -feat: :sparkles: add support for Assistant resource ([`139887d`](https://github.com/AI21Labs/ai21-python/commit/139887d99edf8d8fb23e43e40511cb5b6753d577)) +- :truck: move `MessageResponse` type to a separate file + ([`151f5ac`](https://github.com/AI21Labs/ai21-python/commit/151f5acfa2d83fccb8b9bc459fce761324542ce5)) ## v3.0.0 (2024-11-11) -### Breaking - -* feat!: BREAKING CHANGE: Version v3.0.0 (#229) ([`53bac6c`](https://github.com/AI21Labs/ai21-python/commit/53bac6c0b373b196fabe38f133213ac9d24e7e73)) - ### Chores -* chore(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)) -* chore(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 -* feat: Sunset tsms and j2 (#225) +- Breaking CHANGE: Version v3.0.0 ([#229](https://github.com/AI21Labs/ai21-python/pull/229), + [`53bac6c`](https://github.com/AI21Labs/ai21-python/commit/53bac6c0b373b196fabe38f133213ac9d24e7e73)) -feat!: Removed Legacy TSM Models ([`b39c92c`](https://github.com/AI21Labs/ai21-python/commit/b39c92cfbdc88c9f98f3d5bfb20aa850f6211b78)) +- Sunset tsms and j2 ([#225](https://github.com/AI21Labs/ai21-python/pull/225), + [`b39c92c`](https://github.com/AI21Labs/ai21-python/commit/b39c92cfbdc88c9f98f3d5bfb20aa850f6211b78)) + +feat!: Removed Legacy TSM Models + +### BREAKING CHANGES + +- Version v3.0.0 (#229) ## v2.15.2 (2024-11-05) +### Bug Fixes + +- Adding depracation warning to all TSMs, custom models and datasets + ([#223](https://github.com/AI21Labs/ai21-python/pull/223), + [`155c6a9`](https://github.com/AI21Labs/ai21-python/commit/155c6a9b008cfe0f52a10a2d30324d42f07bc2a5)) + ### Chores -* chore(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)) -* chore(deps): bump pypa/gh-action-pypi-publish from 1.10.1 to 1.10.3 (#216) +Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.10.1 to + 1.10.3. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - + [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/0ab0b79471669eb3a4d647e625009c62f9f3b241...f7600683efdcb7656dec5b29656edb7bc586e597) -Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.10.1 to 1.10.3. -- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) -- [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 ---- -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> -Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> ([`5de5ae5`](https://github.com/AI21Labs/ai21-python/commit/5de5ae5cc3a42726b525e6956d61bd8bfefbc0cb)) -* chore(deps): bump python-semantic-release/python-semantic-release (#218) +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), + [`cc4a26c`](https://github.com/AI21Labs/ai21-python/commit/cc4a26c528517aceb32322ed090cb83cec1fa72a)) -Bumps [python-semantic-release/python-semantic-release](https://github.com/python-semantic-release/python-semantic-release) from 9.8.8 to 9.10.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.8.8...v9.10.1) +Bumps + [python-semantic-release/python-semantic-release](https://github.com/python-semantic-release/python-semantic-release) + from 9.8.8 to 9.10.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.8.8...v9.10.1) ---- -updated-dependencies: -- dependency-name: python-semantic-release/python-semantic-release +--- updated-dependencies: - dependency-name: python-semantic-release/python-semantic-release dependency-type: direct:production - update-type: version-update:semver-minor + +update-type: version-update:semver-minor + ... Signed-off-by: dependabot[bot] -Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> ([`cc4a26c`](https://github.com/AI21Labs/ai21-python/commit/cc4a26c528517aceb32322ed090cb83cec1fa72a)) -### Fixes +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> -* fix: adding depracation warning to all TSMs, custom models and datasets (#223) ([`155c6a9`](https://github.com/AI21Labs/ai21-python/commit/155c6a9b008cfe0f52a10a2d30324d42f07bc2a5)) +- **release**: V2.15.2 [skip ci] + ([`b94594f`](https://github.com/AI21Labs/ai21-python/commit/b94594f70a68223059505c712fea54111145cd50)) ## v2.15.1 (2024-09-30) +### Bug Fixes + +- Removed unnecessary urls ([#213](https://github.com/AI21Labs/ai21-python/pull/213), + [`8562e86`](https://github.com/AI21Labs/ai21-python/commit/8562e86f611a3ca49d78bbd82b6c6f5962265613)) + ### Chores -* chore(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)) -* chore(deps): bump pypa/gh-action-pypi-publish from 1.10.0 to 1.10.1 (#210) +Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.10.0 to + 1.10.1. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - + [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/8a08d616893759ef8e1aa1f2785787c0b97e20d6...0ab0b79471669eb3a4d647e625009c62f9f3b241) -Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.10.0 to 1.10.1. -- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) -- [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 ---- -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> -Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> ([`6da18da`](https://github.com/AI21Labs/ai21-python/commit/6da18da7dd9c104092161f435e3c39432e04f095)) -### Fixes +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> -* fix: Removed unnecessary urls (#213) ([`8562e86`](https://github.com/AI21Labs/ai21-python/commit/8562e86f611a3ca49d78bbd82b6c6f5962265613)) +- **release**: V2.15.1 [skip ci] + ([`d31badb`](https://github.com/AI21Labs/ai21-python/commit/d31badbaf2b688b216317967b2d85fbad986c1b0)) ## v2.15.0 (2024-09-24) ### Chores -* chore(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)) + +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) -* chore(deps-dev): bump cryptography from 42.0.7 to 43.0.1 (#209) +--- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: + direct:production -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) +update-type: version-update:semver-minor ---- -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> ([`e811d74`](https://github.com/AI21Labs/ai21-python/commit/e811d74bfb067546f7e1873a273896b4747a7d57)) -* chore(deps): bump python-semantic-release/python-semantic-release (#207) +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), + [`37cfc24`](https://github.com/AI21Labs/ai21-python/commit/37cfc244ca3989718fea80ab02360ec78d4343f3)) -Bumps [python-semantic-release/python-semantic-release](https://github.com/python-semantic-release/python-semantic-release) from 9.8.7 to 9.8.8. -- [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.7...v9.8.8) +Bumps + [python-semantic-release/python-semantic-release](https://github.com/python-semantic-release/python-semantic-release) + from 9.8.7 to 9.8.8. - [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.7...v9.8.8) ---- -updated-dependencies: -- dependency-name: python-semantic-release/python-semantic-release +--- updated-dependencies: - dependency-name: python-semantic-release/python-semantic-release dependency-type: direct:production - update-type: version-update:semver-patch + +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> ([`37cfc24`](https://github.com/AI21Labs/ai21-python/commit/37cfc244ca3989718fea80ab02360ec78d4343f3)) -* chore(deps): bump pypa/gh-action-pypi-publish from 1.9.0 to 1.10.0 (#208) +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 [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: cryptography dependency-type: indirect ---- -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> ([`6bec329`](https://github.com/AI21Labs/ai21-python/commit/6bec329d453b969f721c5a27d1459fe2cbdea9a7)) + +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 -* feat: Bedrock model id support for jamba-1.5 (#212) +- Bedrock model id support for jamba-1.5 ([#212](https://github.com/AI21Labs/ai21-python/pull/212), + [`2eda23f`](https://github.com/AI21Labs/ai21-python/commit/2eda23f1aedcd65671554aff93e3feaf929cb903)) * feat: Bedrock model id support for jamba-1.5 -* fix: Bedrock examples ([`2eda23f`](https://github.com/AI21Labs/ai21-python/commit/2eda23f1aedcd65671554aff93e3feaf929cb903)) +* fix: Bedrock examples ## v2.14.1 (2024-08-26) -### Chores +### Bug Fixes -* chore(release): v2.14.1 [skip ci] ([`2816660`](https://github.com/AI21Labs/ai21-python/commit/28166609752483988974c089e6eb09a7bf82f48c)) +- Bug fixes - embed, streaming response, request retry rename + ([#206](https://github.com/AI21Labs/ai21-python/pull/206), + [`882de79`](https://github.com/AI21Labs/ai21-python/commit/882de79241239dc0068d7619dbed326fe13cc6b1)) -### Fixes +Co-authored-by: Paz Shalev -* fix: Bug fixes - embed, streaming response, request retry rename (#206) +### Chores -Co-authored-by: Paz Shalev ([`882de79`](https://github.com/AI21Labs/ai21-python/commit/882de79241239dc0068d7619dbed326fe13cc6b1)) +- **release**: V2.14.1 [skip ci] + ([`2816660`](https://github.com/AI21Labs/ai21-python/commit/28166609752483988974c089e6eb09a7bf82f48c)) ## v2.14.0 (2024-08-22) -### Chores +### Bug Fixes -* chore(release): v2.14.0 [skip ci] ([`307cfc6`](https://github.com/AI21Labs/ai21-python/commit/307cfc6f78355515acc9949de65a89bac7279db0)) +- Example text ([#205](https://github.com/AI21Labs/ai21-python/pull/205), + [`e526c53`](https://github.com/AI21Labs/ai21-python/commit/e526c533129dd3d279e0b3e2866298683cfbd693)) -### Features +### Chores -* feat: add vertex support (#182) ([`0c7a32d`](https://github.com/AI21Labs/ai21-python/commit/0c7a32df521c23443cd1a5a64b15a4429e0f57a7)) +- **release**: V2.14.0 [skip ci] + ([`307cfc6`](https://github.com/AI21Labs/ai21-python/commit/307cfc6f78355515acc9949de65a89bac7279db0)) -### Fixes +### Features -* fix: example text (#205) ([`e526c53`](https://github.com/AI21Labs/ai21-python/commit/e526c533129dd3d279e0b3e2866298683cfbd693)) +- Add vertex support ([#182](https://github.com/AI21Labs/ai21-python/pull/182), + [`0c7a32d`](https://github.com/AI21Labs/ai21-python/commit/0c7a32df521c23443cd1a5a64b15a4429e0f57a7)) ## v2.13.0 (2024-08-21) ### Chores -* chore(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)) -* chore(deps): bump python-semantic-release/python-semantic-release (#204) +Bumps + [python-semantic-release/python-semantic-release](https://github.com/python-semantic-release/python-semantic-release) + from 9.8.6 to 9.8.7. - [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.6...v9.8.7) -Bumps [python-semantic-release/python-semantic-release](https://github.com/python-semantic-release/python-semantic-release) from 9.8.6 to 9.8.7. -- [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.6...v9.8.7) - ---- -updated-dependencies: -- dependency-name: python-semantic-release/python-semantic-release +--- updated-dependencies: - dependency-name: python-semantic-release/python-semantic-release dependency-type: direct:production - update-type: version-update:semver-patch + +update-type: version-update:semver-patch + ... Signed-off-by: dependabot[bot] -Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> ([`82d3abe`](https://github.com/AI21Labs/ai21-python/commit/82d3abece58b95818505c51707145c4410dfe4d6)) + +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 -* docs: Fixed Conversational RAG README (#199) +- Fixed Conversational RAG README ([#199](https://github.com/AI21Labs/ai21-python/pull/199), + [`e20978a`](https://github.com/AI21Labs/ai21-python/commit/e20978a8917e98a9b2ba86d11f6544d277201698)) * docs: README for RAG -* docs: Added link ([`e20978a`](https://github.com/AI21Labs/ai21-python/commit/e20978a8917e98a9b2ba86d11f6544d277201698)) +* docs: Added link ### Features -* feat: Jamba 1.5 Support (#203) ([`6c131ac`](https://github.com/AI21Labs/ai21-python/commit/6c131ac67896ed827ca55c65a119bf0736812d58)) +- Jamba 1.5 Support ([#203](https://github.com/AI21Labs/ai21-python/pull/203), + [`6c131ac`](https://github.com/AI21Labs/ai21-python/commit/6c131ac67896ed827ca55c65a119bf0736812d58)) ## v2.12.0 (2024-08-07) ### Chores -* chore(release): v2.12.0 [skip ci] ([`38430ad`](https://github.com/AI21Labs/ai21-python/commit/38430ad46686ce94b40d66991598dae67a3dbdd8)) +- **release**: V2.12.0 [skip ci] + ([`38430ad`](https://github.com/AI21Labs/ai21-python/commit/38430ad46686ce94b40d66991598dae67a3dbdd8)) ### Features -* feat: :sparkles: add conversational RAG resource (#198) ([`fca3729`](https://github.com/AI21Labs/ai21-python/commit/fca372988e62c09e6ae03d6cc91ab83f62db2fd9)) +- :sparkles: add conversational RAG resource + ([#198](https://github.com/AI21Labs/ai21-python/pull/198), + [`fca3729`](https://github.com/AI21Labs/ai21-python/commit/fca372988e62c09e6ae03d6cc91ab83f62db2fd9)) ## v2.11.0 (2024-08-06) ### Chores -* chore(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)) -* chore(deps): bump python-semantic-release/python-semantic-release (#190) +Bumps + [python-semantic-release/python-semantic-release](https://github.com/python-semantic-release/python-semantic-release) + from 9.8.5 to 9.8.6. - [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.5...v9.8.6) -Bumps [python-semantic-release/python-semantic-release](https://github.com/python-semantic-release/python-semantic-release) from 9.8.5 to 9.8.6. -- [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.5...v9.8.6) - ---- -updated-dependencies: -- dependency-name: python-semantic-release/python-semantic-release +--- updated-dependencies: - dependency-name: python-semantic-release/python-semantic-release dependency-type: direct:production - update-type: version-update:semver-patch + +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> ([`0c7622b`](https://github.com/AI21Labs/ai21-python/commit/0c7622b138a76bf74f509749b38ae228c761f894)) + +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 -* feat: add stream support for Bedrock (#191) +- Add stream support for Bedrock ([#191](https://github.com/AI21Labs/ai21-python/pull/191), + [`5392b52`](https://github.com/AI21Labs/ai21-python/commit/5392b5260da9ee0be00b1d9afe35d175cbfaf3e5)) * feat: add stream support for bedrock @@ -470,94 +692,110 @@ Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.co * refactor: async stream example -* refactor: cr comments - --------- -Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> ([`5392b52`](https://github.com/AI21Labs/ai21-python/commit/5392b5260da9ee0be00b1d9afe35d175cbfaf3e5)) +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> ## v2.10.1 (2024-07-31) -### Chores +### Bug Fixes -* chore(release): v2.10.1 [skip ci] ([`c0050f4`](https://github.com/AI21Labs/ai21-python/commit/c0050f474d84853676ccbde17e71fc4419b86334)) +- Env ([#197](https://github.com/AI21Labs/ai21-python/pull/197), + [`525c1ef`](https://github.com/AI21Labs/ai21-python/commit/525c1ef4cdd593eca62ae16eddda6db72a36dbcf)) -### Continuous Integration +- Remove redundant dependency - dataclass json + ([#194](https://github.com/AI21Labs/ai21-python/pull/194), + [`e8dcd27`](https://github.com/AI21Labs/ai21-python/commit/e8dcd27e2883b4e60cbb4f4d7505309f4a963a6c)) -* ci: Fix label swap syntax (#196) +* fix: remove redundant dependency - dataclass json -* ci: Added quotes +* chore: use j2 ultra in examples -* ci: Read from env ([`a31233b`](https://github.com/AI21Labs/ai21-python/commit/a31233b385918a1118ed70c683b6850bf8667ab9)) +* test: use j2 ultra in completion tests -* ci: fix size labeler (#195) ([`1247b81`](https://github.com/AI21Labs/ai21-python/commit/1247b81bc7b02952f6ee87fbe1249bdb6cecd8da)) +--------- -### Fixes +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> -* fix: remove redundant dependency - dataclass json (#194) +### Chores -* fix: remove redundant dependency - dataclass json +- **release**: V2.10.1 [skip ci] + ([`c0050f4`](https://github.com/AI21Labs/ai21-python/commit/c0050f474d84853676ccbde17e71fc4419b86334)) -* chore: use j2 ultra in examples +### Continuous Integration -* test: use j2 ultra in completion tests +- Fix label swap syntax ([#196](https://github.com/AI21Labs/ai21-python/pull/196), + [`a31233b`](https://github.com/AI21Labs/ai21-python/commit/a31233b385918a1118ed70c683b6850bf8667ab9)) ---------- +* ci: Added quotes -Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> ([`e8dcd27`](https://github.com/AI21Labs/ai21-python/commit/e8dcd27e2883b4e60cbb4f4d7505309f4a963a6c)) +* ci: Read from env -* fix: env (#197) ([`525c1ef`](https://github.com/AI21Labs/ai21-python/commit/525c1ef4cdd593eca62ae16eddda6db72a36dbcf)) +- Fix size labeler ([#195](https://github.com/AI21Labs/ai21-python/pull/195), + [`1247b81`](https://github.com/AI21Labs/ai21-python/commit/1247b81bc7b02952f6ee87fbe1249bdb6cecd8da)) ## v2.10.0 (2024-07-29) ### Chores -* chore(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) -* chore(deps-dev): bump setuptools from 69.5.1 to 70.0.0 (#186) +--- updated-dependencies: - dependency-name: python-semantic-release/python-semantic-release + dependency-type: direct:production -Bumps [setuptools](https://github.com/pypa/setuptools) from 69.5.1 to 70.0.0. -- [Release notes](https://github.com/pypa/setuptools/releases) -- [Changelog](https://github.com/pypa/setuptools/blob/main/NEWS.rst) -- [Commits](https://github.com/pypa/setuptools/compare/v69.5.1...v70.0.0) +update-type: version-update:semver-patch ---- -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> ([`51b59f8`](https://github.com/AI21Labs/ai21-python/commit/51b59f8eb166be299076d23fe646a292aa151f51)) -* chore(deps): bump python-semantic-release/python-semantic-release (#179) +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> -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) +- **deps-dev**: Bump setuptools from 69.5.1 to 70.0.0 + ([#186](https://github.com/AI21Labs/ai21-python/pull/186), + [`51b59f8`](https://github.com/AI21Labs/ai21-python/commit/51b59f8eb166be299076d23fe646a292aa151f51)) + +Bumps [setuptools](https://github.com/pypa/setuptools) from 69.5.1 to 70.0.0. - [Release + notes](https://github.com/pypa/setuptools/releases) - + [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: 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> ([`2175f81`](https://github.com/AI21Labs/ai21-python/commit/2175f81c29e8fcaac8ff2dfb67af2b4f0aceead7)) + +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 -* docs: fix base url for azure (#188) ([`bb84d35`](https://github.com/AI21Labs/ai21-python/commit/bb84d351fdda13b57617a6fc3fc5a12bce2d9528)) +- Fix base url for azure ([#188](https://github.com/AI21Labs/ai21-python/pull/188), + [`bb84d35`](https://github.com/AI21Labs/ai21-python/commit/bb84d351fdda13b57617a6fc3fc5a12bce2d9528)) ### Features -* feat: Pydantic Migration (#193) +- Pydantic Migration ([#193](https://github.com/AI21Labs/ai21-python/pull/193), + [`135ea43`](https://github.com/AI21Labs/ai21-python/commit/135ea43e75f3692f966c2263c25b4b9c7c343b81)) * feat: Pydantic migration (#189) @@ -579,13 +817,8 @@ Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.co * refactor: ci comments, use to_*, and from_* funcs internally -* 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 +* refactor: ci comments, attach alias by field, create private functions for serialization, add + deprecation warning * test: fix tests @@ -597,252 +830,212 @@ Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.co --------- -Co-authored-by: semantic-release ([`135ea43`](https://github.com/AI21Labs/ai21-python/commit/135ea43e75f3692f966c2263c25b4b9c7c343b81)) +Co-authored-by: semantic-release ## v2.9.2 (2024-07-15) -### Chores - -* chore(release): v2.9.2 [skip ci] ([`30d9947`](https://github.com/AI21Labs/ai21-python/commit/30d9947b500e3c5d39858b187fc1f6d5c7a98916)) - -### Fixes +### Bug Fixes -* fix: fix default for require_api_key in http client and other clients (#185) +- Fix default for require_api_key in http client and other clients + ([#185](https://github.com/AI21Labs/ai21-python/pull/185), + [`e6b305e`](https://github.com/AI21Labs/ai21-python/commit/e6b305edc8ed36c722cc359f499c764e05248b95)) * fix: fix default for require_api_key in http client and other clients * test: fix unittests -* test: add ai21 azure client ([`e6b305e`](https://github.com/AI21Labs/ai21-python/commit/e6b305edc8ed36c722cc359f499c764e05248b95)) +* test: add ai21 azure client +### Chores -## v2.9.1 (2024-07-10) +- **release**: V2.9.2 [skip ci] + ([`30d9947`](https://github.com/AI21Labs/ai21-python/commit/30d9947b500e3c5d39858b187fc1f6d5c7a98916)) -### Chores -* chore(release): v2.9.1 [skip ci] ([`5ed7f07`](https://github.com/AI21Labs/ai21-python/commit/5ed7f07e677ce60eb960991f3c601869d4e2c68c)) +## v2.9.1 (2024-07-10) + +### Bug Fixes -* chore(deps-dev): bump zipp from 3.18.1 to 3.19.1 (#183) +- Remove httpx logger on log level info ([#184](https://github.com/AI21Labs/ai21-python/pull/184), + [`06d0226`](https://github.com/AI21Labs/ai21-python/commit/06d02261c187a4bda1b5d479855d17b5a1507a1d)) -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) +### Chores ---- -updated-dependencies: -- dependency-name: zipp - dependency-type: indirect -... +- **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] -Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> ([`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) -* chore(deps): bump certifi from 2024.2.2 to 2024.7.4 (#176) +--- updated-dependencies: - dependency-name: amannn/action-semantic-pull-request dependency-type: + direct:production -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) +update-type: version-update:semver-patch ---- -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> ([`f5e1814`](https://github.com/AI21Labs/ai21-python/commit/f5e18140ffd289be8d3e5afa2e0c5352a0beb1cd)) -* chore(deps): bump amannn/action-semantic-pull-request (#154) +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), + [`f5e1814`](https://github.com/AI21Labs/ai21-python/commit/f5e18140ffd289be8d3e5afa2e0c5352a0beb1cd)) -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 [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: amannn/action-semantic-pull-request - 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> ([`e57d99a`](https://github.com/AI21Labs/ai21-python/commit/e57d99a04ff4b6aa4a858a2fe87f8cc8c68bcfa0)) -### Fixes +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> -* fix: remove httpx logger on log level info (#184) ([`06d0226`](https://github.com/AI21Labs/ai21-python/commit/06d02261c187a4bda1b5d479855d17b5a1507a1d)) +- **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)) -### Unknown +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) -* Securely use variables in labeler workflow. (#181) +--- updated-dependencies: - dependency-name: zipp dependency-type: indirect -Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> ([`5349992`](https://github.com/AI21Labs/ai21-python/commit/53499926753a1854a2da6c65f8175c33d0a79ae1)) +... +Signed-off-by: dependabot[bot] -## v2.9.0 (2024-07-07) +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> -### Chores +- **release**: V2.9.1 [skip ci] + ([`5ed7f07`](https://github.com/AI21Labs/ai21-python/commit/5ed7f07e677ce60eb960991f3c601869d4e2c68c)) -* chore(release): v2.9.0 [skip ci] ([`f4b4d36`](https://github.com/AI21Labs/ai21-python/commit/f4b4d362b77ab94c970ae623f7f9185b94718181)) -* chore(deps): bump actions/github-script from 6 to 7 (#169) +## v2.9.0 (2024-07-07) -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) +### Bug Fixes ---- -updated-dependencies: -- dependency-name: actions/github-script - dependency-type: direct:production - update-type: version-update:semver-major -... +- Label parse ([#178](https://github.com/AI21Labs/ai21-python/pull/178), + [`1ea52f5`](https://github.com/AI21Labs/ai21-python/commit/1ea52f5b7b842edcb6f61e40edc9c8c58e49d9ac)) -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> ([`de4b1af`](https://github.com/AI21Labs/ai21-python/commit/de4b1af5654b30fbf01d7258a9174eb091362b1d)) +- Rest call ([#174](https://github.com/AI21Labs/ai21-python/pull/174), + [`24caf96`](https://github.com/AI21Labs/ai21-python/commit/24caf96a291a33b51df77a1ca1223eca639d741b)) + +- Version of action and json parser ([#173](https://github.com/AI21Labs/ai21-python/pull/173), + [`8a270ec`](https://github.com/AI21Labs/ai21-python/commit/8a270ecfc3e8b5d312dbe49d2a47a41c31be9be3)) -* chore: semantic pr - allow running on external prs (#164) ([`032fd5d`](https://github.com/AI21Labs/ai21-python/commit/032fd5d3a384f8dba26568c0b618e7c5f59a0431)) +### Chores -* chore: add status report to integration workflow (#161) +- Add status report to integration workflow + ([#161](https://github.com/AI21Labs/ai21-python/pull/161), + [`0a3a1e0`](https://github.com/AI21Labs/ai21-python/commit/0a3a1e02a6e44ac6589ff18e19c03c8cf5d94c19)) * chore: add status report to integration workflow * chore: add status report to integration workflow lint -* chore: export lint to separate workflow ([`0a3a1e0`](https://github.com/AI21Labs/ai21-python/commit/0a3a1e02a6e44ac6589ff18e19c03c8cf5d94c19)) +* chore: export lint to separate workflow + +- 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)) -* chore: integration-tests.yaml update inputs (#160) ([`b3f7728`](https://github.com/AI21Labs/ai21-python/commit/b3f772859374303efc130083d0f0aba0b1743398)) +- Integration-tests.yaml update inputs ([#159](https://github.com/AI21Labs/ai21-python/pull/159), + [`f61c905`](https://github.com/AI21Labs/ai21-python/commit/f61c9059ecb6cc8c4fafdec7f86205a768976f32)) -* chore: integration-tests.yaml update inputs (#159) ([`f61c905`](https://github.com/AI21Labs/ai21-python/commit/f61c9059ecb6cc8c4fafdec7f86205a768976f32)) +- Integration-tests.yaml update inputs ([#160](https://github.com/AI21Labs/ai21-python/pull/160), + [`b3f7728`](https://github.com/AI21Labs/ai21-python/commit/b3f772859374303efc130083d0f0aba0b1743398)) -* chore: integration-tests.yaml update checkout to specific commit (#158) ([`1c01663`](https://github.com/AI21Labs/ai21-python/commit/1c016630428085c44a6b1437fa87831a6b684fcb)) +- 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)) -* chore: Update testing workflows (#156) +- Update testing workflows ([#156](https://github.com/AI21Labs/ai21-python/pull/156), + [`4c170b8`](https://github.com/AI21Labs/ai21-python/commit/4c170b8378e6bfe06a1bc342d612ad1711792fca)) * chore: change triggers for workflows tests, integration-tests -* chore: integration-tests.yaml - add trigger for push on main ([`4c170b8`](https://github.com/AI21Labs/ai21-python/commit/4c170b8378e6bfe06a1bc342d612ad1711792fca)) +* chore: integration-tests.yaml - add trigger for push on main -### Continuous Integration - -* ci: Update size label When PR size changes (#171) (#172) - -* ci: Update size label - -* test: File to test label - -* fix: Remove file ([`6dd535a`](https://github.com/AI21Labs/ai21-python/commit/6dd535a4da3959ea258a2d316be7c145961b6875)) - -* ci: remove explicit permissions from semantic-pr.yml (#167) ([`3674efc`](https://github.com/AI21Labs/ai21-python/commit/3674efc106959f9b5b9b35c6eacc19db413c80cf)) - -### Features - -* feat: Async Support AWS (#180) - -* feat: Add bedrock async support (#146) - -* refactor: migrate from boto3 to custom http client +- **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)) -* 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) +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) -* feat: Add async tokenizer, add detokenize method (#144) +--- updated-dependencies: - dependency-name: actions/github-script dependency-type: + direct:production -* 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 +update-type: version-update:semver-major -* 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: 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) +- **release**: V2.9.0 [skip ci] + ([`f4b4d36`](https://github.com/AI21Labs/ai21-python/commit/f4b4d362b77ab94c970ae623f7f9185b94718181)) -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) +### Continuous Integration ---- -updated-dependencies: -- dependency-name: pypa/gh-action-pypi-publish - dependency-type: direct:production - update-type: version-update:semver-minor -... +- 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)) -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 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)) -* chore: rebase code +* ci: Update size label -* refactor: chat + chat completions - migrate to new client +* test: File to test label -* refactor: cr comments +* fix: Remove file -* chore: add async to new bedrock components +### Features -* refactor: rename aws folder +- Added Log Verbosity ([#152](https://github.com/AI21Labs/ai21-python/pull/152), + [`57b1ea9`](https://github.com/AI21Labs/ai21-python/commit/57b1ea9aa172fdef7723199fe77ca50a15d6427c)) -* chore: fix typo on file name bedrock_chat_completions +* fix: Added logger to httpx -* fix: fix errors +* feat: Added set_verbose -* chore: fix typo +* feat: Added set_debug -* fix: Added deprecation warning +* fix: api-key header -* fix: Added deprecation warning to async +* fix: Removed unused function -* chore: add log for ignoring stream +* feat: Logged env variables ---------- +* fix: Changed call location -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> +* fix: CR -* Add sagemaker async support (#155) +* 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)) + +* feat: Add bedrock async support (#146) * refactor: migrate from boto3 to custom http client @@ -870,8 +1063,6 @@ Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.c * 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 @@ -882,37 +1073,31 @@ Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.c * 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) +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 ---- -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) +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 -... +--- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish 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-minor * chore: rebase code @@ -924,24 +1109,30 @@ Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.co * 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 +--------- + +* Add sagemaker async support (#155) + +* refactor: sagemaker client, boto->aws http client + +* chore: refactor to use http client + +* chore: add async to sm resources + +* test: fix imports test + * chore: fix lint * refactor: export get_aws_region, add async sm to readme, add async examples @@ -950,12 +1141,6 @@ Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.co * 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 @@ -982,8 +1167,6 @@ Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.c * fix: base_url -* fix: Added deprecation warning - * fix: Moved 'model' extract * test: Added a tests to validate model_id and model cant be together @@ -992,99 +1175,82 @@ Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.c * 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> ([`5248d96`](https://github.com/AI21Labs/ai21-python/commit/5248d96a783b5ffab7cb7c9f6de383a1eba4df11)) -* feat: Added Log Verbosity (#152) -* 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 +## v2.8.0 (2024-06-26) -* fix: CR +### Chores -* fix: Added amazon header to secrets ([`57b1ea9`](https://github.com/AI21Labs/ai21-python/commit/57b1ea9aa172fdef7723199fe77ca50a15d6427c)) +- **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)) -### Fixes +Bumps + [python-semantic-release/python-semantic-release](https://github.com/python-semantic-release/python-semantic-release) + from 9.8.0 to 9.8.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.8.0...v9.8.3) -* fix: label parse (#178) ([`1ea52f5`](https://github.com/AI21Labs/ai21-python/commit/1ea52f5b7b842edcb6f61e40edc9c8c58e49d9ac)) +--- updated-dependencies: - dependency-name: python-semantic-release/python-semantic-release + dependency-type: direct:production -* fix: rest call (#174) ([`24caf96`](https://github.com/AI21Labs/ai21-python/commit/24caf96a291a33b51df77a1ca1223eca639d741b)) +update-type: version-update:semver-patch -* fix: Version of action and json parser (#173) ([`8a270ec`](https://github.com/AI21Labs/ai21-python/commit/8a270ecfc3e8b5d312dbe49d2a47a41c31be9be3)) +... +Signed-off-by: dependabot[bot] -## v2.8.0 (2024-06-26) +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> -### Chores +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> -* chore(release): v2.8.0 [skip ci] ([`c5087cf`](https://github.com/AI21Labs/ai21-python/commit/c5087cf6f20accdeba57d7630e1cd780de36e435)) +- **deps**: Bump urllib3 from 1.26.18 to 1.26.19 + ([#140](https://github.com/AI21Labs/ai21-python/pull/140), + [`dccf911`](https://github.com/AI21Labs/ai21-python/commit/dccf9117a2b17a74f8e9c298de22a072b84c6994)) -* chore(deps): bump python-semantic-release/python-semantic-release (#143) +Bumps [urllib3](https://github.com/urllib3/urllib3) from 1.26.18 to 1.26.19. - [Release + notes](https://github.com/urllib3/urllib3/releases) - + [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) -Bumps [python-semantic-release/python-semantic-release](https://github.com/python-semantic-release/python-semantic-release) from 9.8.0 to 9.8.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.8.0...v9.8.3) +--- updated-dependencies: - dependency-name: urllib3 dependency-type: indirect ---- -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> ([`718baaa`](https://github.com/AI21Labs/ai21-python/commit/718baaacce4af67c39c6e875782948e2158f22d4)) -* chore(deps): bump urllib3 from 1.26.18 to 1.26.19 (#140) +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> -Bumps [urllib3](https://github.com/urllib3/urllib3) from 1.26.18 to 1.26.19. -- [Release notes](https://github.com/urllib3/urllib3/releases) -- [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) +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> ---- -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> ([`dccf911`](https://github.com/AI21Labs/ai21-python/commit/dccf9117a2b17a74f8e9c298de22a072b84c6994)) +- **release**: V2.8.0 [skip ci] + ([`c5087cf`](https://github.com/AI21Labs/ai21-python/commit/c5087cf6f20accdeba57d7630e1cd780de36e435)) ### Continuous Integration -* ci: Update pull request action (#151) ([`bf535c6`](https://github.com/AI21Labs/ai21-python/commit/bf535c64a71a17d257dadbdfbe7ef5c384b1268a)) +- Update pull request action ([#151](https://github.com/AI21Labs/ai21-python/pull/151), + [`bf535c6`](https://github.com/AI21Labs/ai21-python/commit/bf535c64a71a17d257dadbdfbe7ef5c384b1268a)) ### Documentation -* docs: update README.md (#149) +- Fix message pass ([#150](https://github.com/AI21Labs/ai21-python/pull/150), + [`8f41631`](https://github.com/AI21Labs/ai21-python/commit/8f41631025021f19b665c0b4836a664438957549)) -minor fix +- Update README.md ([#149](https://github.com/AI21Labs/ai21-python/pull/149), + [`09798b1`](https://github.com/AI21Labs/ai21-python/commit/09798b1e730098d0f3d43695a39d416a75f5a17d)) -Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> ([`09798b1`](https://github.com/AI21Labs/ai21-python/commit/09798b1e730098d0f3d43695a39d416a75f5a17d)) +minor fix -* docs: Fix message pass (#150) ([`8f41631`](https://github.com/AI21Labs/ai21-python/commit/8f41631025021f19b665c0b4836a664438957549)) +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> ### Features -* feat: adding Jamaba-Instruct-V1(chat_completions) to AWS Bedrock (#153) +- Adding Jamaba-Instruct-V1(chat_completions) to AWS Bedrock + ([#153](https://github.com/AI21Labs/ai21-python/pull/153), + [`7fae5c6`](https://github.com/AI21Labs/ai21-python/commit/7fae5c6dd097ee491ed3a37c6c0b1b2e6f21502a)) * feat: adding Jamaba-Instruct-V1(chat_completions) to AWS Bedrock @@ -1102,54 +1268,72 @@ Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.co --------- -Co-authored-by: Josephasafg ([`7fae5c6`](https://github.com/AI21Labs/ai21-python/commit/7fae5c6dd097ee491ed3a37c6c0b1b2e6f21502a)) +Co-authored-by: Josephasafg ## v2.7.0 (2024-06-21) +### Bug Fixes + +- Add default version to azure url ([#148](https://github.com/AI21Labs/ai21-python/pull/148), + [`cbea1d1`](https://github.com/AI21Labs/ai21-python/commit/cbea1d19197bf48c26679f8f97d37013333994f6)) + +* fix: Added azure api version in the url + +* fix: Added _create_base_url + ### Chores -* chore(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)) -* 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) -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 ---- -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> ([`c509b7e`](https://github.com/AI21Labs/ai21-python/commit/c509b7e59aa984cc9948db1362162eaa52eeb1d7)) -* chore(deps-dev): bump authlib from 1.3.0 to 1.3.1 (#131) +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), + [`5eeaf52`](https://github.com/AI21Labs/ai21-python/commit/5eeaf52af19eee54d19fb9430b6caadf972e5f9c)) + +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) -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 ---- -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> ([`5eeaf52`](https://github.com/AI21Labs/ai21-python/commit/5eeaf52af19eee54d19fb9430b6caadf972e5f9c)) + +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 -* ci: Added parter labels (#147) ([`737d98f`](https://github.com/AI21Labs/ai21-python/commit/737d98f0b28d6e335b747dbae44fc68929cf39d6)) +- Added parter labels ([#147](https://github.com/AI21Labs/ai21-python/pull/147), + [`737d98f`](https://github.com/AI21Labs/ai21-python/commit/737d98f0b28d6e335b747dbae44fc68929cf39d6)) -* ci: Auto Label (#142) +- Auto Label ([#142](https://github.com/AI21Labs/ai21-python/pull/142), + [`b59407c`](https://github.com/AI21Labs/ai21-python/commit/b59407cb44e0f13ddc85cb07e721126df5acccfb)) * ci: Auto lgtm @@ -1201,62 +1385,56 @@ Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.co * 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)) +- Azure README ([#139](https://github.com/AI21Labs/ai21-python/pull/139), + [`5b0eadb`](https://github.com/AI21Labs/ai21-python/commit/5b0eadbe88702e2ca28de608191d9a17b8c0b4b0)) ### Features -* feat: Add async tokenizer, add detokenize method (#144) +- Add async tokenizer, add detokenize method + ([#144](https://github.com/AI21Labs/ai21-python/pull/144), + [`f2d06fc`](https://github.com/AI21Labs/ai21-python/commit/f2d06fc7d2bc155beeaec72c0481f9a239656c07)) * 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)) - -### Fixes - -* 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)) +* fix: fix tokenizer name in examples and readme, add example ## v2.6.0 (2024-06-13) ### Chores -* chore(release): v2.6.0 [skip ci] ([`3a6de49`](https://github.com/AI21Labs/ai21-python/commit/3a6de495aa88dc98577b8b27fff94cb88d7662ba)) +- **release**: V2.6.0 [skip ci] + ([`3a6de49`](https://github.com/AI21Labs/ai21-python/commit/3a6de495aa88dc98577b8b27fff94cb88d7662ba)) ### Features -* feat: Azure Client Support (#135) ([`6115632`](https://github.com/AI21Labs/ai21-python/commit/611563279999168703e49dbbf288190ee0ae262d)) +- Azure Client Support ([#135](https://github.com/AI21Labs/ai21-python/pull/135), + [`6115632`](https://github.com/AI21Labs/ai21-python/commit/611563279999168703e49dbbf288190ee0ae262d)) ## v2.5.2 (2024-06-13) -### Chores +### Bug Fixes -* chore(release): v2.5.2 [skip ci] ([`3eae31e`](https://github.com/AI21Labs/ai21-python/commit/3eae31e1f82cec6bcf208d1ed614daa0fd6ddad1)) +- Camel case ([#136](https://github.com/AI21Labs/ai21-python/pull/136), + [`e2b8466`](https://github.com/AI21Labs/ai21-python/commit/e2b846666bf5b2b8617cc26214fa5f36d65f5e35)) -### Fixes +### Chores -* fix: camel case (#136) ([`e2b8466`](https://github.com/AI21Labs/ai21-python/commit/e2b846666bf5b2b8617cc26214fa5f36d65f5e35)) +- **release**: V2.5.2 [skip ci] + ([`3eae31e`](https://github.com/AI21Labs/ai21-python/commit/3eae31e1f82cec6bcf208d1ed614daa0fd6ddad1)) ## v2.5.1 (2024-06-13) -### Chores +### Bug Fixes -* chore(release): v2.5.1 [skip ci] ([`e2a43b8`](https://github.com/AI21Labs/ai21-python/commit/e2a43b82cf891d8858d8927be77e696ff9ace4b3)) - -### Fixes - -* fix: Chain /studio/v1 to default url (#134) +- Chain /studio/v1 to default url ([#134](https://github.com/AI21Labs/ai21-python/pull/134), + [`8d305c5`](https://github.com/AI21Labs/ai21-python/commit/8d305c537df846be8f6c12ba0e165c6d8ae3c06d)) * fix: Chain /studio/v1 @@ -1266,52 +1444,34 @@ Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.co * fix: Extra line -* fix: Moved to external function ([`8d305c5`](https://github.com/AI21Labs/ai21-python/commit/8d305c537df846be8f6c12ba0e165c6d8ae3c06d)) - - -## v2.5.0 (2024-06-10) +* fix: Moved to external function ### Chores -* chore(release): v2.5.0 [skip ci] ([`f829c8f`](https://github.com/AI21Labs/ai21-python/commit/f829c8fc5430d65e771931c8c1f0af09bd75f94e)) - -### Features - -* feat: add support for studio async client (#129) - -* 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 +- **release**: V2.5.1 [skip ci] + ([`e2a43b8`](https://github.com/AI21Labs/ai21-python/commit/e2a43b82cf891d8858d8927be77e696ff9ace4b3)) -* feat: library -* feat: client +## v2.5.0 (2024-06-10) -* refactor: sync and async http, ai21 http, ai21 client, resources +### Bug Fixes -* test: update imports, create tests for async +- Pass Base URL to HTTP Client ([#128](https://github.com/AI21Labs/ai21-python/pull/128), + [`8b91187`](https://github.com/AI21Labs/ai21-python/commit/8b9118746bc30c9ba91fbca80ca6c6a9256d2876)) -* fix: base client - -* fix: add pytest marker asyncio +* fix: Support base urls -* fix: add pytest asyncio to poetry +* fix: tests -* fix: add delete to lib files, add examples, test examples +### Chores -* fix: tests +- **release**: V2.5.0 [skip ci] + ([`f829c8f`](https://github.com/AI21Labs/ai21-python/commit/f829c8fc5430d65e771931c8c1f0af09bd75f94e)) -* fix: fix stream, add stream tests, add readme +### Features -* fix: fix import on sm stub +- Add support for studio async client ([#129](https://github.com/AI21Labs/ai21-python/pull/129), + [`d1933e4`](https://github.com/AI21Labs/ai21-python/commit/d1933e4f4ba5964c4622b737504fbd0f0f77353a)) * feat: async support - stream, http, ai21 http @@ -1355,125 +1515,123 @@ Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.co * fix: fix failing test -* fix: fix failing test - -* fix: fix failing test - * fix: fix library test -* fix: cr comments ([`d1933e4`](https://github.com/AI21Labs/ai21-python/commit/d1933e4f4ba5964c4622b737504fbd0f0f77353a)) +* fix: cr comments -### Fixes -* fix: Pass Base URL to HTTP Client (#128) - -* fix: Support base urls - -* fix: tests ([`8b91187`](https://github.com/AI21Labs/ai21-python/commit/8b9118746bc30c9ba91fbca80ca6c6a9256d2876)) +## v2.4.2 (2024-06-06) +### Bug Fixes -## v2.4.2 (2024-06-06) +- Parameters ([#130](https://github.com/AI21Labs/ai21-python/pull/130), + [`dfcc567`](https://github.com/AI21Labs/ai21-python/commit/dfcc5675dc22fc3aafe7624b7e8ebd8cbd021146)) ### Chores -* chore(release): v2.4.2 [skip ci] ([`15109d6`](https://github.com/AI21Labs/ai21-python/commit/15109d6d1747c939612fa1a546818d011283e6ea)) +- **release**: V2.4.2 [skip ci] + ([`15109d6`](https://github.com/AI21Labs/ai21-python/commit/15109d6d1747c939612fa1a546818d011283e6ea)) -### Fixes -* fix: parameters (#130) ([`dfcc567`](https://github.com/AI21Labs/ai21-python/commit/dfcc5675dc22fc3aafe7624b7e8ebd8cbd021146)) +## v2.4.1 (2024-06-03) +### Bug Fixes -## v2.4.1 (2024-06-03) +- Num_retries ([#125](https://github.com/AI21Labs/ai21-python/pull/125), + [`cbbc213`](https://github.com/AI21Labs/ai21-python/commit/cbbc213bd840158797d3b5cfbcbc11200bd12f06)) ### Chores -* chore(release): v2.4.1 [skip ci] ([`f708889`](https://github.com/AI21Labs/ai21-python/commit/f708889469a022a26df4dcd2dc29636cebc5f581)) +- **deps**: Bump python-semantic-release/python-semantic-release + ([#121](https://github.com/AI21Labs/ai21-python/pull/121), + [`c8ade60`](https://github.com/AI21Labs/ai21-python/commit/c8ade60602661e0193e33371e942dd7a4600915a)) -* chore(deps): bump python-semantic-release/python-semantic-release (#121) +Bumps + [python-semantic-release/python-semantic-release](https://github.com/python-semantic-release/python-semantic-release) + from 9.7.3 to 9.8.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.7.3...v9.8.0) -Bumps [python-semantic-release/python-semantic-release](https://github.com/python-semantic-release/python-semantic-release) from 9.7.3 to 9.8.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.7.3...v9.8.0) - ---- -updated-dependencies: -- dependency-name: python-semantic-release/python-semantic-release +--- updated-dependencies: - dependency-name: python-semantic-release/python-semantic-release dependency-type: direct:production - update-type: version-update:semver-minor + +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> ([`c8ade60`](https://github.com/AI21Labs/ai21-python/commit/c8ade60602661e0193e33371e942dd7a4600915a)) -### Continuous Integration +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> -* ci: Added reach for auto assign (#124) ([`3f3aed0`](https://github.com/AI21Labs/ai21-python/commit/3f3aed0a653aef7a5addc005e96323c5f8874108)) +- **release**: V2.4.1 [skip ci] + ([`f708889`](https://github.com/AI21Labs/ai21-python/commit/f708889469a022a26df4dcd2dc29636cebc5f581)) -### Fixes +### Continuous Integration -* fix: num_retries (#125) ([`cbbc213`](https://github.com/AI21Labs/ai21-python/commit/cbbc213bd840158797d3b5cfbcbc11200bd12f06)) +- Added reach for auto assign ([#124](https://github.com/AI21Labs/ai21-python/pull/124), + [`3f3aed0`](https://github.com/AI21Labs/ai21-python/commit/3f3aed0a653aef7a5addc005e96323c5f8874108)) -### Unknown -* --- (#118) +## v2.4.0 (2024-05-28) -updated-dependencies: -- dependency-name: requests - dependency-type: indirect -... +### Bug Fixes -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> ([`30e1e58`](https://github.com/AI21Labs/ai21-python/commit/30e1e589e050958d277af00dd2aadbc493b9c56d)) +- Update library_search_response.py ([#122](https://github.com/AI21Labs/ai21-python/pull/122), + [`c8b57a8`](https://github.com/AI21Labs/ai21-python/commit/c8b57a8177754a376d2f53e2f730682832e76f04)) +feat: adding new field: order to library-search api response -## v2.4.0 (2024-05-28) +Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> ### Chores -* chore(release): v2.4.0 [skip ci] ([`b4062d2`](https://github.com/AI21Labs/ai21-python/commit/b4062d250f04b89b0f9ddd6762d61dd1363f0dc5)) +- **release**: V2.4.0 [skip ci] + ([`b4062d2`](https://github.com/AI21Labs/ai21-python/commit/b4062d250f04b89b0f9ddd6762d61dd1363f0dc5)) ### Features -* feat: Added beta to client (#123) ([`e3bfb27`](https://github.com/AI21Labs/ai21-python/commit/e3bfb272fc2d5f4341dff55d90e34da319b464f1)) - -### Fixes +- Added beta to client ([#123](https://github.com/AI21Labs/ai21-python/pull/123), + [`e3bfb27`](https://github.com/AI21Labs/ai21-python/commit/e3bfb272fc2d5f4341dff55d90e34da319b464f1)) -* fix: Update library_search_response.py (#122) - -feat: adding new field: order to library-search api response -Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> ([`c8b57a8`](https://github.com/AI21Labs/ai21-python/commit/c8b57a8177754a376d2f53e2f730682832e76f04)) +## v2.3.1 (2024-05-22) +### Bug Fixes -## v2.3.1 (2024-05-22) +- Updated env var in real time ([#120](https://github.com/AI21Labs/ai21-python/pull/120), + [`d19332d`](https://github.com/AI21Labs/ai21-python/commit/d19332d43d138b2060670561abbac292ece76826)) ### Chores -* chore(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)) -* chore(deps): bump idna from 3.6 to 3.7 (#96) +Bumps [idna](https://github.com/kjd/idna) from 3.6 to 3.7. - [Release + notes](https://github.com/kjd/idna/releases) - + [Changelog](https://github.com/kjd/idna/blob/master/HISTORY.rst) - + [Commits](https://github.com/kjd/idna/compare/v3.6...v3.7) -Bumps [idna](https://github.com/kjd/idna) from 3.6 to 3.7. -- [Release notes](https://github.com/kjd/idna/releases) -- [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> ([`7c52f19`](https://github.com/AI21Labs/ai21-python/commit/7c52f19012d400a23e38f5e41191d5f865c7d0a6)) + +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 -* docs: Table of contents in readme (#119) +- Table of contents in readme ([#119](https://github.com/AI21Labs/ai21-python/pull/119), + [`aca280e`](https://github.com/AI21Labs/ai21-python/commit/aca280e3d57f70c054491fbcaee45a905dda6b6b)) * docs: Updated docs with table of contents @@ -1483,156 +1641,73 @@ Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.co * fix: emoji -* fix: cloud emoji ([`aca280e`](https://github.com/AI21Labs/ai21-python/commit/aca280e3d57f70c054491fbcaee45a905dda6b6b)) - -### Fixes - -* fix: updated env var in real time (#120) ([`d19332d`](https://github.com/AI21Labs/ai21-python/commit/d19332d43d138b2060670561abbac292ece76826)) +* fix: cloud emoji ## v2.3.0 (2024-05-20) -### Chores - -* chore(release): v2.3.0 [skip ci] ([`d2d416a`](https://github.com/AI21Labs/ai21-python/commit/d2d416aaaf018c9905ad947fe70e30dfd951b5e6)) +### Bug Fixes -* chore(deps): bump python-semantic-release/python-semantic-release (#115) +- Delete file fixture ([#116](https://github.com/AI21Labs/ai21-python/pull/116), + [`9d9a9ba`](https://github.com/AI21Labs/ai21-python/commit/9d9a9ba7a00a6efeb1fedb936633e5d35cec3527)) -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) +### Chores ---- -updated-dependencies: -- dependency-name: python-semantic-release/python-semantic-release - dependency-type: direct:production - update-type: version-update:semver-minor -... +- **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)) -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> ([`2ff5912`](https://github.com/AI21Labs/ai21-python/commit/2ff5912c38be61ea3c06b52037109eb7504ae1a2)) +Bumps [amannn/action-semantic-pull-request](https://github.com/amannn/action-semantic-pull-request) + from 5.4.0 to 5.5.2. - [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.4.0...v5.5.2) -* chore(deps): bump amannn/action-semantic-pull-request (#103) +--- updated-dependencies: - dependency-name: amannn/action-semantic-pull-request dependency-type: + direct:production -Bumps [amannn/action-semantic-pull-request](https://github.com/amannn/action-semantic-pull-request) from 5.4.0 to 5.5.2. -- [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.4.0...v5.5.2) +update-type: version-update:semver-minor ---- -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> ([`5dd95ac`](https://github.com/AI21Labs/ai21-python/commit/5dd95acdeb73967377ada7ba3da98002df58398f)) - -### Features - -* feat: Jamba Stream Support (#117) - -* 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 - -* fix: imports - -* fix: tests - -* fix: imports - -* 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) @@ -1662,34 +1737,6 @@ Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.co * 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 @@ -1704,8 +1751,6 @@ Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.co * fix: tests -* fix: imports - * fix: reponse parse * fix: Added two examples to tests @@ -1716,8 +1761,6 @@ Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.co * fix: comment out failing test -* fix: CR - * fix: Removed code * docs: Added readme for streaming @@ -1734,84 +1777,84 @@ Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.co * fix: poetry.lock -* fix: poetry.lock - * fix: Uncomment test case -* fix: Removed unused json_to_response ([`ae0d12b`](https://github.com/AI21Labs/ai21-python/commit/ae0d12b4e4fbb9cdf8e2fac20ec370e7f91215b4)) - -### Fixes - -* fix: delete file fixture (#116) ([`9d9a9ba`](https://github.com/AI21Labs/ai21-python/commit/9d9a9ba7a00a6efeb1fedb936633e5d35cec3527)) +* fix: Removed unused json_to_response ## v2.2.5 (2024-05-14) -### Chores - -* chore(release): v2.2.5 [skip ci] ([`6d1502f`](https://github.com/AI21Labs/ai21-python/commit/6d1502f75457906f156503d9bbd63daf87665e54)) - -### Fixes +### Bug Fixes -* fix: upgrade ai21-tokenizer to latest version with less restrictive deps (#113) +- Upgrade ai21-tokenizer to latest version with less restrictive deps + ([#113](https://github.com/AI21Labs/ai21-python/pull/113), + [`022d60c`](https://github.com/AI21Labs/ai21-python/commit/022d60c78a1342fbe6a30a7a4d95c05b656a03bb)) * fix: upgrade ai21-tokenizer with latest version which has less restrictive deps -* fix: upgrade deps in general ([`022d60c`](https://github.com/AI21Labs/ai21-python/commit/022d60c78a1342fbe6a30a7a4d95c05b656a03bb)) - - -## v2.2.4 (2024-05-09) +* fix: upgrade deps in general ### Chores -* chore(release): v2.2.4 [skip ci] ([`aa2e8e2`](https://github.com/AI21Labs/ai21-python/commit/aa2e8e2fc4ca28728ed3f6b59abcbce398a04228)) +- **release**: V2.2.5 [skip ci] + ([`6d1502f`](https://github.com/AI21Labs/ai21-python/commit/6d1502f75457906f156503d9bbd63daf87665e54)) -### Fixes -* fix: pass kwargs to endpoints (#110) +## v2.2.4 (2024-05-09) -* feat: pass kwargs to endpoints +### Bug Fixes -* fix: test when passing kwargs ([`0d895e4`](https://github.com/AI21Labs/ai21-python/commit/0d895e49330400e938d87ef5eaa75f8c34fe36d1)) +- Pass kwargs to endpoints ([#110](https://github.com/AI21Labs/ai21-python/pull/110), + [`0d895e4`](https://github.com/AI21Labs/ai21-python/commit/0d895e49330400e938d87ef5eaa75f8c34fe36d1)) +* feat: pass kwargs to endpoints -## v2.2.3 (2024-04-25) +* fix: test when passing kwargs ### Chores -* chore(release): v2.2.3 [skip ci] ([`58c0166`](https://github.com/AI21Labs/ai21-python/commit/58c01660400fe54c0034447e903a843bc92ffcd5)) +- **release**: V2.2.4 [skip ci] + ([`aa2e8e2`](https://github.com/AI21Labs/ai21-python/commit/aa2e8e2fc4ca28728ed3f6b59abcbce398a04228)) -### Fixes -* fix: Support num_retries (#104) +## v2.2.3 (2024-04-25) -* fix: num_retries method +### Bug Fixes -* fix: Added 408 for retries ([`94c3254`](https://github.com/AI21Labs/ai21-python/commit/94c32542be3d4af6e80aae156b074055b9e5c34a)) +- Support num_retries ([#104](https://github.com/AI21Labs/ai21-python/pull/104), + [`94c3254`](https://github.com/AI21Labs/ai21-python/commit/94c32542be3d4af6e80aae156b074055b9e5c34a)) +* fix: num_retries method -## v2.2.2 (2024-04-24) +* fix: Added 408 for retries ### Chores -* chore(release): v2.2.2 [skip ci] ([`f3daeba`](https://github.com/AI21Labs/ai21-python/commit/f3daebaeafd168090c7a9b06485c49ebfe4f1b87)) +- **release**: V2.2.3 [skip ci] + ([`58c0166`](https://github.com/AI21Labs/ai21-python/commit/58c01660400fe54c0034447e903a843bc92ffcd5)) -### Fixes -* fix: Added raise error on wrong use of chat message (#102) ([`4efbea6`](https://github.com/AI21Labs/ai21-python/commit/4efbea6d85cd70f77650e4c4d96a3395eb60517b)) +## v2.2.2 (2024-04-24) +### Bug Fixes -## v2.2.1 (2024-04-22) +- Added raise error on wrong use of chat message + ([#102](https://github.com/AI21Labs/ai21-python/pull/102), + [`4efbea6`](https://github.com/AI21Labs/ai21-python/commit/4efbea6d85cd70f77650e4c4d96a3395eb60517b)) ### Chores -* chore(release): v2.2.1 [skip ci] ([`4fbfe00`](https://github.com/AI21Labs/ai21-python/commit/4fbfe0002bdf1e28bdfc611f1e9b9b99012f77c7)) +- **release**: V2.2.2 [skip ci] + ([`f3daeba`](https://github.com/AI21Labs/ai21-python/commit/f3daebaeafd168090c7a9b06485c49ebfe4f1b87)) -* chore: update chat example (#95) ([`7dd83b1`](https://github.com/AI21Labs/ai21-python/commit/7dd83b184a21fe3d94a8a8b90f9bfe04c6e30e2e)) -### Fixes +## v2.2.1 (2024-04-22) + +### Bug Fixes -* fix: Add support for n param to chat completion in studio (#98) +- Add support for n param to chat completion in studio + ([#98](https://github.com/AI21Labs/ai21-python/pull/98), + [`5459323`](https://github.com/AI21Labs/ai21-python/commit/54593235b590c35f5bfd391b3b195d294a65237b)) * fix: add n param support @@ -1819,147 +1862,178 @@ Co-authored-by: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.co * revert: wrong file -* fix: add n param support, add integration test ([`5459323`](https://github.com/AI21Labs/ai21-python/commit/54593235b590c35f5bfd391b3b195d294a65237b)) +* fix: add n param support, add integration test + +### Chores + +- 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) ### Chores -* chore(release): v2.2.0 [skip ci] ([`52a0fa3`](https://github.com/AI21Labs/ai21-python/commit/52a0fa3fe71f9491c89b12f183758eb9491a929d)) +- **release**: V2.2.0 [skip ci] + ([`52a0fa3`](https://github.com/AI21Labs/ai21-python/commit/52a0fa3fe71f9491c89b12f183758eb9491a929d)) ### Features -* feat: Support new chat API (#93) ([`d14bb7c`](https://github.com/AI21Labs/ai21-python/commit/d14bb7c80c18cef8589515eeade1b917499ea09c)) +- Support new chat API ([#93](https://github.com/AI21Labs/ai21-python/pull/93), + [`d14bb7c`](https://github.com/AI21Labs/ai21-python/commit/d14bb7c80c18cef8589515eeade1b917499ea09c)) ## v2.1.3 (2024-03-27) -### Chores +### Bug Fixes -* chore(release): v2.1.3 [skip ci] ([`a2b783c`](https://github.com/AI21Labs/ai21-python/commit/a2b783c6e1d7a095f69fc6cc3be86460e12949af)) +- Fix readme gaps ([#87](https://github.com/AI21Labs/ai21-python/pull/87), + [`da3afed`](https://github.com/AI21Labs/ai21-python/commit/da3afed67b806a35638ad804172183f8029619ea)) -* chore(deps-dev): bump black from 22.12.0 to 24.3.0 (#80) +* docs: Added contextual answers examples and shared a link to our examples folder -* chore(deps-dev): bump black from 22.12.0 to 24.3.0 +* fix: Fixed main link in our readme -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) +* docs: Examples section ---- -updated-dependencies: -- dependency-name: black - dependency-type: direct:development -... +### Chores -Signed-off-by: dependabot[bot] +- **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)) -* refactor: lint fixes +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) ---------- +--- 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> + Co-authored-by: Asaf Gardin <147075902+asafgardin@users.noreply.github.com> -Co-authored-by: Asaf Gardin ([`5986522`](https://github.com/AI21Labs/ai21-python/commit/59865220571bbdb19edf69aee16b21dbe7582d85)) -* chore(deps): bump python-semantic-release/python-semantic-release (#85) +- **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)) -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 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) +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 + 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) ---- -updated-dependencies: -- dependency-name: python-semantic-release/python-semantic-release +--- updated-dependencies: - dependency-name: python-semantic-release/python-semantic-release dependency-type: direct:production - update-type: version-update:semver-patch + +update-type: version-update:semver-major + ... Signed-off-by: dependabot[bot] -Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> ([`aea5963`](https://github.com/AI21Labs/ai21-python/commit/aea5963943ad6220a41386acc5adbf23a8f0bf3e)) -* chore(deps): bump python-semantic-release/python-semantic-release (#81) +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 + ([#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 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) +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 + 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) ---- -updated-dependencies: -- dependency-name: python-semantic-release/python-semantic-release +--- updated-dependencies: - dependency-name: python-semantic-release/python-semantic-release dependency-type: direct:production - update-type: version-update:semver-major + +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 Gardin <147075902+asafgardin@users.noreply.github.com> ([`c94966b`](https://github.com/AI21Labs/ai21-python/commit/c94966b4b05eec93a44e828800f043233b1fe5f4)) -* chore(deps): bump pypa/gh-action-pypi-publish from 1.8.11 to 1.8.14 (#77) +- **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 + +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 ---- -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> -Co-authored-by: Asaf Gardin <147075902+asafgardin@users.noreply.github.com> ([`7f3ea4a`](https://github.com/AI21Labs/ai21-python/commit/7f3ea4ab5ff87f92312e6fd873a17cbab010ed4e)) -### Fixes +* refactor: lint fixes -* fix: Fix readme gaps (#87) +--------- -* docs: Added contextual answers examples and shared a link to our examples folder +Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> -* fix: Fixed main link in our readme +Co-authored-by: Asaf Gardin <147075902+asafgardin@users.noreply.github.com> + +Co-authored-by: Asaf Gardin -* docs: Examples section ([`da3afed`](https://github.com/AI21Labs/ai21-python/commit/da3afed67b806a35638ad804172183f8029619ea)) +- **release**: V2.1.3 [skip ci] + ([`a2b783c`](https://github.com/AI21Labs/ai21-python/commit/a2b783c6e1d7a095f69fc6cc3be86460e12949af)) ### Testing -* test: integration test for library files (#83) +- 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)) * fix: integration test for file * refactor: Simplified -* fix: chat tests ([`3a50669`](https://github.com/AI21Labs/ai21-python/commit/3a50669db9351223ca971908eaa6e4842011d259)) - -* test: check imports (#76) ([`a72e23b`](https://github.com/AI21Labs/ai21-python/commit/a72e23b063ad3c1db076ced932bf0f4e6703c576)) +* fix: chat tests ## v2.1.2 (2024-02-27) -### Chores +### Bug Fixes -* chore(release): v2.1.2 [skip ci] ([`9551776`](https://github.com/AI21Labs/ai21-python/commit/9551776a9f6c4c3a1671e308dad37a900e786b0f)) +- Added future type annotation to sagemaker ([#74](https://github.com/AI21Labs/ai21-python/pull/74), + [`f561dd8`](https://github.com/AI21Labs/ai21-python/commit/f561dd8ce2a2bd4e532f46fe96211486f9b8cc39)) -### Fixes +### Chores -* fix: Added future type annotation to sagemaker (#74) ([`f561dd8`](https://github.com/AI21Labs/ai21-python/commit/f561dd8ce2a2bd4e532f46fe96211486f9b8cc39)) +- **release**: V2.1.2 [skip ci] + ([`9551776`](https://github.com/AI21Labs/ai21-python/commit/9551776a9f6c4c3a1671e308dad37a900e786b0f)) ## v2.1.1 (2024-02-25) -### Chores - -* chore(release): v2.1.1 [skip ci] ([`69dc136`](https://github.com/AI21Labs/ai21-python/commit/69dc1361e47cdc60dde3c366dffe89b364fdce26)) - -### Fixes +### Bug Fixes -* fix: add logit bias to studio, sagemaker (#70) +- Add logit bias to studio, sagemaker ([#70](https://github.com/AI21Labs/ai21-python/pull/70), + [`b0b5bc1`](https://github.com/AI21Labs/ai21-python/commit/b0b5bc152d61944313b53f39cd314a621568e6e0)) * fix: add logit bias, fix studio completion @@ -1971,32 +2045,49 @@ Co-authored-by: Asaf Gardin <147075902+asafgardin@users.noreply.github.com> ([`7 * 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: update code with new not_giving approach -* fix: add logit bias integration test +### Chores -* fix: update studio completion example +- **release**: V2.1.1 [skip ci] + ([`69dc136`](https://github.com/AI21Labs/ai21-python/commit/69dc1361e47cdc60dde3c366dffe89b364fdce26)) -* fix: fix studio completion example -* fix: update code with new not_giving approach ([`b0b5bc1`](https://github.com/AI21Labs/ai21-python/commit/b0b5bc152d61944313b53f39cd314a621568e6e0)) +## v2.1.0 (2024-02-25) + +### Bug Fixes +- Pass default model_id in bedrock client ([#72](https://github.com/AI21Labs/ai21-python/pull/72), + [`e849d78`](https://github.com/AI21Labs/ai21-python/commit/e849d78dfa9990492dcd7836d2f5df3f1ade3451)) -## v2.1.0 (2024-02-25) +* fix: Pass default model_id in bedrock client + +* 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)) + +* feat: Moved model_id in bedrock to init + +* test: Added tests to check model id + +* fix: bedrock example + +* refactor: rename test params ### Chores -* chore(release): v2.1.0 [skip ci] ([`5e9a768`](https://github.com/AI21Labs/ai21-python/commit/5e9a7681e4ab1ffcdcff1c07e0cb94452eb2632c)) +- **release**: V2.1.0 [skip ci] + ([`5e9a768`](https://github.com/AI21Labs/ai21-python/commit/5e9a7681e4ab1ffcdcff1c07e0cb94452eb2632c)) ### Features -* feat: support NOT_GIVEN type (#69) +- Support NOT_GIVEN type ([#69](https://github.com/AI21Labs/ai21-python/pull/69), + [`c7fd28a`](https://github.com/AI21Labs/ai21-python/commit/c7fd28a124c4971a9d9b85ad0d5fc5bd187535b0)) * feat: support NOT_GIVEN type @@ -2012,38 +2103,15 @@ Co-authored-by: Asaf Gardin <147075902+asafgardin@users.noreply.github.com> ([`7 --------- -Co-authored-by: Asaf Gardin ([`c7fd28a`](https://github.com/AI21Labs/ai21-python/commit/c7fd28a124c4971a9d9b85ad0d5fc5bd187535b0)) - -### Fixes - -* fix: Pass default model_id in bedrock client (#72) - -* fix: Pass default model_id in bedrock client - -* fix: Added validation for model_id - -* fix: Added validation for model_id ([`e849d78`](https://github.com/AI21Labs/ai21-python/commit/e849d78dfa9990492dcd7836d2f5df3f1ade3451)) - -* fix: Pass model id in Bedrock client init (#71) - -* feat: Moved model_id in bedrock to init - -* test: Added tests to check model id - -* fix: bedrock example - -* refactor: rename test params ([`409e818`](https://github.com/AI21Labs/ai21-python/commit/409e818b751c261b93befedad968d6533860296c)) +Co-authored-by: Asaf Gardin ## v2.0.5 (2024-02-21) -### Chores - -* chore(release): v2.0.5 [skip ci] ([`8965828`](https://github.com/AI21Labs/ai21-python/commit/896582839dd298121210187572adc178351f8d58)) +### Bug Fixes -### Fixes - -* fix: penalties in Sagemaker and Bedrock (#67) +- Penalties in Sagemaker and Bedrock ([#67](https://github.com/AI21Labs/ai21-python/pull/67), + [`d7c912f`](https://github.com/AI21Labs/ai21-python/commit/d7c912f0ef86d8ca18a7225cdf8da6b79de8b415)) * fix: penalties in sagemaker @@ -2059,43 +2127,60 @@ Co-authored-by: Asaf Gardin ([`c7fd28a`](https://github.com/AI2 --------- -Co-authored-by: etang ([`d7c912f`](https://github.com/AI21Labs/ai21-python/commit/d7c912f0ef86d8ca18a7225cdf8da6b79de8b415)) +Co-authored-by: etang + +### Chores +- **release**: V2.0.5 [skip ci] + ([`8965828`](https://github.com/AI21Labs/ai21-python/commit/896582839dd298121210187572adc178351f8d58)) -## v2.0.4 (2024-02-18) -### Chores +## v2.0.4 (2024-02-18) -* chore(release): v2.0.4 [skip ci] ([`8b0f217`](https://github.com/AI21Labs/ai21-python/commit/8b0f217dd14aa820b5e404ed564e099d214d882f)) +### Bug Fixes -### Documentation +- Add model types to docs ([#62](https://github.com/AI21Labs/ai21-python/pull/62), + [`ca5c3ca`](https://github.com/AI21Labs/ai21-python/commit/ca5c3ca4127fa3393c1d29f069120b3896da8beb)) -* docs: fix error handling example (#63) ([`fcd2746`](https://github.com/AI21Labs/ai21-python/commit/fcd2746ffd5839932628a10c0292fc766fef8963)) +* fix: Added model names in readme -### Fixes +* fix: Added header -* fix: Removed answer_length and mode from answer (#65) +- 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)) * fix: Removed answer_length and mode from answer -* test: Fixed test ([`3814e57`](https://github.com/AI21Labs/ai21-python/commit/3814e57c7a90a026cfb4ee4f97b7edb0de937f16)) +* test: Fixed test + +### Chores -* fix: Add model types to docs (#62) +- **release**: V2.0.4 [skip ci] + ([`8b0f217`](https://github.com/AI21Labs/ai21-python/commit/8b0f217dd14aa820b5e404ed564e099d214d882f)) -* fix: Added model names in readme +### Documentation -* fix: Added header ([`ca5c3ca`](https://github.com/AI21Labs/ai21-python/commit/ca5c3ca4127fa3393c1d29f069120b3896da8beb)) +- Fix error handling example ([#63](https://github.com/AI21Labs/ai21-python/pull/63), + [`fcd2746`](https://github.com/AI21Labs/ai21-python/commit/fcd2746ffd5839932628a10c0292fc766fef8963)) ## v2.0.3 (2024-02-07) +### Bug Fixes + +- Skip passing API key to ARN endpoint ([#60](https://github.com/AI21Labs/ai21-python/pull/60), + [`8fd72f0`](https://github.com/AI21Labs/ai21-python/commit/8fd72f0ebe23bc23244e8453744b46bd093bccb3)) + ### Chores -* chore(release): v2.0.3 [skip ci] ([`d0ccc5d`](https://github.com/AI21Labs/ai21-python/commit/d0ccc5d9f3a14a61fca788496afc65e02d9dca4f)) +- **release**: V2.0.3 [skip ci] + ([`d0ccc5d`](https://github.com/AI21Labs/ai21-python/commit/d0ccc5d9f3a14a61fca788496afc65e02d9dca4f)) ### Documentation -* docs: add code snippet notebook (#58) +- Add code snippet notebook ([#58](https://github.com/AI21Labs/ai21-python/pull/58), + [`139d05f`](https://github.com/AI21Labs/ai21-python/commit/139d05f919d7c89da031dd50bf7bc1f080dc2d31)) * add code snippet notebook @@ -2104,87 +2189,106 @@ Co-authored-by: etang ([`d7c912f`](https://github.com/AI21Labs/ --------- Co-authored-by: Joshua Broyde -Co-authored-by: asafgardin <147075902+asafgardin@users.noreply.github.com> ([`139d05f`](https://github.com/AI21Labs/ai21-python/commit/139d05f919d7c89da031dd50bf7bc1f080dc2d31)) - -### Fixes -* fix: skip passing API key to ARN endpoint (#60) ([`8fd72f0`](https://github.com/AI21Labs/ai21-python/commit/8fd72f0ebe23bc23244e8453744b46bd093bccb3)) +Co-authored-by: asafgardin <147075902+asafgardin@users.noreply.github.com> ## v2.0.2 (2024-02-04) -### Chores +### Bug Fixes -* chore(release): v2.0.2 [skip ci] ([`2db1816`](https://github.com/AI21Labs/ai21-python/commit/2db1816a152a20d18cbd397183512f479d4fec90)) +- Changed log level ([#56](https://github.com/AI21Labs/ai21-python/pull/56), + [`8db493c`](https://github.com/AI21Labs/ai21-python/commit/8db493c9ccd98e2421ff65a583e5e43773dc4bb1)) -* chore(deps): bump python-semantic-release/python-semantic-release (#49) +### Chores + +- **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)) -Bumps [python-semantic-release/python-semantic-release](https://github.com/python-semantic-release/python-semantic-release) from 8.3.0 to 8.7.2. -- [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.3.0...v8.7.2) +Bumps + [python-semantic-release/python-semantic-release](https://github.com/python-semantic-release/python-semantic-release) + from 8.3.0 to 8.7.2. - [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.3.0...v8.7.2) ---- -updated-dependencies: -- dependency-name: python-semantic-release/python-semantic-release +--- updated-dependencies: - dependency-name: python-semantic-release/python-semantic-release dependency-type: direct:production - update-type: version-update:semver-minor + +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> ([`aac9932`](https://github.com/AI21Labs/ai21-python/commit/aac993213edfe2ee889d5d12e899fe32e0ba702a)) -### Fixes +Co-authored-by: asafgardin <147075902+asafgardin@users.noreply.github.com> -* fix: Changed log level (#56) ([`8db493c`](https://github.com/AI21Labs/ai21-python/commit/8db493c9ccd98e2421ff65a583e5e43773dc4bb1)) +- **release**: V2.0.2 [skip ci] + ([`2db1816`](https://github.com/AI21Labs/ai21-python/commit/2db1816a152a20d18cbd397183512f479d4fec90)) ## v2.0.1 (2024-02-01) +### Bug Fixes + +- Added badges ([#55](https://github.com/AI21Labs/ai21-python/pull/55), + [`96d716d`](https://github.com/AI21Labs/ai21-python/commit/96d716de7a49868c20461bc2dc34c142da36070b)) + ### Chores -* chore(release): v2.0.1 [skip ci] ([`2af2f2b`](https://github.com/AI21Labs/ai21-python/commit/2af2f2b3153a486a8df33b4266f54cf28f0da049)) +- **release**: V2.0.1 [skip ci] + ([`2af2f2b`](https://github.com/AI21Labs/ai21-python/commit/2af2f2b3153a486a8df33b4266f54cf28f0da049)) ### Documentation -* docs: updated migration (#54) +- Updated migration ([#54](https://github.com/AI21Labs/ai21-python/pull/54), + [`bca0424`](https://github.com/AI21Labs/ai21-python/commit/bca0424f44ffb2c5e5a3b9f292eb08649a844f53)) * docs: updated migration -* fix: example ([`bca0424`](https://github.com/AI21Labs/ai21-python/commit/bca0424f44ffb2c5e5a3b9f292eb08649a844f53)) +* fix: example -### Fixes -* fix: Added badges (#55) ([`96d716d`](https://github.com/AI21Labs/ai21-python/commit/96d716de7a49868c20461bc2dc34c142da36070b)) +## v2.0.0 (2024-01-31) +### Chores -## v2.0.0 (2024-01-31) +- **release**: V2.0.0 [skip ci] + ([`2a65f23`](https://github.com/AI21Labs/ai21-python/commit/2a65f23b487d7d64c09ea69f87daf1cd80a42146)) -### Breaking +### Features -* feat: bump version (#53) +- Bump version ([#53](https://github.com/AI21Labs/ai21-python/pull/53), + [`77cfb85`](https://github.com/AI21Labs/ai21-python/commit/77cfb85d4b422ff217c511edfdf0782fce65c3b3)) -BREAKING CHANGE: 2.0.0 to SDK ([`77cfb85`](https://github.com/AI21Labs/ai21-python/commit/77cfb85d4b422ff217c511edfdf0782fce65c3b3)) +BREAKING CHANGE: 2.0.0 to SDK -### Chores +### BREAKING CHANGES -* chore(release): v2.0.0 [skip ci] ([`2a65f23`](https://github.com/AI21Labs/ai21-python/commit/2a65f23b487d7d64c09ea69f87daf1cd80a42146)) +- 2.0.0 to SDK ## v1.0.0 (2024-01-31) ### Chores -* chore(release): v1.0.0 [skip ci] ([`34efede`](https://github.com/AI21Labs/ai21-python/commit/34efedeb9a181bce86f8cbf0458dcd6b54538415)) +- **release**: V1.0.0 [skip ci] + ([`34efede`](https://github.com/AI21Labs/ai21-python/commit/34efedeb9a181bce86f8cbf0458dcd6b54538415)) -* chore(release): v1.0.0 [skip ci] ([`66a0086`](https://github.com/AI21Labs/ai21-python/commit/66a008632304265914acb25a6eb8c6dfd8476911)) +- **release**: V1.0.0 [skip ci] + ([`66a0086`](https://github.com/AI21Labs/ai21-python/commit/66a008632304265914acb25a6eb8c6dfd8476911)) ### Features -* feat: bump to 2.0.0 (#52) ([`5e61e29`](https://github.com/AI21Labs/ai21-python/commit/5e61e29ec74c6c508969301c949e5b2bf72ad85b)) +- Bump to 2.0.0 ([#52](https://github.com/AI21Labs/ai21-python/pull/52), + [`5e61e29`](https://github.com/AI21Labs/ai21-python/commit/5e61e29ec74c6c508969301c949e5b2bf72ad85b)) -* feat: Release Candidate v2.0.0 (#26) +- Release Candidate v2.0.0 ([#26](https://github.com/AI21Labs/ai21-python/pull/26), + [`60e3f4d`](https://github.com/AI21Labs/ai21-python/commit/60e3f4dc93f83c11ad1c1bc1f51cb64ec6036520)) * ci: Change main proj name (#22) @@ -2196,10 +2300,6 @@ BREAKING CHANGE: 2.0.0 to SDK ([`77cfb85`](https://github.com/AI21Labs/ai21-pyth * 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] @@ -2274,64 +2374,6 @@ BREAKING CHANGE: 2.0.0 to SDK ([`77cfb85`](https://github.com/AI21Labs/ai21-pyth * 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 @@ -2394,8 +2436,6 @@ BREAKING CHANGE: 2.0.0 to SDK ([`77cfb85`](https://github.com/AI21Labs/ai21-pyth * refactor: init -* fix: imports - * refactor: added more to imports * chore(release): v2.0.0-rc.7 [skip ci] @@ -2414,8 +2454,6 @@ BREAKING CHANGE: 2.0.0 to SDK ([`77cfb85`](https://github.com/AI21Labs/ai21-pyth * 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) @@ -2430,8 +2468,6 @@ BREAKING CHANGE: 2.0.0 to SDK ([`77cfb85`](https://github.com/AI21Labs/ai21-pyth * 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) @@ -2454,14 +2490,6 @@ BREAKING CHANGE: 2.0.0 to SDK ([`77cfb85`](https://github.com/AI21Labs/ai21-pyth * 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 @@ -2492,34 +2520,6 @@ BREAKING CHANGE: 2.0.0 to SDK ([`77cfb85`](https://github.com/AI21Labs/ai21-pyth * 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 @@ -2530,121 +2530,81 @@ BREAKING CHANGE: 2.0.0 to SDK ([`77cfb85`](https://github.com/AI21Labs/ai21-pyth * chore(deps-dev): bump jinja2 from 3.1.2 to 3.1.3 (#38) -Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.2 to 3.1.3. -- [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.2...3.1.3) +Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.2 to 3.1.3. - [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.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> * chore(deps-dev): bump gitpython from 3.1.40 to 3.1.41 (#37) -Bumps [gitpython](https://github.com/gitpython-developers/GitPython) from 3.1.40 to 3.1.41. -- [Release notes](https://github.com/gitpython-developers/GitPython/releases) -- [Changelog](https://github.com/gitpython-developers/GitPython/blob/main/CHANGES) -- [Commits](https://github.com/gitpython-developers/GitPython/compare/3.1.40...3.1.41) +Bumps [gitpython](https://github.com/gitpython-developers/GitPython) from 3.1.40 to 3.1.41. - + [Release notes](https://github.com/gitpython-developers/GitPython/releases) - + [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) -Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 4. -- [Release notes](https://github.com/actions/upload-artifact/releases) -- [Commits](https://github.com/actions/upload-artifact/compare/v3...v4) +Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 4. - [Release + notes](https://github.com/actions/upload-artifact/releases) - + [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 -... +--- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: + 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) -Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.4.2 to 1.8.11. -- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) -- [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/27b31702a0e7fc50959f5ad993c78deac1bdfc29...2f6f737ca5f74c637829c0f5c3acd0e29ea5e8bf) +Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.4.2 to + 1.8.11. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - + [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 -... +--- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: + 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) -Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5. -- [Release notes](https://github.com/actions/setup-python/releases) -- [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 -... +Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5. - [Release + notes](https://github.com/actions/setup-python/releases) - + [Commits](https://github.com/actions/setup-python/compare/v4...v5) -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: actions/setup-python dependency-type: direct:production * chore(deps): bump amannn/action-semantic-pull-request (#2) -Bumps [amannn/action-semantic-pull-request](https://github.com/amannn/action-semantic-pull-request) from 5.0.2 to 5.4.0. -- [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.0.2...v5.4.0) - ---- -updated-dependencies: -- dependency-name: amannn/action-semantic-pull-request - dependency-type: direct:production - update-type: version-update:semver-minor -... +Bumps [amannn/action-semantic-pull-request](https://github.com/amannn/action-semantic-pull-request) + from 5.0.2 to 5.4.0. - [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.0.2...v5.4.0) -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: amannn/action-semantic-pull-request dependency-type: + 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 @@ -2655,141 +2615,138 @@ Co-authored-by: asafgardin <147075902+asafgardin@users.noreply.github.com> --------- -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> ([`60e3f4d`](https://github.com/AI21Labs/ai21-python/commit/60e3f4dc93f83c11ad1c1bc1f51cb64ec6036520)) - -### Unknown - -* Revert "chore(release): v1.0.0 [skip ci]" (#51) - -This reverts commit 66a008632304265914acb25a6eb8c6dfd8476911. ([`6bab551`](https://github.com/AI21Labs/ai21-python/commit/6bab55101e3b17800c435442ae2a762ec39ce0f8)) -* Update issue templates ([`c30302f`](https://github.com/AI21Labs/ai21-python/commit/c30302fd9d6dc2b0b83cea10b5a677699ea2b8a2)) - -* Update issue templates ([`2590685`](https://github.com/AI21Labs/ai21-python/commit/2590685fed8ea63204dcfdd47e27cb340a79cfb8)) +Co-authored-by: etang ## v2.0.0-rc.3 (2023-12-18) -### Chores +### Bug Fixes -* chore(release): v2.0.0-rc.3 [skip ci] ([`0a9ace7`](https://github.com/AI21Labs/ai21-python/commit/0a9ace7dd8b59eb51b6dcb4e4a1118aaa012b454)) +- Change main project name in setup ([#17](https://github.com/AI21Labs/ai21-python/pull/17), + [`7c68b7f`](https://github.com/AI21Labs/ai21-python/commit/7c68b7f0671681e0faab3720649760b50d05d6c6)) -### Fixes +* ci: precommit -* fix: Change main project name in setup (#17) +* fix: version name -* ci: precommit +### Chores -* fix: version name ([`7c68b7f`](https://github.com/AI21Labs/ai21-python/commit/7c68b7f0671681e0faab3720649760b50d05d6c6)) +- **release**: V2.0.0-rc.3 [skip ci] + ([`0a9ace7`](https://github.com/AI21Labs/ai21-python/commit/0a9ace7dd8b59eb51b6dcb4e4a1118aaa012b454)) ## v2.0.0-rc.2 (2023-12-18) ### Chores -* chore(release): v2.0.0-rc.2 [skip ci] ([`5b83506`](https://github.com/AI21Labs/ai21-python/commit/5b835060bc223bfec907624b2d717418ab51309e)) +- **release**: V2.0.0-rc.2 [skip ci] + ([`5b83506`](https://github.com/AI21Labs/ai21-python/commit/5b835060bc223bfec907624b2d717418ab51309e)) ### Features -* feat: project name (#16) +- Project name ([#16](https://github.com/AI21Labs/ai21-python/pull/16), + [`e985980`](https://github.com/AI21Labs/ai21-python/commit/e98598027d955e3f0108ab1919e90195c5b2d52d)) * feat: project name -* fix: name ([`e985980`](https://github.com/AI21Labs/ai21-python/commit/e98598027d955e3f0108ab1919e90195c5b2d52d)) +* fix: name ## v1.0.0-rc.2 (2023-12-18) -### Breaking - -* feat!: branch group (#15) ([`3ca1017`](https://github.com/AI21Labs/ai21-python/commit/3ca10175891ed4c51e5f4ec638eb2fd5cf05359e)) - -* feat!: Bump 2 rc version new (#14) - -* ci: new line remove - -* feat: new line ([`a086c7d`](https://github.com/AI21Labs/ai21-python/commit/a086c7d8ef40ba3f53b0144c5ba4b5911ecd5932)) - ### Chores -* chore(release): v1.0.0-rc.2 [skip ci] ([`ea8b6a9`](https://github.com/AI21Labs/ai21-python/commit/ea8b6a90e21f9a287a026b438ba5a5eb4eacdaa3)) - - -## v1.0.0-rc.1 (2023-12-18) - -### Breaking - -* feat!: Bump 2 rc version (#13) - -* docs: changelog - -* docs: added text +- **release**: V1.0.0-rc.2 [skip ci] + ([`ea8b6a9`](https://github.com/AI21Labs/ai21-python/commit/ea8b6a90e21f9a287a026b438ba5a5eb4eacdaa3)) -* fix: verison ([`1426ed1`](https://github.com/AI21Labs/ai21-python/commit/1426ed16cdf9cd1d201a0bfe8bbf9a454ad685f7)) +### Features -* feat!: version rc bump (#12) ([`88ccbe2`](https://github.com/AI21Labs/ai21-python/commit/88ccbe2b0d35b1f1682b0fcf58ca1a755fa26739)) +- Branch group ([#15](https://github.com/AI21Labs/ai21-python/pull/15), + [`3ca1017`](https://github.com/AI21Labs/ai21-python/commit/3ca10175891ed4c51e5f4ec638eb2fd5cf05359e)) -* feat!: readme restart (#11) ([`992dedc`](https://github.com/AI21Labs/ai21-python/commit/992dedc63dd99dbffe78c80343afca1bb0530649)) +- Bump 2 rc version new ([#14](https://github.com/AI21Labs/ai21-python/pull/14), + [`a086c7d`](https://github.com/AI21Labs/ai21-python/commit/a086c7d8ef40ba3f53b0144c5ba4b5911ecd5932)) -* feat: bumping test (#10) +* ci: new line remove -BREAKING CHANGE: New SDK version +* feat: new line -* fix: removed CHANGELOG.md -* fix: removed version rc +## v1.0.0-rc.1 (2023-12-18) -* fix: removed CHANGELOG.md +### Bug Fixes -* fix: removed version rc ([`5650abd`](https://github.com/AI21Labs/ai21-python/commit/5650abdac34dd035b80962ce14d173376210193e)) +- Test pypi params ([#8](https://github.com/AI21Labs/ai21-python/pull/8), + [`ed8fa1f`](https://github.com/AI21Labs/ai21-python/commit/ed8fa1f7b52b0ab6f94ed9815adf0256152dd02e)) ### Chores -* chore(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)) -* chore(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)) -* chore(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)) -* chore(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)) -* chore(release): v1.1.0-rc.1 [skip ci] ([`de5b2b5`](https://github.com/AI21Labs/ai21-python/commit/de5b2b55c4fb0ba99b002ec7c75c34eb130a63c8)) +- **release**: V1.1.0-rc.1 [skip ci] + ([`de5b2b5`](https://github.com/AI21Labs/ai21-python/commit/de5b2b55c4fb0ba99b002ec7c75c34eb130a63c8)) -* chore(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)) -* chore(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)) -* chore(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)) -* chore(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 -* ci: python versions (#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)) -* ci: add_integration_test_action (#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 -* feat: BREAKING CHANGE: pre release 2.0.0 (#9) +- 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 ([`b15d4c7`](https://github.com/AI21Labs/ai21-python/commit/b15d4c757afe18ee000334ec8355c9baa5351505)) +* feat: bump 1.0.0 BREAKING CHANGE: pre release -* feat: Test pypi (#7) +- Bump 2 rc version ([#13](https://github.com/AI21Labs/ai21-python/pull/13), + [`1426ed1`](https://github.com/AI21Labs/ai21-python/commit/1426ed16cdf9cd1d201a0bfe8bbf9a454ad685f7)) -* feat: release candidate +* docs: changelog -* ci: test pypi +* docs: added text + +* fix: verison + +- Bumping test ([#10](https://github.com/AI21Labs/ai21-python/pull/10), + [`5650abd`](https://github.com/AI21Labs/ai21-python/commit/5650abdac34dd035b80962ce14d173376210193e)) + +BREAKING CHANGE: New SDK version + +* fix: removed CHANGELOG.md -* fix: version ([`549d044`](https://github.com/AI21Labs/ai21-python/commit/549d0444e09e1af34b29e6d264c61bfe0c091dbe)) +* fix: removed version rc -* feat: Pre release publish (#6) +- Pre release publish ([#6](https://github.com/AI21Labs/ai21-python/pull/6), + [`ed3ff91`](https://github.com/AI21Labs/ai21-python/commit/ed3ff91090f14ded7b9d1ae03fdff5ac935fbdc0)) * feat: release candidate @@ -2797,9 +2754,13 @@ BREAKING CHANGE: pre release ([`b15d4c7`](https://github.com/AI21Labs/ai21-pytho * fix: imports -* fix: push to test pypi ([`ed3ff91`](https://github.com/AI21Labs/ai21-python/commit/ed3ff91090f14ded7b9d1ae03fdff5ac935fbdc0)) +* fix: push to test pypi -* feat: SDK code (#3) +- 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)) * feat: Added code @@ -2905,8 +2866,6 @@ BREAKING CHANGE: pre release ([`b15d4c7`](https://github.com/AI21Labs/ai21-pytho * fix: test path -* fix: CR - * feat: Added bedrock session * feat: Added SageMakerSession @@ -2929,12 +2888,16 @@ BREAKING CHANGE: pre release ([`b15d4c7`](https://github.com/AI21Labs/ai21-pytho * ci: Added integration tests only on push to main -* fix: removed unused import ([`0e9b36a`](https://github.com/AI21Labs/ai21-python/commit/0e9b36aca7ab0a3800552c8929c6f4f7d1cd9e1f)) +* fix: removed unused import + +- Test pypi ([#7](https://github.com/AI21Labs/ai21-python/pull/7), + [`549d044`](https://github.com/AI21Labs/ai21-python/commit/549d0444e09e1af34b29e6d264c61bfe0c091dbe)) -### Fixes +* feat: release candidate -* fix: test pypi params (#8) ([`ed8fa1f`](https://github.com/AI21Labs/ai21-python/commit/ed8fa1f7b52b0ab6f94ed9815adf0256152dd02e)) +* ci: test pypi -### Unknown +* fix: version -* Initial commit ([`a2841de`](https://github.com/AI21Labs/ai21-python/commit/a2841dead1d9324d444fded170b64d280fef3394)) +- Version rc bump ([#12](https://github.com/AI21Labs/ai21-python/pull/12), + [`88ccbe2`](https://github.com/AI21Labs/ai21-python/commit/88ccbe2b0d35b1f1682b0fcf58ca1a755fa26739)) diff --git a/ai21/version.py b/ai21/version.py index aefeac31..2244a82d 100644 --- a/ai21/version.py +++ b/ai21/version.py @@ -1 +1 @@ -VERSION = "3.1.0-rc.3" +VERSION = "3.1.0-rc.4" diff --git a/pyproject.toml b/pyproject.toml index 663baa2b..8faae935 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ exclude_lines = [ [tool.poetry] name = "ai21" -version = "3.1.0-rc.3" +version = "3.1.0-rc.4" description = "" authors = ["AI21 Labs"] readme = "README.md" From c09170fdc2ce93aa768704aa343c769af654d686 Mon Sep 17 00:00:00 2001 From: Ben <23212294+benshuk@users.noreply.github.com> Date: Wed, 8 Jan 2025 12:52:22 +0200 Subject: [PATCH 35/50] refactor: :label: change `rag` tool resource to `file_search` (#251) Co-authored-by: benshuk --- ai21/models/assistant/assistant.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ai21/models/assistant/assistant.py b/ai21/models/assistant/assistant.py index cdb39f36..d9254b3b 100644 --- a/ai21/models/assistant/assistant.py +++ b/ai21/models/assistant/assistant.py @@ -3,10 +3,10 @@ from typing_extensions import TypedDict Optimization = Literal["cost", "latency"] -Tool = Literal["rag", "web_search", "plan_approval"] +Tool = Literal["file_search", "web_search", "plan_approval"] class ToolResources(TypedDict, total=False): - rag: Optional[dict] + file_search: Optional[dict] web_search: Optional[dict] plan_approval: Optional[dict] From d646e99cdd1dabca423b62e7e001ca58c5105594 Mon Sep 17 00:00:00 2001 From: Ben <23212294+benshuk@users.noreply.github.com> Date: Wed, 8 Jan 2025 14:20:54 +0200 Subject: [PATCH 36/50] fix: :bug: await needed for async `plans.create` (#252) Co-authored-by: benshuk --- .../studio/resources/beta/assistant/assistants_plans.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ai21/clients/studio/resources/beta/assistant/assistants_plans.py b/ai21/clients/studio/resources/beta/assistant/assistants_plans.py index 81d78eee..ff9a9b1e 100644 --- a/ai21/clients/studio/resources/beta/assistant/assistants_plans.py +++ b/ai21/clients/studio/resources/beta/assistant/assistants_plans.py @@ -78,7 +78,9 @@ async def create( **kwargs, ) - return self._post(path=f"/assistants/{assistant_id}/{self._module_name}", body=body, response_cls=PlanResponse) + return await self._post( + path=f"/assistants/{assistant_id}/{self._module_name}", body=body, response_cls=PlanResponse + ) async def list( self, From f2f7918fc0336bd026efb02e2228546f6abbcc5d Mon Sep 17 00:00:00 2001 From: semantic-release Date: Wed, 8 Jan 2025 12:24:53 +0000 Subject: [PATCH 37/50] chore(release): v3.1.0-rc.5 [skip ci] --- CHANGELOG.md | 41 +++++++++++++++++++++++++++++++++++++++++ ai21/version.py | 2 +- pyproject.toml | 2 +- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1f61aaf..5f89945d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,44 @@ # CHANGELOG +## 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> + +### 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 @@ -52,6 +90,9 @@ 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), diff --git a/ai21/version.py b/ai21/version.py index 2244a82d..55959252 100644 --- a/ai21/version.py +++ b/ai21/version.py @@ -1 +1 @@ -VERSION = "3.1.0-rc.4" +VERSION = "3.1.0-rc.5" diff --git a/pyproject.toml b/pyproject.toml index 8faae935..debe1b53 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ exclude_lines = [ [tool.poetry] name = "ai21" -version = "3.1.0-rc.4" +version = "3.1.0-rc.5" description = "" authors = ["AI21 Labs"] readme = "README.md" From 1714ccc8538e7e0329f4dc564a8d40c92b650d81 Mon Sep 17 00:00:00 2001 From: guyl25 <144776634+guyl25@users.noreply.github.com> Date: Wed, 8 Jan 2025 15:08:12 +0200 Subject: [PATCH 38/50] fix: do not require all fields for RequiredAction (#253) --- ai21/models/assistant/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ai21/models/assistant/run.py b/ai21/models/assistant/run.py index 715488e3..3d29eaa0 100644 --- a/ai21/models/assistant/run.py +++ b/ai21/models/assistant/run.py @@ -45,7 +45,7 @@ class SubmitInput(TypedDict): data: Dict[str, Any] -class RequiredAction(TypedDict): +class RequiredAction(TypedDict, total=False): type: Literal["submit_tool_outputs", "submit_input"] submit_tool_outputs: Optional[SubmitToolCallOutputs] = None submit_input: Optional[SubmitInput] = None From 0d8f3060e69947a1d9ac5627b392c1ffb4fc3151 Mon Sep 17 00:00:00 2001 From: semantic-release Date: Wed, 8 Jan 2025 15:29:48 +0000 Subject: [PATCH 39/50] chore(release): v3.1.0-rc.6 [skip ci] --- CHANGELOG.md | 12 ++++++++++++ ai21/version.py | 2 +- pyproject.toml | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f89945d..54874801 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,15 @@ # CHANGELOG +## 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)) + + ## v3.1.0-rc.5 (2025-01-08) ### Bug Fixes @@ -30,6 +39,9 @@ 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` diff --git a/ai21/version.py b/ai21/version.py index 55959252..5bb52a6b 100644 --- a/ai21/version.py +++ b/ai21/version.py @@ -1 +1 @@ -VERSION = "3.1.0-rc.5" +VERSION = "3.1.0-rc.6" diff --git a/pyproject.toml b/pyproject.toml index debe1b53..ecbad00d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ exclude_lines = [ [tool.poetry] name = "ai21" -version = "3.1.0-rc.5" +version = "3.1.0-rc.6" description = "" authors = ["AI21 Labs"] readme = "README.md" From 4a7dfe0c642321c2f58c56b747586d830b1ade05 Mon Sep 17 00:00:00 2001 From: guyl25 <144776634+guyl25@users.noreply.github.com> Date: Sun, 12 Jan 2025 15:58:45 +0200 Subject: [PATCH 40/50] fix: bad endpoint in async thread runs (#255) --- ai21/clients/studio/resources/beta/assistant/thread_runs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ai21/clients/studio/resources/beta/assistant/thread_runs.py b/ai21/clients/studio/resources/beta/assistant/thread_runs.py index 0ee5b217..555ad6c8 100644 --- a/ai21/clients/studio/resources/beta/assistant/thread_runs.py +++ b/ai21/clients/studio/resources/beta/assistant/thread_runs.py @@ -208,7 +208,7 @@ async def submit_input(self, *, thread_id: str, run_id: str, input: Any) -> RunR body = dict(input=input) return await self._post( - path=f"/threads/{thread_id}/{self._module_name}/{run_id}/submit_inputs", + path=f"/threads/{thread_id}/{self._module_name}/{run_id}/submit_input", body=body, response_cls=RunResponse, ) From 6d9d1a416dc070076175430fcdd18b56bd658e5b Mon Sep 17 00:00:00 2001 From: MichalAI21 <101511249+MichalAI21@users.noreply.github.com> Date: Mon, 13 Jan 2025 10:17:37 +0200 Subject: [PATCH 41/50] fix: change schemas field in PlanResponse to be optional (#257) --- ai21/models/responses/plan_response.py | 2 +- examples/studio/assistant/user_defined_plans.py | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ai21/models/responses/plan_response.py b/ai21/models/responses/plan_response.py index db0876a3..e8afa863 100644 --- a/ai21/models/responses/plan_response.py +++ b/ai21/models/responses/plan_response.py @@ -10,7 +10,7 @@ class PlanResponse(AI21BaseModel): updated_at: datetime assistant_id: str code: str - schemas: List[Dict[str, Any]] + schemas: Optional[List[Dict[str, Any]]] = None class ListPlanResponse(AI21BaseModel): diff --git a/examples/studio/assistant/user_defined_plans.py b/examples/studio/assistant/user_defined_plans.py index ba8e1f54..0273de18 100644 --- a/examples/studio/assistant/user_defined_plans.py +++ b/examples/studio/assistant/user_defined_plans.py @@ -4,7 +4,7 @@ TIMEOUT = 20 -def test_func(): +def func(): pass @@ -18,8 +18,15 @@ def main(): assistant = ai21_client.beta.assistants.create(name="My Assistant") - plan = ai21_client.beta.assistants.plans.create(assistant_id=assistant.id, code=test_func, schemas=[ExampleSchema]) - route = ai21_client.beta.assistants.routes.create( + 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" ) - print(f"Route: {route}") + 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() From 45d874cc46e382746cd3eaf2165222ff7318c7ca Mon Sep 17 00:00:00 2001 From: semantic-release Date: Mon, 13 Jan 2025 08:31:12 +0000 Subject: [PATCH 42/50] chore(release): v3.1.0-rc.7 [skip ci] --- CHANGELOG.md | 17 +++++++++++++++++ ai21/version.py | 2 +- pyproject.toml | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54874801..3dea4aea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,18 @@ # CHANGELOG +## 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)) + + ## v3.1.0-rc.6 (2025-01-08) ### Bug Fixes @@ -9,6 +21,11 @@ ([#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) diff --git a/ai21/version.py b/ai21/version.py index 5bb52a6b..8a0185ce 100644 --- a/ai21/version.py +++ b/ai21/version.py @@ -1 +1 @@ -VERSION = "3.1.0-rc.6" +VERSION = "3.1.0-rc.7" diff --git a/pyproject.toml b/pyproject.toml index ecbad00d..d5407110 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ exclude_lines = [ [tool.poetry] name = "ai21" -version = "3.1.0-rc.6" +version = "3.1.0-rc.7" description = "" authors = ["AI21 Labs"] readme = "README.md" From 0195f62ba33f2c5af0403f40e49d1a1865869a1a Mon Sep 17 00:00:00 2001 From: Ben <23212294+benshuk@users.noreply.github.com> Date: Tue, 14 Jan 2025 18:13:16 +0200 Subject: [PATCH 43/50] =?UTF-8?q?feat:=20=E2=9C=A8=20support=20deleting=20?= =?UTF-8?q?assistant=20(#258)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: :sparkles: support deleting assistant * fix: :recycle: assistant route description should be optional --------- Co-authored-by: benshuk --- ai21/clients/common/beta/assistant/assistants.py | 6 +++++- ai21/clients/common/beta/assistant/routes.py | 2 +- ai21/clients/studio/resources/beta/assistant/assistant.py | 8 +++++++- .../studio/resources/beta/assistant/assistant_routes.py | 4 ++-- ai21/models/responses/assistant_response.py | 6 ++++++ 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/ai21/clients/common/beta/assistant/assistants.py b/ai21/clients/common/beta/assistant/assistants.py index 7552cdbe..be8074dd 100644 --- a/ai21/clients/common/beta/assistant/assistants.py +++ b/ai21/clients/common/beta/assistant/assistants.py @@ -6,7 +6,7 @@ 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 +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 @@ -75,3 +75,7 @@ def modify( 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/routes.py b/ai21/clients/common/beta/assistant/routes.py index 38f0fff1..c34e30e3 100644 --- a/ai21/clients/common/beta/assistant/routes.py +++ b/ai21/clients/common/beta/assistant/routes.py @@ -18,8 +18,8 @@ def create( assistant_id: str, plan_id: str, name: str, - description: str, examples: List[str], + description: str | NotGiven = NOT_GIVEN, **kwargs, ) -> RouteResponse: pass diff --git a/ai21/clients/studio/resources/beta/assistant/assistant.py b/ai21/clients/studio/resources/beta/assistant/assistant.py index af129f12..b387db5a 100644 --- a/ai21/clients/studio/resources/beta/assistant/assistant.py +++ b/ai21/clients/studio/resources/beta/assistant/assistant.py @@ -12,7 +12,7 @@ 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 +from ai21.models.responses.assistant_response import AssistantResponse, ListAssistant, DeletedAssistantResponse from ai21.types import NotGiven, NOT_GIVEN @@ -76,6 +76,9 @@ def modify( 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): @@ -136,3 +139,6 @@ async def modify( ) 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 index d5fabb07..14bc6641 100644 --- a/ai21/clients/studio/resources/beta/assistant/assistant_routes.py +++ b/ai21/clients/studio/resources/beta/assistant/assistant_routes.py @@ -18,7 +18,7 @@ def create( assistant_id: str, plan_id: str, name: str, - description: str, + description: str | NotGiven = NOT_GIVEN, examples: List[str], **kwargs, ) -> RouteResponse: @@ -85,7 +85,7 @@ async def create( assistant_id: str, plan_id: str, name: str, - description: str, + description: str | NotGiven = NOT_GIVEN, examples: List[str], **kwargs, ) -> RouteResponse: diff --git a/ai21/models/responses/assistant_response.py b/ai21/models/responses/assistant_response.py index 0bf40c5f..77ed2c66 100644 --- a/ai21/models/responses/assistant_response.py +++ b/ai21/models/responses/assistant_response.py @@ -24,3 +24,9 @@ class AssistantResponse(AI21BaseModel): class ListAssistant(AI21BaseModel): results: List[AssistantResponse] + + +class DeletedAssistantResponse(AI21BaseModel): + object: Literal["assistant"] = "assistant" + deleted: bool = True + id: str From 7198db963dd9d922ec290ac5f9e79b941a116075 Mon Sep 17 00:00:00 2001 From: benshuk Date: Tue, 14 Jan 2025 18:16:01 +0200 Subject: [PATCH 44/50] chore: :recycle: thread messages should be optional --- ai21/clients/common/beta/assistant/threads.py | 16 +++++++++++++--- .../studio/resources/beta/assistant/thread.py | 11 ++++++----- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/ai21/clients/common/beta/assistant/threads.py b/ai21/clients/common/beta/assistant/threads.py index ff67ed60..68cc9460 100644 --- a/ai21/clients/common/beta/assistant/threads.py +++ b/ai21/clients/common/beta/assistant/threads.py @@ -1,11 +1,13 @@ from __future__ import annotations from abc import ABC, abstractmethod -from typing import List +from typing import List, Optional from ai21.clients.common.beta.assistant.messages import BaseMessages -from ai21.models.assistant.message import Message +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): @@ -15,11 +17,19 @@ class BaseThreads(ABC): @abstractmethod def create( self, - messages: List[Message], + 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}) + + if "messages" in body: + body["messages"] = [modify_message_content(message) for message in body["messages"]] + + return body + @abstractmethod def retrieve(self, thread_id: str) -> ThreadResponse: pass diff --git a/ai21/clients/studio/resources/beta/assistant/thread.py b/ai21/clients/studio/resources/beta/assistant/thread.py index 54ef0c1d..91279317 100644 --- a/ai21/clients/studio/resources/beta/assistant/thread.py +++ b/ai21/clients/studio/resources/beta/assistant/thread.py @@ -8,8 +8,9 @@ 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, modify_message_content +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): @@ -21,10 +22,10 @@ def __init__(self, client: AI21HTTPClient): def create( self, - messages: List[Message], + messages: List[Message] | NotGiven = NOT_GIVEN, **kwargs, ) -> ThreadResponse: - body = dict(messages=[modify_message_content(message) for message in messages]) + body = self._create_body(messages=messages, **kwargs) return self._post(path=f"/{self._module_name}", body=body, response_cls=ThreadResponse) @@ -41,10 +42,10 @@ def __init__(self, client: AsyncAI21HTTPClient): async def create( self, - messages: List[Message], + messages: List[Message] | NotGiven = NOT_GIVEN, **kwargs, ) -> ThreadResponse: - body = dict(messages=[modify_message_content(message) for message in messages]) + body = self._create_body(messages=messages, **kwargs) return await self._post(path=f"/{self._module_name}", body=body, response_cls=ThreadResponse) From 9b73967be1762d8cd0e772a7455dc9db6ebbb9c0 Mon Sep 17 00:00:00 2001 From: Ben <23212294+benshuk@users.noreply.github.com> Date: Tue, 21 Jan 2025 11:07:54 +0200 Subject: [PATCH 45/50] =?UTF-8?q?fix:=20=F0=9F=90=9B=20create=20thread=20w?= =?UTF-8?q?ithout=20messages=20plz=20(#260)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: :bug: create thread without messages plz * docs: :memo: update assistant example --------- Co-authored-by: benshuk --- ai21/clients/common/beta/assistant/threads.py | 3 +-- examples/studio/assistant/assistant.py | 11 +++-------- examples/studio/assistant/async_assistant.py | 11 +++-------- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/ai21/clients/common/beta/assistant/threads.py b/ai21/clients/common/beta/assistant/threads.py index 68cc9460..883b75c0 100644 --- a/ai21/clients/common/beta/assistant/threads.py +++ b/ai21/clients/common/beta/assistant/threads.py @@ -25,8 +25,7 @@ def create( def _create_body(self, messages: List[Message] | NotGiven, **kwargs) -> Optional[dict]: body = remove_not_given({"messages": messages, **kwargs}) - if "messages" in body: - body["messages"] = [modify_message_content(message) for message in body["messages"]] + body["messages"] = [modify_message_content(message) for message in body.get("messages", [])] return body diff --git a/examples/studio/assistant/assistant.py b/examples/studio/assistant/assistant.py index a3ba465c..e0628f29 100644 --- a/examples/studio/assistant/assistant.py +++ b/examples/studio/assistant/assistant.py @@ -6,14 +6,9 @@ def main(): assistant = ai21_client.beta.assistants.create(name="My Assistant") - thread = ai21_client.beta.threads.create( - messages=[ - { - "role": "user", - "content": "Hello", - }, - ] - ) + 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, diff --git a/examples/studio/assistant/async_assistant.py b/examples/studio/assistant/async_assistant.py index f0cf4b90..cc4d1ae7 100644 --- a/examples/studio/assistant/async_assistant.py +++ b/examples/studio/assistant/async_assistant.py @@ -8,14 +8,9 @@ async def main(): assistant = await ai21_client.beta.assistants.create(name="My Assistant") - thread = await ai21_client.beta.threads.create( - messages=[ - { - "role": "user", - "content": "Hello", - }, - ] - ) + 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, From aedf04a4d70e005f4f3ae6bc046cd43766ca5cdd Mon Sep 17 00:00:00 2001 From: semantic-release Date: Tue, 21 Jan 2025 15:08:38 +0000 Subject: [PATCH 46/50] chore(release): v3.1.0-rc.8 [skip ci] --- CHANGELOG.md | 39 +++++++++++++++++++++++++++++++++++++++ ai21/version.py | 2 +- pyproject.toml | 2 +- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3dea4aea..5f25591d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,40 @@ # 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 @@ -12,6 +46,11 @@ ([#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) diff --git a/ai21/version.py b/ai21/version.py index 8a0185ce..9408db31 100644 --- a/ai21/version.py +++ b/ai21/version.py @@ -1 +1 @@ -VERSION = "3.1.0-rc.7" +VERSION = "3.1.0-rc.8" diff --git a/pyproject.toml b/pyproject.toml index d5407110..e00ce9ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ exclude_lines = [ [tool.poetry] name = "ai21" -version = "3.1.0-rc.7" +version = "3.1.0-rc.8" description = "" authors = ["AI21 Labs"] readme = "README.md" From 9b7cbfc14ec7bb521f612494b1a764bbca4ca375 Mon Sep 17 00:00:00 2001 From: bennyr21 Date: Mon, 27 Jan 2025 16:21:11 +0200 Subject: [PATCH 47/50] fix: change tool to a dict --- ai21/clients/common/beta/assistant/assistants.py | 4 ++-- ai21/clients/studio/resources/beta/assistant/assistant.py | 8 ++++---- ai21/models/responses/assistant_response.py | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ai21/clients/common/beta/assistant/assistants.py b/ai21/clients/common/beta/assistant/assistants.py index be8074dd..6f910956 100644 --- a/ai21/clients/common/beta/assistant/assistants.py +++ b/ai21/clients/common/beta/assistant/assistants.py @@ -24,7 +24,7 @@ def create( description: str | NotGiven = NOT_GIVEN, optimization: Optimization | NotGiven = NOT_GIVEN, models: List[str] | NotGiven = NOT_GIVEN, - tools: List[Tool] | NotGiven = NOT_GIVEN, + tools: List[dict[str, Tool]] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, **kwargs, ) -> AssistantResponse: @@ -71,7 +71,7 @@ def modify( optimization: Optimization | NotGiven = NOT_GIVEN, is_archived: bool | NotGiven = NOT_GIVEN, models: List[str] | NotGiven = NOT_GIVEN, - tools: List[Tool] | NotGiven = NOT_GIVEN, + tools: List[dict[str, Tool]] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, ) -> AssistantResponse: pass diff --git a/ai21/clients/studio/resources/beta/assistant/assistant.py b/ai21/clients/studio/resources/beta/assistant/assistant.py index b387db5a..5caf25fa 100644 --- a/ai21/clients/studio/resources/beta/assistant/assistant.py +++ b/ai21/clients/studio/resources/beta/assistant/assistant.py @@ -30,7 +30,7 @@ def create( description: str | NotGiven = NOT_GIVEN, optimization: str | NotGiven = NOT_GIVEN, models: List[str] | NotGiven = NOT_GIVEN, - tools: List[Tool] | NotGiven = NOT_GIVEN, + tools: List[dict[str, Tool]] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, **kwargs, ) -> AssistantResponse: @@ -61,7 +61,7 @@ def modify( optimization: str | NotGiven = NOT_GIVEN, is_archived: bool | NotGiven = NOT_GIVEN, models: List[str] | NotGiven = NOT_GIVEN, - tools: List[Tool] | NotGiven = NOT_GIVEN, + tools: List[dict[str, Tool]] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, ) -> AssistantResponse: body = self._create_body( @@ -94,7 +94,7 @@ async def create( description: str | NotGiven = NOT_GIVEN, optimization: str | NotGiven = NOT_GIVEN, models: List[str] | NotGiven = NOT_GIVEN, - tools: List[Tool] | NotGiven = NOT_GIVEN, + tools: List[dict[str, Tool]] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, **kwargs, ) -> AssistantResponse: @@ -125,7 +125,7 @@ async def modify( optimization: str | NotGiven = NOT_GIVEN, is_archived: bool | NotGiven = NOT_GIVEN, models: List[str] | NotGiven = NOT_GIVEN, - tools: List[Tool] | NotGiven = NOT_GIVEN, + tools: List[dict[str, Tool]] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, ) -> AssistantResponse: body = self._create_body( diff --git a/ai21/models/responses/assistant_response.py b/ai21/models/responses/assistant_response.py index 77ed2c66..ab6c1017 100644 --- a/ai21/models/responses/assistant_response.py +++ b/ai21/models/responses/assistant_response.py @@ -1,5 +1,5 @@ from datetime import datetime -from typing import Optional, List, Literal +from typing import Optional, List, Literal, Any from ai21.models.ai21_base_model import AI21BaseModel from ai21.models.assistant.assistant import ToolResources @@ -18,7 +18,7 @@ class AssistantResponse(AI21BaseModel): avatar: Optional[str] = None is_archived: bool = False models: Optional[List[str]] = None - tools: Optional[List[str]] = None + tools: Optional[List[dict[str, Any]]] = None tool_resources: Optional[ToolResources] = None From cc3984fa43a37d77957ace37019f79a54eb85caa Mon Sep 17 00:00:00 2001 From: bennyr21 Date: Mon, 27 Jan 2025 17:34:33 +0200 Subject: [PATCH 48/50] fix: pre commit --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From e70e1f8f0608b8329ecb7a8480b8b0d873fc096b Mon Sep 17 00:00:00 2001 From: bennyr21 Date: Tue, 28 Jan 2025 13:26:11 +0200 Subject: [PATCH 49/50] fix: tools --- ai21/clients/common/beta/assistant/assistants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ai21/clients/common/beta/assistant/assistants.py b/ai21/clients/common/beta/assistant/assistants.py index 6f910956..068f9302 100644 --- a/ai21/clients/common/beta/assistant/assistants.py +++ b/ai21/clients/common/beta/assistant/assistants.py @@ -37,7 +37,7 @@ def _create_body( description: str | NotGiven, optimization: str | NotGiven, models: List[str] | NotGiven, - tools: List[str] | NotGiven, + tools: List[dict[str, Tool]] | NotGiven, tool_resources: dict | NotGiven, **kwargs, ) -> Dict[str, Any]: From 5cb61b84d70af2a44d83236047dcb8f6412aef2b Mon Sep 17 00:00:00 2001 From: Lior Benita Date: Tue, 28 Jan 2025 15:30:08 +0200 Subject: [PATCH 50/50] chore: fix dict to Dict big D --- ai21/clients/common/beta/assistant/assistants.py | 6 +++--- .../studio/resources/beta/assistant/assistant.py | 10 +++++----- ai21/models/responses/assistant_response.py | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ai21/clients/common/beta/assistant/assistants.py b/ai21/clients/common/beta/assistant/assistants.py index 068f9302..4e4f0c2d 100644 --- a/ai21/clients/common/beta/assistant/assistants.py +++ b/ai21/clients/common/beta/assistant/assistants.py @@ -24,7 +24,7 @@ def create( description: str | NotGiven = NOT_GIVEN, optimization: Optimization | NotGiven = NOT_GIVEN, models: List[str] | NotGiven = NOT_GIVEN, - tools: List[dict[str, Tool]] | NotGiven = NOT_GIVEN, + tools: List[Dict[str, Tool]] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, **kwargs, ) -> AssistantResponse: @@ -37,7 +37,7 @@ def _create_body( description: str | NotGiven, optimization: str | NotGiven, models: List[str] | NotGiven, - tools: List[dict[str, Tool]] | NotGiven, + tools: List[Dict[str, Tool]] | NotGiven, tool_resources: dict | NotGiven, **kwargs, ) -> Dict[str, Any]: @@ -71,7 +71,7 @@ def modify( 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, + tools: List[Dict[str, Tool]] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, ) -> AssistantResponse: pass diff --git a/ai21/clients/studio/resources/beta/assistant/assistant.py b/ai21/clients/studio/resources/beta/assistant/assistant.py index 5caf25fa..50cae6c3 100644 --- a/ai21/clients/studio/resources/beta/assistant/assistant.py +++ b/ai21/clients/studio/resources/beta/assistant/assistant.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import List +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 @@ -30,7 +30,7 @@ def create( description: str | NotGiven = NOT_GIVEN, optimization: str | NotGiven = NOT_GIVEN, models: List[str] | NotGiven = NOT_GIVEN, - tools: List[dict[str, Tool]] | NotGiven = NOT_GIVEN, + tools: List[Dict[str, Tool]] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, **kwargs, ) -> AssistantResponse: @@ -61,7 +61,7 @@ def modify( 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, + tools: List[Dict[str, Tool]] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, ) -> AssistantResponse: body = self._create_body( @@ -94,7 +94,7 @@ async def create( description: str | NotGiven = NOT_GIVEN, optimization: str | NotGiven = NOT_GIVEN, models: List[str] | NotGiven = NOT_GIVEN, - tools: List[dict[str, Tool]] | NotGiven = NOT_GIVEN, + tools: List[Dict[str, Tool]] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, **kwargs, ) -> AssistantResponse: @@ -125,7 +125,7 @@ async def modify( 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, + tools: List[Dict[str, Tool]] | NotGiven = NOT_GIVEN, tool_resources: ToolResources | NotGiven = NOT_GIVEN, ) -> AssistantResponse: body = self._create_body( diff --git a/ai21/models/responses/assistant_response.py b/ai21/models/responses/assistant_response.py index ab6c1017..ed63c296 100644 --- a/ai21/models/responses/assistant_response.py +++ b/ai21/models/responses/assistant_response.py @@ -1,5 +1,5 @@ from datetime import datetime -from typing import Optional, List, Literal, Any +from typing import Optional, List, Literal, Any, Dict from ai21.models.ai21_base_model import AI21BaseModel from ai21.models.assistant.assistant import ToolResources @@ -18,7 +18,7 @@ class AssistantResponse(AI21BaseModel): avatar: Optional[str] = None is_archived: bool = False models: Optional[List[str]] = None - tools: Optional[List[dict[str, Any]]] = None + tools: Optional[List[Dict[str, Any]]] = None tool_resources: Optional[ToolResources] = None