Skip to content

Commit ac2cf61

Browse files
taskingaijcjameszyao
authored andcommitted
feat: update enum name (TaskingAI#9)
* feat: update enum name (TaskingAI#5) * fix: update enum and code version * refactor: update enum name * test:fix testcase --------- Co-authored-by: James Yao <[email protected]>
1 parent eca7202 commit ac2cf61

28 files changed

+252
-1424
lines changed

examples/assistant/chat_with_assistant.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
" \"No matter what the user's language is, you will use the {{langugae}} to explain.\"\n",
129129
" ],\n",
130130
" tools=[AssistantTool(\n",
131-
" type=AssistantToolType.action,\n",
131+
" type=AssistantToolType.ACTION,\n",
132132
" id=action.action_id,\n",
133133
" )],\n",
134134
" retrievals=[],\n",

taskingai/assistant/assistant.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def list_assistants(
5858
if after and before:
5959
raise ValueError("Only one of after and before can be specified.")
6060

61-
api_instance = get_api_instance(ModuleType.assistant)
61+
api_instance = get_api_instance(ModuleType.ASSISTANT)
6262
# only add non-None parameters
6363
params = {
6464
"order": order,
@@ -91,7 +91,7 @@ async def a_list_assistants(
9191
if after and before:
9292
raise ValueError("Only one of after and before can be specified.")
9393

94-
api_instance = get_api_instance(ModuleType.assistant, async_client=True)
94+
api_instance = get_api_instance(ModuleType.ASSISTANT, async_client=True)
9595
# only add non-None parameters
9696
params = {
9797
"order": order,
@@ -113,7 +113,7 @@ def get_assistant(assistant_id: str) -> Assistant:
113113
:param assistant_id: The ID of the assistant.
114114
"""
115115

116-
api_instance = get_api_instance(ModuleType.assistant)
116+
api_instance = get_api_instance(ModuleType.ASSISTANT)
117117
response: AssistantGetResponse = api_instance.get_assistant(assistant_id=assistant_id)
118118
assistant: Assistant = Assistant(**response.data)
119119
return assistant
@@ -126,7 +126,7 @@ async def a_get_assistant(assistant_id: str) -> Assistant:
126126
:param assistant_id: The ID of the assistant.
127127
"""
128128

129-
api_instance = get_api_instance(ModuleType.assistant, async_client=True)
129+
api_instance = get_api_instance(ModuleType.ASSISTANT, async_client=True)
130130
response: AssistantGetResponse = await api_instance.get_assistant(assistant_id=assistant_id)
131131
assistant: Assistant = Assistant(**response.data)
132132
return assistant
@@ -156,7 +156,7 @@ def create_assistant(
156156
:return: The created assistant object.
157157
"""
158158

159-
api_instance = get_api_instance(ModuleType.assistant)
159+
api_instance = get_api_instance(ModuleType.ASSISTANT)
160160
memory_dict = memory.model_dump()
161161
body = AssistantCreateRequest(
162162
model_id=model_id,
@@ -197,7 +197,7 @@ async def a_create_assistant(
197197
:return: The created assistant object.
198198
"""
199199

200-
api_instance = get_api_instance(ModuleType.assistant, async_client=True)
200+
api_instance = get_api_instance(ModuleType.ASSISTANT, async_client=True)
201201
memory_dict = memory.model_dump()
202202
body = AssistantCreateRequest(
203203
model_id=model_id,
@@ -240,7 +240,7 @@ def update_assistant(
240240
:return: The updated assistant object.
241241
"""
242242

243-
api_instance = get_api_instance(ModuleType.assistant)
243+
api_instance = get_api_instance(ModuleType.ASSISTANT)
244244
body = AssistantUpdateRequest(
245245
model_id=model_id,
246246
name=name,
@@ -282,7 +282,7 @@ async def a_update_assistant(
282282
:return: The updated assistant object.
283283
"""
284284

285-
api_instance = get_api_instance(ModuleType.assistant, async_client=True)
285+
api_instance = get_api_instance(ModuleType.ASSISTANT, async_client=True)
286286
body = AssistantUpdateRequest(
287287
model_id=model_id,
288288
name=name,
@@ -305,7 +305,7 @@ def delete_assistant(assistant_id: str) -> None:
305305
:param assistant_id: The ID of the assistant.
306306
"""
307307

308-
api_instance = get_api_instance(ModuleType.assistant)
308+
api_instance = get_api_instance(ModuleType.ASSISTANT)
309309
api_instance.delete_assistant(assistant_id=assistant_id)
310310

311311

@@ -316,6 +316,6 @@ async def a_delete_assistant(assistant_id: str) -> None:
316316
:param assistant_id: The ID of the assistant.
317317
"""
318318

319-
api_instance = get_api_instance(ModuleType.assistant, async_client=True)
319+
api_instance = get_api_instance(ModuleType.ASSISTANT, async_client=True)
320320
await api_instance.delete_assistant(assistant_id=assistant_id)
321321

taskingai/assistant/chat.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def list_chats(
4040
if after and before:
4141
raise ValueError("Only one of after and before can be specified.")
4242

43-
api_instance = get_api_instance(ModuleType.assistant)
43+
api_instance = get_api_instance(ModuleType.ASSISTANT)
4444
# only add non-None parameters
4545
params = {
4646
"order": order,
@@ -76,7 +76,7 @@ async def a_list_chats(
7676
if after and before:
7777
raise ValueError("Only one of after and before can be specified.")
7878

79-
api_instance = get_api_instance(ModuleType.assistant, async_client=True)
79+
api_instance = get_api_instance(ModuleType.ASSISTANT, async_client=True)
8080
# only add non-None parameters
8181
params = {
8282
"order": order,
@@ -101,7 +101,7 @@ def get_chat(assistant_id: str, chat_id: str) -> Chat:
101101
:param chat_id: The ID of the chat.
102102
"""
103103

104-
api_instance = get_api_instance(ModuleType.assistant)
104+
api_instance = get_api_instance(ModuleType.ASSISTANT)
105105
response: ChatGetResponse = api_instance.get_chat(
106106
assistant_id=assistant_id,
107107
chat_id=chat_id,
@@ -118,7 +118,7 @@ async def a_get_chat(assistant_id: str, chat_id: str) -> Chat:
118118
:param chat_id: The ID of the chat.
119119
"""
120120

121-
api_instance = get_api_instance(ModuleType.assistant, async_client=True)
121+
api_instance = get_api_instance(ModuleType.ASSISTANT, async_client=True)
122122
response: ChatGetResponse = await api_instance.get_chat(
123123
assistant_id=assistant_id,
124124
chat_id=chat_id,
@@ -139,7 +139,7 @@ def create_chat(
139139
:return: The created chat object.
140140
"""
141141

142-
api_instance = get_api_instance(ModuleType.assistant)
142+
api_instance = get_api_instance(ModuleType.ASSISTANT)
143143
body = ChatCreateRequest(
144144
metadata=metadata,
145145
)
@@ -163,7 +163,7 @@ async def a_create_chat(
163163
:return: The created chat object.
164164
"""
165165

166-
api_instance = get_api_instance(ModuleType.assistant, async_client=True)
166+
api_instance = get_api_instance(ModuleType.ASSISTANT, async_client=True)
167167
body = ChatCreateRequest(
168168
metadata=metadata,
169169
)
@@ -189,7 +189,7 @@ def update_chat(
189189
:return: The updated chat object.
190190
"""
191191

192-
api_instance = get_api_instance(ModuleType.assistant)
192+
api_instance = get_api_instance(ModuleType.ASSISTANT)
193193
body = ChatUpdateRequest(
194194
metadata=metadata,
195195
)
@@ -216,7 +216,7 @@ async def a_update_chat(
216216
:return: The updated chat object.
217217
"""
218218

219-
api_instance = get_api_instance(ModuleType.assistant, async_client=True)
219+
api_instance = get_api_instance(ModuleType.ASSISTANT, async_client=True)
220220
body = ChatUpdateRequest(
221221
metadata=metadata,
222222
)
@@ -240,7 +240,7 @@ def delete_chat(
240240
:param chat_id: The ID of the chat.
241241
"""
242242

243-
api_instance = get_api_instance(ModuleType.assistant)
243+
api_instance = get_api_instance(ModuleType.ASSISTANT)
244244
api_instance.delete_chat(assistant_id=assistant_id, chat_id=chat_id)
245245

246246

@@ -255,7 +255,7 @@ async def a_delete_chat(
255255
:param chat_id: The ID of the chat.
256256
"""
257257

258-
api_instance = get_api_instance(ModuleType.assistant, async_client=True)
258+
api_instance = get_api_instance(ModuleType.ASSISTANT, async_client=True)
259259
await api_instance.delete_chat(assistant_id=assistant_id, chat_id=chat_id)
260260

261261

taskingai/assistant/message.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def list_messages(
5656
if after and before:
5757
raise ValueError("Only one of after and before can be specified.")
5858

59-
api_instance = get_api_instance(ModuleType.assistant)
59+
api_instance = get_api_instance(ModuleType.ASSISTANT)
6060
# only add non-None parameters
6161
params = {
6262
"order": order,
@@ -96,7 +96,7 @@ async def a_list_messages(
9696
if after and before:
9797
raise ValueError("Only one of after and before can be specified.")
9898

99-
api_instance = get_api_instance(ModuleType.assistant, async_client=True)
99+
api_instance = get_api_instance(ModuleType.ASSISTANT, async_client=True)
100100
# only add non-None parameters
101101
params = {
102102
"order": order,
@@ -127,7 +127,7 @@ def get_message(
127127
:param message_id: The ID of the message.
128128
"""
129129

130-
api_instance = get_api_instance(ModuleType.assistant)
130+
api_instance = get_api_instance(ModuleType.ASSISTANT)
131131
response: MessageGetResponse = api_instance.get_message(
132132
assistant_id=assistant_id,
133133
chat_id=chat_id,
@@ -150,7 +150,7 @@ async def a_get_message(
150150
:param message_id: The ID of the message.
151151
"""
152152

153-
api_instance = get_api_instance(ModuleType.assistant, async_client=True)
153+
api_instance = get_api_instance(ModuleType.ASSISTANT, async_client=True)
154154
response: MessageGetResponse = await api_instance.get_message(
155155
assistant_id=assistant_id,
156156
chat_id=chat_id,
@@ -177,9 +177,9 @@ def create_message(
177177
:return: The created message object.
178178
"""
179179

180-
api_instance = get_api_instance(ModuleType.assistant)
180+
api_instance = get_api_instance(ModuleType.ASSISTANT)
181181
body = MessageCreateRequest(
182-
role=MessageRole.user,
182+
role=MessageRole.USER,
183183
content=MessageContent(text=text),
184184
metadata=metadata,
185185
)
@@ -208,9 +208,9 @@ async def a_create_message(
208208
:return: The created message object.
209209
"""
210210

211-
api_instance = get_api_instance(ModuleType.assistant, async_client=True)
211+
api_instance = get_api_instance(ModuleType.ASSISTANT, async_client=True)
212212
body = MessageCreateRequest(
213-
role=MessageRole.user,
213+
role=MessageRole.USER,
214214
content=MessageContent(text=text),
215215
metadata=metadata,
216216
)
@@ -238,7 +238,7 @@ def update_message(
238238
:return: The updated message object.
239239
"""
240240

241-
api_instance = get_api_instance(ModuleType.assistant)
241+
api_instance = get_api_instance(ModuleType.ASSISTANT)
242242
body = MessageUpdateRequest(
243243
metadata=metadata,
244244
)
@@ -267,7 +267,7 @@ async def a_update_message(
267267
:return: The updated message object.
268268
"""
269269

270-
api_instance = get_api_instance(ModuleType.assistant, async_client=True)
270+
api_instance = get_api_instance(ModuleType.ASSISTANT, async_client=True)
271271
body = MessageUpdateRequest(
272272
metadata=metadata,
273273
)
@@ -298,7 +298,7 @@ def generate_message(
298298
:return: The generated message object.
299299
"""
300300

301-
api_instance = get_api_instance(ModuleType.assistant)
301+
api_instance = get_api_instance(ModuleType.ASSISTANT)
302302
body = MessageGenerateRequest(
303303
system_prompt_variables=system_prompt_variables,
304304
stream=stream,
@@ -339,7 +339,7 @@ async def a_generate_message(
339339
:return: The generated message object.
340340
"""
341341

342-
api_instance = get_api_instance(ModuleType.assistant, async_client=True)
342+
api_instance = get_api_instance(ModuleType.ASSISTANT, async_client=True)
343343
body = MessageGenerateRequest(
344344
system_prompt_variables=system_prompt_variables,
345345
stream=stream,

taskingai/client/constants.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
DEFAULT_PARENT_LOGGER_LEVEL = 'ERROR'
55

66
class ModuleType(str, Enum):
7-
assistant = "assistant"
8-
tool = "tool"
9-
retrieval = "retrieval"
10-
inference = "inference"
7+
ASSISTANT = "assistant"
8+
TOOL = "tool"
9+
RETRIEVAL = "retrieval"
10+
INFERENCE = "inference"
1111

1212

1313

taskingai/client/models/entity/assistant/assistant.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919

2020

2121
class AssistantToolType(str, Enum):
22-
action = "action"
23-
function = "function"
22+
ACTION = "action"
23+
FUNCTION = "function"
2424

2525

2626
class AssistantRetrievalType(str, Enum):
27-
collection = "collection"
27+
COLLECTION = "collection"
2828

2929

3030
class AssistantRetrieval(TaskingaiBaseModel):

taskingai/client/models/entity/assistant/message.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313

1414
class MessageRole(str, Enum):
15-
user = "user"
16-
assistant = "assistant"
15+
USER = "user"
16+
ASSISTANT = "assistant"
1717

1818

1919
class MessageContent(TaskingaiBaseModel):

taskingai/client/models/entity/inference/chat_completion.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222

2323

2424
class ChatCompletionRole(str, Enum):
25-
system = "system"
26-
assistant = "assistant"
27-
user = "user"
28-
function = "function"
25+
SYSTEM = "system"
26+
ASSISTANT = "assistant"
27+
USER = "user"
28+
FUNCTION = "function"
2929

3030

3131
class ChatCompletionFunctionCall(TaskingaiBaseModel):
@@ -45,30 +45,30 @@ class ChatCompletionMessage(TaskingaiBaseModel, metaclass=ABCMeta):
4545

4646

4747
class ChatCompletionSystemMessage(ChatCompletionMessage):
48-
role: ChatCompletionRole = Field(Literal[ChatCompletionRole.system])
48+
role: ChatCompletionRole = Field(Literal[ChatCompletionRole.SYSTEM])
4949

5050

5151
class ChatCompletionUserMessage(ChatCompletionMessage):
52-
role: ChatCompletionRole = Field(Literal[ChatCompletionRole.user])
52+
role: ChatCompletionRole = Field(Literal[ChatCompletionRole.USER])
5353

5454

5555
class ChatCompletionAssistantMessage(ChatCompletionMessage):
56-
role: ChatCompletionRole = Field(Literal[ChatCompletionRole.assistant])
56+
role: ChatCompletionRole = Field(Literal[ChatCompletionRole.ASSISTANT])
5757
function_calls: Optional[List[ChatCompletionFunctionCall]]
5858

5959

6060
class ChatCompletionFunctionMessage(ChatCompletionMessage):
61-
role: ChatCompletionRole = Field(Literal[ChatCompletionRole.function])
61+
role: ChatCompletionRole = Field(Literal[ChatCompletionRole.FUNCTION])
6262
id: str
6363

6464

6565
class ChatCompletionFinishReason(str, Enum):
66-
stop = "stop"
67-
length = "length"
68-
function_calls = "function_calls"
69-
recitation = "recitation"
70-
error = "error"
71-
unknown = "unknown"
66+
STOP = "stop"
67+
LENGTH = "length"
68+
FUNCTION_CALLS = "function_calls"
69+
RECITATION = "recitation"
70+
ERROR = "error"
71+
UNKNOWN = "unknown"
7272

7373

7474
class ChatCompletion(TaskingaiBaseModel):

0 commit comments

Comments
 (0)