Skip to content

Commit 4bd0233

Browse files
committed
update content consistency
1 parent 646f5a5 commit 4bd0233

13 files changed

Lines changed: 385 additions & 167 deletions

File tree

gen-ai/Assistants/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Check out the provided samples to get started with integrating the Assistants AP
3535
| [Financial Assistant](./api-in-a-box/personal_finance/assistant-personal_finance.ipynb) | Function Calling with Yfinance to get latest stock prices. Summarization of user provided article. Extract country info from article, extract country, capital and other aspects, and call an API to get more information about each country. |
3636
| [Failed Banks](./api-in-a-box/failed_banks/assistant-failed_banks.ipynb) | Failed Banks is an Assistant designed to analyze and extract data concerning failed banks. It can provide insights into questions like identifying failed banks within specific states during a given time frame and generate charts illustrating bank failures across the US. |
3737
| [Wind Farm](./api-in-a-box/wind_farm/assistant-wind_farm.ipynb) | Utilizing Assistant tools such as the Code Interpreter and Function calling, this bot is capable of retrieving a CSV file that illustrates turbine wind speed, voltage, and the last maintenance date. It assists you in reviewing the file contents and aids in determining whether a specific turbine is in need of maintenance. |
38+
| [Sales Assistant](./api-in-a-box/sales_assistant/assistant_sales.ipynb) | Showcases how you can create an Assistant adept at managing various tasks, such as handling relational data across different files and supporting multiple users simultaneously within the same Assistant across distinct threads. |
3839
| [Assistants Bot-in-a-Box](./bot-in-a-box/) | The Assistants API Bot in-a-box automates virtual assistant deployment on Azure, facilitating seamless communication between users and assistants across various messaging channels. It streamlines message processing and response delivery through Azure Bot Services and the Assistants API. |
3940

4041
## Prerequisites

gen-ai/Assistants/api-in-a-box/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,10 @@ while True:
144144
| Topic | Description |
145145
|----------------------|--------------------------------------------------|
146146
| [Math Tutor](math_tutor/assistant-math_tutor.ipynb) | Showcases the foundational concepts of Assistants such as Threads, Messages, Runs, Tools, and lifecycle management. |
147-
| [Failed Banks](failed_banks/assistant-failed_banks.ipynb) | Failed Banks is an Assistant designed to analyze and extract data concerning failed banks. It can provide insights into questions like identifying failed banks within specific states during a given time frame and generate charts illustrating bank failures across the US. |
148-
| [Wind Farm](wind_farm/assistant-wind_farm.ipynb) | Utilizing Assistant tools such as the Code Interpreter and Function calling, this bot is capable of retrieving a CSV file that illustrates turbine wind speed, voltage, and the last maintenance date. It assists you in reviewing the file contents and aids in determining whether a specific turbine is in need of maintenance. |
149147
| [Financial Assistant](personal_finance/assistant-personal_finance.ipynb) | Function Calling with Yfinance to get latest stock prices. Summarization of user provided article. Extract country info from article, extract country, capital and other aspects, and call an API to get more information about each country. |
148+
| [Failed Banks](failed_banks/assistant-failed_banks.ipynb) | Using Assistant tools Code Interpreter and Function calling, this Assistant can get a CSV file, gather a list of failed banks by state, and generate a chart to visually represent the data. |
149+
| [Wind Farm](wind_farm/assistant-wind_farm.ipynb) | Utilizing Assistant tools such as the Code Interpreter and Function calling, this bot is capable of retrieving a CSV file that illustrates turbine wind speed, voltage, and the last maintenance date. It assists you in reviewing the file contents and aids in determining whether a specific turbine is in need of maintenance. |
150+
| [Sales Assistant](sales_assistant/assistant_sales.ipynb) | Showcases how you can create an Assistant adept at managing various tasks, such as handling relational data across different files and supporting multiple users simultaneously within the same Assistant across distinct threads. |
150151

151152
## Prerequisites
152153

gen-ai/Assistants/api-in-a-box/failed_banks/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Using Assistant tools Code Interpreter and Function calling, this bot can get a
1010
The objective of the provided notebook file is to create an Azure OpenAI Assistant named "Failed Banks Assistant" using the Azure OpenAI API. The assistant is designed to assist users in obtaining information about failed banks based on a provided CSV file. The assistant is equipped with the capability to process user messages, interact with the provided file, and respond with relevant information.
1111

1212
### Programming Languages
13-
- Python
13+
14+
- Python
1415

1516
### Estimated Runtime: 5 mins

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

Lines changed: 63 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"- A connection to the Azure OpenAI Service with a [Key and Endpoint](https://learn.microsoft.com/en-us/azure/ai-services/openai/chatgpt-quickstart)\n",
2525
"\n",
2626
"Reference:\n",
27-
"- Learn more about how to use Assistants with our [How-to guide on Assistants](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/assistant).\n",
27+
"- Learn more about how to use Assistants with our [How-to guide on Assistants](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/assistant)\n",
2828
"- [Assistants OpenAI Overview](https://platform.openai.com/docs/assistants/overview)"
2929
]
3030
},
@@ -43,23 +43,26 @@
4343
"source": [
4444
"## About this example\n",
4545
"\n",
46-
"This sample demonstrates the creation of an Azure OpenAI Assistant named \"Failed Banks Assistant\" through the Azure OpenAI API. The assistant is tailored to aid users in retrieving information about failed banks from a CSV file, the assistant efficiently processes user messages, interacts with the designated file, and promptly delivers pertinent information in response."
46+
"This sample demonstrates the creation of an Azure OpenAI Assistant named \"Failed Banks Assistant\" through the Azure OpenAI API. The assistant is tailored to aid users in retrieving information about failed banks from a CSV file, the assistant efficiently processes user messages, interacts with the designated file, and promptly delivers pertinent information in response.\n",
47+
"\n",
48+
"### Data\n",
49+
"This sample uses files from the folder [`data/`](./data/) in this repo. You can clone this repo or copy this folder to make sure you have access to these files when running the sample."
4750
]
4851
},
4952
{
5053
"cell_type": "markdown",
5154
"metadata": {},
5255
"source": [
53-
"### Data\n",
54-
"\n",
55-
"This sample uses files from the folder [`data/`](data/failed_banks.csv) in this repo. You can clone this repo or copy this folder to make sure you have access to these files when running the sample."
56+
"## Before you begin"
5657
]
5758
},
5859
{
5960
"cell_type": "markdown",
6061
"metadata": {},
6162
"source": [
62-
"### Load the required libraries"
63+
"### Installation\n",
64+
"\n",
65+
"Install the following packages required to execute this notebook."
6366
]
6467
},
6568
{
@@ -68,27 +71,15 @@
6871
"metadata": {},
6972
"outputs": [],
7073
"source": [
71-
"import io\n",
72-
"import os\n",
73-
"import time\n",
74-
"from datetime import datetime\n",
75-
"from pathlib import Path\n",
76-
"from typing import Iterable\n",
77-
"\n",
78-
"from dotenv import load_dotenv\n",
79-
"from openai import AzureOpenAI\n",
80-
"from openai.types import FileObject\n",
81-
"from openai.types.beta.threads.message_content_image_file import MessageContentImageFile\n",
82-
"from openai.types.beta.threads.message_content_text import MessageContentText\n",
83-
"from openai.types.beta.threads.messages import MessageFile\n",
84-
"from PIL import Image"
74+
"# Install the packages\n",
75+
"%pip install -r ../requirements.txt"
8576
]
8677
},
8778
{
8879
"cell_type": "markdown",
8980
"metadata": {},
9081
"source": [
91-
"### Load the environment variables"
82+
"### Parameters"
9283
]
9384
},
9485
{
@@ -97,19 +88,60 @@
9788
"metadata": {},
9889
"outputs": [],
9990
"source": [
100-
"load_dotenv(\"../.env\") #make sure to have the .env file in the root directory of the project\n",
91+
"import os\n",
92+
"\n",
93+
"from dotenv import load_dotenv\n",
94+
"\n",
95+
"load_dotenv(\"../.env\") # make sure to have the .env file in the root directory of the project\n",
96+
"\n",
10197
"api_endpoint = os.getenv(\"OPENAI_URI\")\n",
10298
"api_key = os.getenv(\"OPENAI_KEY\")\n",
10399
"api_version = os.getenv(\"OPENAI_VERSION\")\n",
104100
"api_deployment_name = os.getenv(\"OPENAI_GPT_DEPLOYMENT\")\n",
105-
"email_URI = os.getenv(\"EMAIL_URI\")"
101+
"email_URI = os.getenv(\"EMAIL_URI\")\n",
102+
"\n",
103+
"should_cleanup: bool = False"
104+
]
105+
},
106+
{
107+
"cell_type": "markdown",
108+
"metadata": {},
109+
"source": [
110+
"## Run this Example"
111+
]
112+
},
113+
{
114+
"cell_type": "markdown",
115+
"metadata": {},
116+
"source": [
117+
"### Load the required libraries"
118+
]
119+
},
120+
{
121+
"cell_type": "code",
122+
"execution_count": null,
123+
"metadata": {},
124+
"outputs": [],
125+
"source": [
126+
"import io\n",
127+
"import time\n",
128+
"from datetime import datetime\n",
129+
"from pathlib import Path\n",
130+
"from typing import Iterable\n",
131+
"\n",
132+
"from openai import AzureOpenAI\n",
133+
"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",
136+
"from openai.types.beta.threads.messages import MessageFile\n",
137+
"from PIL import Image"
106138
]
107139
},
108140
{
109141
"cell_type": "markdown",
110142
"metadata": {},
111143
"source": [
112-
"### Create an AzureOpenAI client"
144+
"### Create an Azure OpenAI client"
113145
]
114146
},
115147
{
@@ -200,7 +232,7 @@
200232
"source": [
201233
"def read_assistant_file(file_id:str):\n",
202234
" response_content = client.files.content(file_id)\n",
203-
" return response_content.read() \n",
235+
" return response_content.read()\n",
204236
"\n",
205237
"def print_messages(messages: Iterable[MessageFile]) -> None:\n",
206238
" message_list = []\n",
@@ -338,7 +370,7 @@
338370
"cell_type": "markdown",
339371
"metadata": {},
340372
"source": [
341-
"### Cleanup"
373+
"### Cleaning up"
342374
]
343375
},
344376
{
@@ -347,10 +379,11 @@
347379
"metadata": {},
348380
"outputs": [],
349381
"source": [
350-
"client.beta.assistants.delete(assistant.id)\n",
351-
"client.beta.threads.delete(thread.id)\n",
352-
"for file in assistant_files:\n",
353-
" client.files.delete(file.id)"
382+
"if should_cleanup:\n",
383+
" client.beta.assistants.delete(assistant.id)\n",
384+
" client.beta.threads.delete(thread.id)\n",
385+
" for file in assistant_files:\n",
386+
" client.files.delete(file.id)"
354387
]
355388
}
356389
],

gen-ai/Assistants/api-in-a-box/math_tutor/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ Showcases the foundational concepts of Assistants such as Threads, Messages, Run
77

88
### Objective
99

10-
The objective of the provided Python file is to create an Azure OpenAI Assistant named "Math Tutor" using the Azure OpenAI API. The assistant is designed to function as a personal math tutor, capable of answering math questions through code interpretation. The script initiates a conversation with the assistant, guiding it through various mathematical queries and scenarios to showcase its capabilities.
10+
The objective of the provided notebook file is to create an Azure OpenAI Assistant named "Math Tutor" using the Azure OpenAI API. The assistant is designed to function as a personal math tutor, capable of answering math questions through code interpretation. The script initiates a conversation with the assistant, guiding it through various mathematical queries and scenarios to showcase its capabilities.
1111

1212
### Programming Languages
13-
- Python
13+
14+
- Python
1415

1516
### Estimated Runtime: 5 mins

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

Lines changed: 63 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@
1818
"- Showcases the foundational concepts of Assistants such as Threads, Messages, Runs, Tools, and lifecycle management.\n",
1919
"\n",
2020
"This tutorial uses the following Azure AI services:\n",
21-
"\n",
2221
"- Access to Azure OpenAI Service - you can apply for access [here](https://aka.ms/oai/access)\n",
23-
"- Azure OpenAI service - you can create it from instructions [here](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/create-resource)\\n\",\n",
22+
"- Azure OpenAI service - you can create it from instructions [here](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/create-resource)\n",
2423
"- Azure OpenAI Studio - go to [https://oai.azure.com/](https://oai.azure.com/) to work with the Assistants API Playground\n",
2524
"- A connection to the Azure OpenAI Service with a [Key and Endpoint](https://learn.microsoft.com/en-us/azure/ai-services/openai/chatgpt-quickstart)\n",
2625
"\n",
2726
"Reference:\n",
28-
"\n",
29-
"- Learn more about how to use Assistants with our [How-to guide on Assistants](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/assistant).\n",
27+
"- Learn more about how to use Assistants with our [How-to guide on Assistants](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/assistant)\n",
3028
"- [Assistants OpenAI Overview](https://platform.openai.com/docs/assistants/overview)\n",
3129
"- [Github-OpenAI Python/examples/Assistant demo notebook](https://github.com/openai/openai-python/blob/main/examples/assistant.py)"
3230
]
@@ -37,7 +35,7 @@
3735
"source": [
3836
"## Time\n",
3937
"\n",
40-
"You should expect to spend 5-10 minutes running this sample. "
38+
"You should expect to spend 5-10 minutes running this sample."
4139
]
4240
},
4341
{
@@ -48,14 +46,24 @@
4846
"\n",
4947
"This sample shows users how to create an Azure OpenAI Assistant named \"Math Tutor\" using the Azure OpenAI API. The assistant is designed to function as a personal math tutor, capable of answering math questions through code interpretation. The script initiates a conversation with the assistant, guiding it through various mathematical queries and scenarios to showcase its capabilities.\n",
5048
"\n",
51-
"This sample provides developers with a clear demonstration of how to leverage the core concepts of the Assistants API into their projects, highlighting its simplicity and effectiveness in leveraging foundational concepts. "
49+
"This sample provides developers with a clear demonstration of how to leverage the core concepts of the Assistants API into their projects, highlighting its simplicity and effectiveness in leveraging foundational concepts."
5250
]
5351
},
5452
{
5553
"cell_type": "markdown",
5654
"metadata": {},
5755
"source": [
58-
"## Load the required libraries"
56+
"## Before you begin"
57+
]
58+
},
59+
{
60+
"cell_type": "markdown",
61+
"metadata": {},
62+
"source": [
63+
"### Installation\n",
64+
"\n",
65+
"Install the following packages required to execute this notebook. \n",
66+
"\n"
5967
]
6068
},
6169
{
@@ -64,25 +72,15 @@
6472
"metadata": {},
6573
"outputs": [],
6674
"source": [
67-
"import io\n",
68-
"import os\n",
69-
"import time\n",
70-
"from datetime import datetime\n",
71-
"from typing import Iterable\n",
72-
"\n",
73-
"from dotenv import load_dotenv\n",
74-
"from openai import AzureOpenAI\n",
75-
"from openai.types.beta.threads.message_content_image_file import MessageContentImageFile\n",
76-
"from openai.types.beta.threads.message_content_text import MessageContentText\n",
77-
"from openai.types.beta.threads.messages import MessageFile\n",
78-
"from PIL import Image"
75+
"# Install the packages\n",
76+
"%pip install -r ../requirements.txt"
7977
]
8078
},
8179
{
8280
"cell_type": "markdown",
8381
"metadata": {},
8482
"source": [
85-
"## Load the environment variables"
83+
"### Parameters"
8684
]
8785
},
8886
{
@@ -91,11 +89,50 @@
9189
"metadata": {},
9290
"outputs": [],
9391
"source": [
94-
"load_dotenv(\"../.env\") #make sure to have the .env file in the root directory of the project\n",
92+
"import os\n",
93+
"\n",
94+
"from dotenv import load_dotenv\n",
95+
"\n",
96+
"load_dotenv(\"../.env\") # make sure to have the .env file in the root directory of the project\n",
97+
"\n",
9598
"api_endpoint = os.getenv(\"OPENAI_URI\")\n",
9699
"api_key = os.getenv(\"OPENAI_KEY\")\n",
97100
"api_version = os.getenv(\"OPENAI_VERSION\")\n",
98-
"api_deployment_name = os.getenv(\"OPENAI_GPT_DEPLOYMENT\")"
101+
"api_deployment_name = os.getenv(\"OPENAI_GPT_DEPLOYMENT\")\n",
102+
"\n",
103+
"should_cleanup: bool = False"
104+
]
105+
},
106+
{
107+
"cell_type": "markdown",
108+
"metadata": {},
109+
"source": [
110+
"## Run this Example"
111+
]
112+
},
113+
{
114+
"cell_type": "markdown",
115+
"metadata": {},
116+
"source": [
117+
"### Load the required libraries"
118+
]
119+
},
120+
{
121+
"cell_type": "code",
122+
"execution_count": null,
123+
"metadata": {},
124+
"outputs": [],
125+
"source": [
126+
"import io\n",
127+
"import time\n",
128+
"from datetime import datetime\n",
129+
"from typing import Iterable\n",
130+
"\n",
131+
"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",
134+
"from openai.types.beta.threads.messages import MessageFile\n",
135+
"from PIL import Image"
99136
]
100137
},
101138
{
@@ -291,7 +328,7 @@
291328
"cell_type": "markdown",
292329
"metadata": {},
293330
"source": [
294-
"### Cleanup"
331+
"### Cleaning up"
295332
]
296333
},
297334
{
@@ -300,8 +337,9 @@
300337
"metadata": {},
301338
"outputs": [],
302339
"source": [
303-
"client.beta.assistants.delete(assistant.id)\n",
304-
"client.beta.threads.delete(thread.id)"
340+
"if should_cleanup:\n",
341+
" client.beta.assistants.delete(assistant.id)\n",
342+
" client.beta.threads.delete(thread.id)"
305343
]
306344
}
307345
],

gen-ai/Assistants/api-in-a-box/personal_finance/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ Function Calling with Yfinance to get latest stock prices. Summarization of user
77

88
### Objective
99

10-
The objective of the provided Python file is to create an Azure OpenAI Assistant named "Portfolio Management Assistant" using the Azure OpenAI API. The assistant is designed to act as a personal financial assistant, providing information and insights related to a user's investment portfolio. The script initiates a conversation with the assistant, guiding it through various financial queries and scenarios to showcase its capabilities.
10+
The objective of the provided notebook file is to create an Azure OpenAI Assistant named "Portfolio Management Assistant" using the Azure OpenAI API. The assistant is designed to act as a personal financial assistant, providing information and insights related to a user's investment portfolio. The script initiates a conversation with the assistant, guiding it through various financial queries and scenarios to showcase its capabilities.
1111

1212
### Programming Languages
13-
- Python
13+
14+
- Python
1415

1516
### Estimated Runtime: 10 mins

0 commit comments

Comments
 (0)