Skip to content

Commit 8e0b7e6

Browse files
authored
Merge pull request Azure#92 from Azure/alemor-sdk-update
Updated OpenAI SDK version to 1.16.2
2 parents 5dcd5dd + 83b1c85 commit 8e0b7e6

9 files changed

Lines changed: 70 additions & 35 deletions

File tree

gen-ai/Assistants/api-in-a-box/failed_banks/assistant-failed_banks.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
"api_deployment_name = os.getenv(\"OPENAI_GPT_DEPLOYMENT\")\n",
101101
"email_URI = os.getenv(\"EMAIL_URI\")\n",
102102
"\n",
103-
"should_cleanup: bool = False"
103+
"should_cleanup: bool = True"
104104
]
105105
},
106106
{
@@ -131,8 +131,8 @@
131131
"\n",
132132
"from openai import AzureOpenAI\n",
133133
"from openai.types import FileObject\n",
134-
"from openai.types.beta.threads.message_content_image_file import MessageContentImageFile\n",
135-
"from openai.types.beta.threads.message_content_text import MessageContentText\n",
134+
"from openai.types.beta.threads.text_content_block import TextContentBlock\n",
135+
"from openai.types.beta.threads.image_file_content_block import ImageFileContentBlock\n",
136136
"from openai.types.beta.threads.messages import MessageFile\n",
137137
"from PIL import Image"
138138
]
@@ -250,15 +250,15 @@
250250
" for message in message_list:\n",
251251
" for item in message.content:\n",
252252
" # Determine the content type\n",
253-
" if isinstance(item, MessageContentText):\n",
253+
" if isinstance(item, TextContentBlock):\n",
254254
" print(f\"{message.role}:\\n{item.text.value}\\n\")\n",
255255
" file_annotations = item.text.annotations\n",
256256
" if file_annotations:\n",
257257
" for annotation in file_annotations:\n",
258258
" file_id = annotation.file_path.file_id\n",
259259
" content = read_assistant_file(file_id)\n",
260260
" print(f\"Annotation Content:\\n{str(content)}\\n\")\n",
261-
" elif isinstance(item, MessageContentImageFile):\n",
261+
" elif isinstance(item, ImageFileContentBlock):\n",
262262
" # Retrieve image from file id \n",
263263
" data_in_bytes = read_assistant_file(item.image_file.file_id)\n",
264264
" # Convert bytes to image\n",
@@ -403,7 +403,7 @@
403403
"name": "python",
404404
"nbconvert_exporter": "python",
405405
"pygments_lexer": "ipython3",
406-
"version": "3.10.12"
406+
"version": "3.11.8"
407407
}
408408
},
409409
"nbformat": 4,

gen-ai/Assistants/api-in-a-box/math_tutor/assistant-math_tutor.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
"api_version = os.getenv(\"OPENAI_VERSION\")\n",
101101
"api_deployment_name = os.getenv(\"OPENAI_GPT_DEPLOYMENT\")\n",
102102
"\n",
103-
"should_cleanup: bool = False"
103+
"should_cleanup: bool = True"
104104
]
105105
},
106106
{
@@ -129,8 +129,8 @@
129129
"from typing import Iterable\n",
130130
"\n",
131131
"from openai import AzureOpenAI\n",
132-
"from openai.types.beta.threads.message_content_image_file import MessageContentImageFile\n",
133-
"from openai.types.beta.threads.message_content_text import MessageContentText\n",
132+
"from openai.types.beta.threads.text_content_block import TextContentBlock\n",
133+
"from openai.types.beta.threads.image_file_content_block import ImageFileContentBlock\n",
134134
"from openai.types.beta.threads.messages import MessageFile\n",
135135
"from PIL import Image"
136136
]
@@ -207,15 +207,15 @@
207207
" for message in message_list:\n",
208208
" for item in message.content:\n",
209209
" # Determine the content type\n",
210-
" if isinstance(item, MessageContentText):\n",
210+
" if isinstance(item, TextContentBlock):\n",
211211
" print(f\"{message.role}:\\n{item.text.value}\\n\")\n",
212212
" file_annotations = item.text.annotations\n",
213213
" if file_annotations:\n",
214214
" for annotation in file_annotations:\n",
215215
" file_id = annotation.file_path.file_id\n",
216216
" content = read_assistant_file(file_id)\n",
217217
" print(f\"Annotation Content:\\n{str(content)}\\n\")\n",
218-
" elif isinstance(item, MessageContentImageFile):\n",
218+
" elif isinstance(item, ImageFileContentBlock):\n",
219219
" # Retrieve image from file id \n",
220220
" data_in_bytes = read_assistant_file(item.image_file.file_id)\n",
221221
" # Convert bytes to image\n",
@@ -359,7 +359,7 @@
359359
"name": "python",
360360
"nbconvert_exporter": "python",
361361
"pygments_lexer": "ipython3",
362-
"version": "3.10.12"
362+
"version": "3.11.8"
363363
}
364364
},
365365
"nbformat": 4,

gen-ai/Assistants/api-in-a-box/personal_finance/assistant-personal_finance.ipynb

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,39 @@
136136
"from openai.types import FileObject\n",
137137
"from openai.types.beta import Thread\n",
138138
"from openai.types.beta.threads import Run\n",
139-
"from openai.types.beta.threads.message_content_image_file import MessageContentImageFile\n",
140-
"from openai.types.beta.threads.message_content_text import MessageContentText\n",
139+
"from openai.types.beta.threads.text_content_block import TextContentBlock\n",
140+
"from openai.types.beta.threads.image_file_content_block import ImageFileContentBlock\n",
141141
"from openai.types.beta.threads.messages import MessageFile\n",
142142
"from PIL import Image"
143143
]
144144
},
145+
{
146+
"cell_type": "markdown",
147+
"metadata": {},
148+
"source": [
149+
"### Parameters"
150+
]
151+
},
152+
{
153+
"cell_type": "code",
154+
"execution_count": null,
155+
"metadata": {},
156+
"outputs": [],
157+
"source": [
158+
"import os\n",
159+
"\n",
160+
"from dotenv import load_dotenv\n",
161+
"\n",
162+
"load_dotenv(\"../.env\") # make sure to have the .env file in the root directory of the project\n",
163+
"\n",
164+
"api_endpoint = os.getenv(\"OPENAI_URI\")\n",
165+
"api_key = os.getenv(\"OPENAI_KEY\")\n",
166+
"api_version = os.getenv(\"OPENAI_VERSION\")\n",
167+
"api_deployment_name = os.getenv(\"OPENAI_GPT_DEPLOYMENT\")\n",
168+
"\n",
169+
"should_cleanup: bool = False"
170+
]
171+
},
145172
{
146173
"cell_type": "markdown",
147174
"metadata": {},
@@ -376,15 +403,15 @@
376403
" for message in message_list:\n",
377404
" for item in message.content:\n",
378405
" # Determine the content type\n",
379-
" if isinstance(item, MessageContentText):\n",
406+
" if isinstance(item, TextContentBlock):\n",
380407
" print(f\"{message.role}:\\n{item.text.value}\\n\")\n",
381408
" file_annotations = item.text.annotations\n",
382409
" if file_annotations:\n",
383410
" for annotation in file_annotations:\n",
384411
" file_id = annotation.file_path.file_id\n",
385412
" content = read_assistant_file(file_id)\n",
386413
" print(f\"Annotation Content:\\n{str(content)}\\n\")\n",
387-
" elif isinstance(item, MessageContentImageFile):\n",
414+
" elif isinstance(item, ImageFileContentBlock):\n",
388415
" # Retrieve image from file id \n",
389416
" data_in_bytes = read_assistant_file(item.image_file.file_id)\n",
390417
" # Convert bytes to image\n",
@@ -539,7 +566,7 @@
539566
"name": "python",
540567
"nbconvert_exporter": "python",
541568
"pygments_lexer": "ipython3",
542-
"version": "3.10.12"
569+
"version": "3.11.8"
543570
}
544571
},
545572
"nbformat": 4,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
openai==1.10.0
1+
openai==1.16.2
22
python-dotenv
33
yfinance
44
pillow
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# do not save the shelve files
2+
assistant_db.*
3+
threads_db.*

gen-ai/Assistants/api-in-a-box/sales_assistant/assistant_sales.ipynb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
"api_deployment_name = os.getenv(\"OPENAI_GPT_DEPLOYMENT\")\n",
105105
"email_URI = os.getenv(\"EMAIL_URI\")\n",
106106
"\n",
107-
"should_cleanup: bool = False"
107+
"should_cleanup: bool = True"
108108
]
109109
},
110110
{
@@ -141,8 +141,8 @@
141141
"from openai.types import FileObject\n",
142142
"from openai.types.beta import Thread\n",
143143
"from openai.types.beta.threads import Run\n",
144-
"from openai.types.beta.threads.message_content_image_file import MessageContentImageFile\n",
145-
"from openai.types.beta.threads.message_content_text import MessageContentText\n",
144+
"from openai.types.beta.threads.text_content_block import TextContentBlock\n",
145+
"from openai.types.beta.threads.image_file_content_block import ImageFileContentBlock\n",
146146
"from openai.types.beta.threads.messages import MessageFile\n",
147147
"from PIL import Image\n",
148148
"\n",
@@ -357,7 +357,7 @@
357357
" for message in message_list:\n",
358358
" for item in message.content:\n",
359359
" # Determine the content type\n",
360-
" if isinstance(item, MessageContentText):\n",
360+
" if isinstance(item, TextContentBlock):\n",
361361
" if message.role == \"user\":\n",
362362
" print(f\"user: {name}:\\n{item.text.value}\\n\")\n",
363363
" else:\n",
@@ -368,7 +368,7 @@
368368
" file_id = annotation.file_path.file_id\n",
369369
" content = read_assistant_file(file_id)\n",
370370
" print(f\"Annotation Content:\\n{str(content)}\\n\")\n",
371-
" elif isinstance(item, MessageContentImageFile):\n",
371+
" elif isinstance(item, ImageFileContentBlock):\n",
372372
" # Retrieve image from file id \n",
373373
" data_in_bytes = read_assistant_file(item.image_file.file_id)\n",
374374
" # Convert bytes to image\n",
@@ -481,6 +481,11 @@
481481
"process_prompt(\"John\", \"user_123\", \"What is the most sold product?\")"
482482
]
483483
},
484+
{
485+
"cell_type": "markdown",
486+
"metadata": {},
487+
"source": []
488+
},
484489
{
485490
"cell_type": "code",
486491
"execution_count": null,
@@ -534,7 +539,7 @@
534539
"name": "python",
535540
"nbconvert_exporter": "python",
536541
"pygments_lexer": "ipython3",
537-
"version": "3.10.12"
542+
"version": "3.11.8"
538543
}
539544
},
540545
"nbformat": 4,

gen-ai/Assistants/api-in-a-box/sales_copilot/AssistantAgent.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
from AgentSettings import AgentSettings
1010

11-
from openai.types.beta.threads.message_content_image_file import MessageContentImageFile
12-
from openai.types.beta.threads.message_content_text import MessageContentText
11+
from openai.types.beta.threads.text_content_block import TextContentBlock
12+
from openai.types.beta.threads.image_file_content_block import ImageFileContentBlock
1313
from openai.types.beta.threads.messages import MessageFile
1414
from openai.types import FileObject
1515
from PIL import Image
@@ -157,7 +157,7 @@ def print_messages(self, name: str, messages: Iterable[MessageFile]) -> None:
157157
for message in message_list:
158158
for item in message.content:
159159
# Determine the content type
160-
if isinstance(item, MessageContentText):
160+
if isinstance(item, TextContentBlock):
161161
if message.role == "user":
162162
print(f"user: {name}:\n{item.text.value}\n")
163163
else:
@@ -168,7 +168,7 @@ def print_messages(self, name: str, messages: Iterable[MessageFile]) -> None:
168168
file_id = annotation.file_path.file_id
169169
content = self.read_assistant_file(file_id)
170170
print(f"Annotation Content:\n{str(content)}\n")
171-
elif isinstance(item, MessageContentImageFile):
171+
elif isinstance(item, ImageFileContentBlock):
172172
# Retrieve image from file id
173173
data_in_bytes = self.read_assistant_file(
174174
item.image_file.file_id)

gen-ai/Assistants/api-in-a-box/sales_copilot/two_agent_copilot_proxy.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@
217217
"name": "python",
218218
"nbconvert_exporter": "python",
219219
"pygments_lexer": "ipython3",
220-
"version": "3.10.12"
220+
"version": "3.11.8"
221221
}
222222
},
223223
"nbformat": 4,

gen-ai/Assistants/api-in-a-box/wind_farm/assistant-wind_farm.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
"api_deployment_name = os.getenv(\"OPENAI_GPT_DEPLOYMENT\")\n",
102102
"email_URI = os.getenv(\"EMAIL_URI\")\n",
103103
"\n",
104-
"should_cleanup: bool = False"
104+
"should_cleanup: bool = True"
105105
]
106106
},
107107
{
@@ -132,8 +132,8 @@
132132
"\n",
133133
"from openai import AzureOpenAI\n",
134134
"from openai.types import FileObject\n",
135-
"from openai.types.beta.threads.message_content_image_file import MessageContentImageFile\n",
136-
"from openai.types.beta.threads.message_content_text import MessageContentText\n",
135+
"from openai.types.beta.threads.text_content_block import TextContentBlock\n",
136+
"from openai.types.beta.threads.image_file_content_block import ImageFileContentBlock\n",
137137
"from openai.types.beta.threads.messages import MessageFile\n",
138138
"from PIL import Image"
139139
]
@@ -266,15 +266,15 @@
266266
" for message in message_list:\n",
267267
" for item in message.content:\n",
268268
" # Determine the content type\n",
269-
" if isinstance(item, MessageContentText):\n",
269+
" if isinstance(item, TextContentBlock):\n",
270270
" print(f\"{message.role}:\\n{item.text.value}\\n\")\n",
271271
" file_annotations = item.text.annotations\n",
272272
" if file_annotations:\n",
273273
" for annotation in file_annotations:\n",
274274
" file_id = annotation.file_path.file_id\n",
275275
" content = read_assistant_file(file_id)\n",
276276
" print(f\"Annotation Content:\\n{str(content)}\\n\")\n",
277-
" elif isinstance(item, MessageContentImageFile):\n",
277+
" elif isinstance(item, ImageFileContentBlock):\n",
278278
" # Retrieve image from file id \n",
279279
" data_in_bytes = read_assistant_file(item.image_file.file_id)\n",
280280
" # Convert bytes to image\n",
@@ -426,7 +426,7 @@
426426
"name": "python",
427427
"nbconvert_exporter": "python",
428428
"pygments_lexer": "ipython3",
429-
"version": "3.10.12"
429+
"version": "3.11.8"
430430
}
431431
},
432432
"nbformat": 4,

0 commit comments

Comments
 (0)