From 9b7cbfc14ec7bb521f612494b1a764bbca4ca375 Mon Sep 17 00:00:00 2001 From: bennyr21 Date: Mon, 27 Jan 2025 16:21:11 +0200 Subject: [PATCH 1/4] 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 2/4] 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 3/4] 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 4/4] 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