Skip to content

Commit 0195f62

Browse files
benshukbenshuk
and
benshuk
authored
feat: ✨ support deleting assistant (#258)
* feat: ✨ support deleting assistant * fix: ♻️ assistant route description should be optional --------- Co-authored-by: benshuk <[email protected]>
1 parent 45d874c commit 0195f62

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

ai21/clients/common/beta/assistant/assistants.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from ai21.clients.common.beta.assistant.plans import BasePlans
77
from ai21.clients.common.beta.assistant.routes import BaseRoutes
88
from ai21.models.assistant.assistant import Optimization, Tool, ToolResources
9-
from ai21.models.responses.assistant_response import AssistantResponse, ListAssistant
9+
from ai21.models.responses.assistant_response import AssistantResponse, ListAssistant, DeletedAssistantResponse
1010
from ai21.types import NotGiven, NOT_GIVEN
1111
from ai21.utils.typing import remove_not_given
1212

@@ -75,3 +75,7 @@ def modify(
7575
tool_resources: ToolResources | NotGiven = NOT_GIVEN,
7676
) -> AssistantResponse:
7777
pass
78+
79+
@abstractmethod
80+
def delete(self, assistant_id: str) -> DeletedAssistantResponse:
81+
pass

ai21/clients/common/beta/assistant/routes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ def create(
1818
assistant_id: str,
1919
plan_id: str,
2020
name: str,
21-
description: str,
2221
examples: List[str],
22+
description: str | NotGiven = NOT_GIVEN,
2323
**kwargs,
2424
) -> RouteResponse:
2525
pass

ai21/clients/studio/resources/beta/assistant/assistant.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from ai21.http_client.async_http_client import AsyncAI21HTTPClient
1313
from ai21.http_client.http_client import AI21HTTPClient
1414
from ai21.models.assistant.assistant import Tool, ToolResources
15-
from ai21.models.responses.assistant_response import AssistantResponse, ListAssistant
15+
from ai21.models.responses.assistant_response import AssistantResponse, ListAssistant, DeletedAssistantResponse
1616
from ai21.types import NotGiven, NOT_GIVEN
1717

1818

@@ -76,6 +76,9 @@ def modify(
7676

7777
return self._patch(path=f"/{self._module_name}/{assistant_id}", body=body, response_cls=AssistantResponse)
7878

79+
def delete(self, assistant_id: str) -> DeletedAssistantResponse:
80+
return self._delete(path=f"/{self._module_name}/{assistant_id}", response_cls=DeletedAssistantResponse)
81+
7982

8083
class AsyncAssistants(AsyncStudioResource, BaseAssistants):
8184
def __init__(self, client: AsyncAI21HTTPClient):
@@ -136,3 +139,6 @@ async def modify(
136139
)
137140

138141
return await self._patch(path=f"/{self._module_name}/{assistant_id}", body=body, response_cls=AssistantResponse)
142+
143+
async def delete(self, assistant_id: str) -> DeletedAssistantResponse:
144+
return await self._delete(path=f"/{self._module_name}/{assistant_id}", response_cls=DeletedAssistantResponse)

ai21/clients/studio/resources/beta/assistant/assistant_routes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def create(
1818
assistant_id: str,
1919
plan_id: str,
2020
name: str,
21-
description: str,
21+
description: str | NotGiven = NOT_GIVEN,
2222
examples: List[str],
2323
**kwargs,
2424
) -> RouteResponse:
@@ -85,7 +85,7 @@ async def create(
8585
assistant_id: str,
8686
plan_id: str,
8787
name: str,
88-
description: str,
88+
description: str | NotGiven = NOT_GIVEN,
8989
examples: List[str],
9090
**kwargs,
9191
) -> RouteResponse:

ai21/models/responses/assistant_response.py

+6
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,9 @@ class AssistantResponse(AI21BaseModel):
2424

2525
class ListAssistant(AI21BaseModel):
2626
results: List[AssistantResponse]
27+
28+
29+
class DeletedAssistantResponse(AI21BaseModel):
30+
object: Literal["assistant"] = "assistant"
31+
deleted: bool = True
32+
id: str

0 commit comments

Comments
 (0)