Skip to content

Commit

Permalink
feat: ✨ support deleting assistant (#258)
Browse files Browse the repository at this point in the history
* feat: ✨ support deleting assistant

* fix: ♻️ assistant route description should be optional

---------

Co-authored-by: benshuk <[email protected]>
  • Loading branch information
benshuk and benshuk authored Jan 14, 2025
1 parent 45d874c commit 0195f62
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
6 changes: 5 additions & 1 deletion ai21/clients/common/beta/assistant/assistants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -75,3 +75,7 @@ def modify(
tool_resources: ToolResources | NotGiven = NOT_GIVEN,
) -> AssistantResponse:
pass

@abstractmethod
def delete(self, assistant_id: str) -> DeletedAssistantResponse:
pass
2 changes: 1 addition & 1 deletion ai21/clients/common/beta/assistant/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion ai21/clients/studio/resources/beta/assistant/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions ai21/models/responses/assistant_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0195f62

Please sign in to comment.