Skip to content

Commit e267921

Browse files
committed
fix: correct the bug in example code
1 parent 54a7435 commit e267921

File tree

12 files changed

+211
-1183
lines changed

12 files changed

+211
-1183
lines changed

examples/assistant/chat_with_assistant.ipynb

Lines changed: 25 additions & 142 deletions
Large diffs are not rendered by default.

examples/crud/assistant_crud.ipynb

Lines changed: 35 additions & 204 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
6-
"metadata": {
7-
"ExecuteTime": {
8-
"end_time": "2023-11-28T03:28:19.450970Z",
9-
"start_time": "2023-11-28T03:28:19.387649Z"
10-
}
11-
},
5+
"execution_count": null,
6+
"metadata": {},
127
"outputs": [],
138
"source": [
149
"import taskingai\n",
@@ -26,19 +21,14 @@
2621
},
2722
{
2823
"cell_type": "code",
29-
"execution_count": 2,
30-
"metadata": {
31-
"ExecuteTime": {
32-
"end_time": "2023-11-28T03:28:19.451171Z",
33-
"start_time": "2023-11-28T03:28:19.436554Z"
34-
}
35-
},
24+
"execution_count": null,
25+
"metadata": {},
3626
"outputs": [],
3727
"source": [
3828
"from taskingai.assistant import Assistant, Chat\n",
3929
"\n",
4030
"# choose an available chat_completion model from your project\n",
41-
"model_id = \"Gk1145Bl\""
31+
"model_id = \"YOUR_MODEL_ID\""
4232
]
4333
},
4434
{
@@ -52,32 +42,9 @@
5242
},
5343
{
5444
"cell_type": "code",
55-
"execution_count": 3,
56-
"metadata": {
57-
"ExecuteTime": {
58-
"end_time": "2023-11-28T03:28:20.580538Z",
59-
"start_time": "2023-11-28T03:28:19.438571Z"
60-
}
61-
},
62-
"outputs": [
63-
{
64-
"name": "stdout",
65-
"output_type": "stream",
66-
"text": [
67-
"created assistant: {'assistant_id': 'X5lMbErLu8l4PmoA3aZQt7FX',\n",
68-
" 'created_timestamp': 1701142100480,\n",
69-
" 'description': 'This is my assistant',\n",
70-
" 'metadata': {'foo': 'bar'},\n",
71-
" 'model_id': 'Gk1145Bl',\n",
72-
" 'name': 'My Assistant',\n",
73-
" 'object': 'Assistant',\n",
74-
" 'retrievals': [],\n",
75-
" 'system_prompt_template': ['You are a professional assistant speaking '\n",
76-
" '{{language}}.'],\n",
77-
" 'tools': []}\n"
78-
]
79-
}
80-
],
45+
"execution_count": null,
46+
"metadata": {},
47+
"outputs": [],
8148
"source": [
8249
"# create an assistant\n",
8350
"def create_assistant() -> Assistant:\n",
@@ -98,26 +65,8 @@
9865
},
9966
{
10067
"cell_type": "code",
101-
"execution_count": 4,
102-
"outputs": [
103-
{
104-
"name": "stdout",
105-
"output_type": "stream",
106-
"text": [
107-
"got assistant: {'assistant_id': 'X5lMbErLu8l4PmoA3aZQt7FX',\n",
108-
" 'created_timestamp': 1701142100480,\n",
109-
" 'description': 'This is my assistant',\n",
110-
" 'metadata': {'foo': 'bar'},\n",
111-
" 'model_id': 'Gk1145Bl',\n",
112-
" 'name': 'My Assistant',\n",
113-
" 'object': 'Assistant',\n",
114-
" 'retrievals': [],\n",
115-
" 'system_prompt_template': ['You are a professional assistant speaking '\n",
116-
" '{{language}}.'],\n",
117-
" 'tools': []}\n"
118-
]
119-
}
120-
],
68+
"execution_count": null,
69+
"outputs": [],
12170
"source": [
12271
"# get assistant\n",
12372
"assistant_id: str = assistant.assistant_id\n",
@@ -128,35 +77,13 @@
12877
"print(f\"got assistant: {assistant}\\n\")"
12978
],
13079
"metadata": {
131-
"collapsed": false,
132-
"ExecuteTime": {
133-
"end_time": "2023-11-28T03:28:21.684926Z",
134-
"start_time": "2023-11-28T03:28:20.563489Z"
135-
}
80+
"collapsed": false
13681
}
13782
},
13883
{
13984
"cell_type": "code",
140-
"execution_count": 5,
141-
"outputs": [
142-
{
143-
"name": "stdout",
144-
"output_type": "stream",
145-
"text": [
146-
"updated assistant: {'assistant_id': 'X5lMbErLu8l4PmoA3aZQt7FX',\n",
147-
" 'created_timestamp': 1701142100480,\n",
148-
" 'description': 'This is my new assistant',\n",
149-
" 'metadata': {'foo': 'bar'},\n",
150-
" 'model_id': 'Gk1145Bl',\n",
151-
" 'name': 'My New Assistant',\n",
152-
" 'object': 'Assistant',\n",
153-
" 'retrievals': [],\n",
154-
" 'system_prompt_template': ['You are a professional assistant speaking '\n",
155-
" '{{language}}.'],\n",
156-
" 'tools': []}\n"
157-
]
158-
}
159-
],
85+
"execution_count": null,
86+
"outputs": [],
16087
"source": [
16188
"# update assistant\n",
16289
"assistant: Assistant = taskingai.assistant.update_assistant(\n",
@@ -168,50 +95,26 @@
16895
"print(f\"updated assistant: {assistant}\\n\")\n"
16996
],
17097
"metadata": {
171-
"collapsed": false,
172-
"ExecuteTime": {
173-
"end_time": "2023-11-28T03:28:22.752013Z",
174-
"start_time": "2023-11-28T03:28:21.681597Z"
175-
}
98+
"collapsed": false
17699
}
177100
},
178101
{
179102
"cell_type": "code",
180-
"execution_count": 6,
181-
"outputs": [
182-
{
183-
"name": "stdout",
184-
"output_type": "stream",
185-
"text": [
186-
"deleted assistant: X5lMbErLu8l4PmoA3aZQt7FX\n"
187-
]
188-
}
189-
],
103+
"execution_count": null,
104+
"outputs": [],
190105
"source": [
191106
"# delete assistant\n",
192107
"taskingai.assistant.delete_assistant(assistant_id=assistant_id)\n",
193108
"print(f\"deleted assistant: {assistant_id}\\n\")"
194109
],
195110
"metadata": {
196-
"collapsed": false,
197-
"ExecuteTime": {
198-
"end_time": "2023-11-28T03:28:23.820561Z",
199-
"start_time": "2023-11-28T03:28:22.744793Z"
200-
}
111+
"collapsed": false
201112
}
202113
},
203114
{
204115
"cell_type": "code",
205-
"execution_count": 7,
206-
"outputs": [
207-
{
208-
"name": "stdout",
209-
"output_type": "stream",
210-
"text": [
211-
"fX5lMbErLu8l4PmoA3aZQt7FX in assistant_ids: False\n"
212-
]
213-
}
214-
],
116+
"execution_count": null,
117+
"outputs": [],
215118
"source": [
216119
"# list assistants\n",
217120
"assistants = taskingai.assistant.list_assistants()\n",
@@ -220,11 +123,7 @@
220123
"print(f\"f{assistant_id} in assistant_ids: {assistant_id in assistant_ids}\\n\")"
221124
],
222125
"metadata": {
223-
"collapsed": false,
224-
"ExecuteTime": {
225-
"end_time": "2023-11-28T03:28:24.721147Z",
226-
"start_time": "2023-11-28T03:28:23.813239Z"
227-
}
126+
"collapsed": false
228127
}
229128
},
230129
{
@@ -238,16 +137,8 @@
238137
},
239138
{
240139
"cell_type": "code",
241-
"execution_count": 8,
242-
"outputs": [
243-
{
244-
"name": "stdout",
245-
"output_type": "stream",
246-
"text": [
247-
"created chat: SdEL6St9BpnDhvqKYvEBNX34 for assistant: X5lMBhmZXSyO5dyLOWxFTeVt\n"
248-
]
249-
}
250-
],
140+
"execution_count": null,
141+
"outputs": [],
251142
"source": [
252143
"# create a new assistant\n",
253144
"assistant: Assistant = create_assistant()\n",
@@ -259,29 +150,13 @@
259150
"print(f\"created chat: {chat.chat_id} for assistant: {assistant.assistant_id}\\n\")"
260151
],
261152
"metadata": {
262-
"collapsed": false,
263-
"ExecuteTime": {
264-
"end_time": "2023-11-28T03:28:26.787643Z",
265-
"start_time": "2023-11-28T03:28:24.715127Z"
266-
}
153+
"collapsed": false
267154
}
268155
},
269156
{
270157
"cell_type": "code",
271-
"execution_count": 9,
272-
"outputs": [
273-
{
274-
"name": "stdout",
275-
"output_type": "stream",
276-
"text": [
277-
"got chat: {'assistant_id': 'X5lMBhmZXSyO5dyLOWxFTeVt',\n",
278-
" 'chat_id': 'SdEL6St9BpnDhvqKYvEBNX34',\n",
279-
" 'created_timestamp': 1701142106714,\n",
280-
" 'metadata': {},\n",
281-
" 'object': 'Chat'}\n"
282-
]
283-
}
284-
],
158+
"execution_count": null,
159+
"outputs": [],
285160
"source": [
286161
"# get chat\n",
287162
"chat_id: str = chat.chat_id\n",
@@ -292,29 +167,13 @@
292167
"print(f\"got chat: {chat}\\n\")"
293168
],
294169
"metadata": {
295-
"collapsed": false,
296-
"ExecuteTime": {
297-
"end_time": "2023-11-28T03:28:27.741867Z",
298-
"start_time": "2023-11-28T03:28:26.778315Z"
299-
}
170+
"collapsed": false
300171
}
301172
},
302173
{
303174
"cell_type": "code",
304-
"execution_count": 10,
305-
"outputs": [
306-
{
307-
"name": "stdout",
308-
"output_type": "stream",
309-
"text": [
310-
"updated chat: {'assistant_id': 'X5lMBhmZXSyO5dyLOWxFTeVt',\n",
311-
" 'chat_id': 'SdEL6St9BpnDhvqKYvEBNX34',\n",
312-
" 'created_timestamp': 1701142106714,\n",
313-
" 'metadata': {'foo': 'bar'},\n",
314-
" 'object': 'Chat'}\n"
315-
]
316-
}
317-
],
175+
"execution_count": null,
176+
"outputs": [],
318177
"source": [
319178
"# update chat\n",
320179
"chat: Chat = taskingai.assistant.update_chat(\n",
@@ -325,25 +184,13 @@
325184
"print(f\"updated chat: {chat}\\n\")"
326185
],
327186
"metadata": {
328-
"collapsed": false,
329-
"ExecuteTime": {
330-
"end_time": "2023-11-28T03:28:28.826640Z",
331-
"start_time": "2023-11-28T03:28:27.732438Z"
332-
}
187+
"collapsed": false
333188
}
334189
},
335190
{
336191
"cell_type": "code",
337-
"execution_count": 11,
338-
"outputs": [
339-
{
340-
"name": "stdout",
341-
"output_type": "stream",
342-
"text": [
343-
"deleted chat: SdEL6St9BpnDhvqKYvEBNX34\n"
344-
]
345-
}
346-
],
192+
"execution_count": null,
193+
"outputs": [],
347194
"source": [
348195
"# delete chat\n",
349196
"taskingai.assistant.delete_chat(\n",
@@ -353,25 +200,13 @@
353200
"print(f\"deleted chat: {chat_id}\\n\")"
354201
],
355202
"metadata": {
356-
"collapsed": false,
357-
"ExecuteTime": {
358-
"end_time": "2023-11-28T03:28:29.772361Z",
359-
"start_time": "2023-11-28T03:28:28.821362Z"
360-
}
203+
"collapsed": false
361204
}
362205
},
363206
{
364207
"cell_type": "code",
365-
"execution_count": 12,
366-
"outputs": [
367-
{
368-
"name": "stdout",
369-
"output_type": "stream",
370-
"text": [
371-
"num chats = 3\n"
372-
]
373-
}
374-
],
208+
"execution_count": null,
209+
"outputs": [],
375210
"source": [
376211
"# list chats \n",
377212
"for _ in range(3):\n",
@@ -385,11 +220,7 @@
385220
"print(f\"num chats = {len(chats)}\\n\")"
386221
],
387222
"metadata": {
388-
"collapsed": false,
389-
"ExecuteTime": {
390-
"end_time": "2023-11-28T03:28:33.720987Z",
391-
"start_time": "2023-11-28T03:28:29.769577Z"
392-
}
223+
"collapsed": false
393224
}
394225
}
395226
],

0 commit comments

Comments
 (0)