Skip to content

Commit c944172

Browse files
author
benshuk
committed
fix: 🚚 move classes and such
1 parent ae7a3e4 commit c944172

File tree

7 files changed

+40
-57
lines changed

7 files changed

+40
-57
lines changed

ai21/clients/common/assistant/assistants.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@
33
from abc import ABC, abstractmethod
44
from typing import Any, Dict, List
55

6-
from ai21.models.assistant.assistant import Optimization, Tool
7-
from ai21.models.responses.assistant_response import (
8-
Assistant,
9-
ToolResources,
10-
ListAssistant,
11-
)
6+
from ai21.models.assistant.assistant import Optimization, Tool, ToolResources
7+
from ai21.models.responses.assistant_response import Assistant, ListAssistant
128
from ai21.types import NotGiven, NOT_GIVEN
139
from ai21.utils.typing import remove_not_given
1410

ai21/clients/common/assistant/threads.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,15 @@
33
from abc import ABC, abstractmethod
44
from typing import List
55

6-
from ai21.models.assistant.thread_message import CreateThreadMessagePayload
6+
from ai21.models.assistant.message import Message
77
from ai21.models.responses.thread_response import Thread
88

99

1010
class Threads(ABC):
1111
_module_name = "threads"
1212

1313
@abstractmethod
14-
def create(
15-
self,
16-
messages: List[CreateThreadMessagePayload],
17-
**kwargs,
18-
) -> Thread:
14+
def create(self, messages: List[Message], **kwargs) -> Thread:
1915
pass
2016

2117
@abstractmethod

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,8 @@
77
AsyncStudioResource,
88
StudioResource,
99
)
10-
from ai21.models.responses.assistant_response import (
11-
Assistant,
12-
Tool,
13-
ToolResources,
14-
ListAssistant,
15-
)
10+
from ai21.models.assistant.assistant import Tool, ToolResources
11+
from ai21.models.responses.assistant_response import Assistant, ListAssistant
1612
from ai21.types import NotGiven, NOT_GIVEN
1713

1814

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

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@
44

55
from ai21.clients.common.assistant.threads import Threads
66
from ai21.clients.studio.resources.studio_resource import StudioResource, AsyncStudioResource
7-
from ai21.models.responses.thread_response import CreateThreadMessagePayload, Thread
7+
from ai21.models.assistant.message import Message
8+
from ai21.models.responses.thread_response import Thread
89

910

1011
class StudioThread(StudioResource, Threads):
11-
def create(
12-
self,
13-
messages: List[CreateThreadMessagePayload],
14-
**kwargs,
15-
) -> Thread:
12+
def create(self, messages: List[Message], **kwargs) -> Thread:
1613
body = dict(messages=messages)
1714

1815
return self._post(path=f"/{self._module_name}", body=body, response_cls=Thread)
@@ -22,11 +19,7 @@ def get(self, thread_id: str) -> Thread:
2219

2320

2421
class AsyncStudioThread(AsyncStudioResource, Threads):
25-
async def create(
26-
self,
27-
messages: List[CreateThreadMessagePayload],
28-
**kwargs,
29-
) -> Thread:
22+
async def create(self, messages: List[Message], **kwargs) -> Thread:
3023
body = dict(messages=messages)
3124

3225
return await self._post(path=f"/{self._module_name}", body=body, response_cls=Thread)

ai21/models/assistant/message.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from datetime import datetime
2+
from typing import Literal, Optional
3+
4+
from typing_extensions import TypedDict
5+
6+
from ai21.models.ai21_base_model import AI21BaseModel
7+
8+
ThreadMessageRole = Literal["assistant", "user"]
9+
10+
11+
class MessageContentText(TypedDict):
12+
type: Literal["text"]
13+
text: str
14+
15+
16+
class Message(TypedDict):
17+
role: ThreadMessageRole
18+
content: MessageContentText
19+
20+
21+
class MessageResponse(AI21BaseModel):
22+
id: str
23+
created_at: datetime
24+
updated_at: datetime
25+
object: Literal["message"] = "message"
26+
role: ThreadMessageRole
27+
content: MessageContentText
28+
run_id: Optional[str] = None
29+
assistant_id: Optional[str] = None

ai21/models/assistant/thread_message.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

ai21/models/responses/thread_response.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
11
from datetime import datetime
2-
from typing import Optional, List, Literal
2+
from typing import List, Literal
33

44
from ai21.models.ai21_base_model import AI21BaseModel
5-
from ai21.models.assistant.thread_message import ThreadMessageRole, ThreadMessageContentText
6-
7-
8-
class ThreadMessage(AI21BaseModel):
9-
id: str
10-
created_at: datetime
11-
updated_at: datetime
12-
object: Literal["message"] = "message"
13-
role: ThreadMessageRole
14-
content: ThreadMessageContentText
15-
run_id: Optional[str] = None
16-
assistant_id: Optional[str] = None
175

186

197
class Thread(AI21BaseModel):

0 commit comments

Comments
 (0)