Skip to content

Commit 9d75ea6

Browse files
committed
threads and assistants refresh
1 parent fa95168 commit 9d75ea6

File tree

2 files changed

+56
-30
lines changed

2 files changed

+56
-30
lines changed

articles/ai-services/openai/assistants-reference-threads.md

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ description: Learn how to use Azure OpenAI's Python & REST API threads with Assi
55
manager: nitinme
66
ms.service: azure-ai-openai
77
ms.topic: conceptual
8-
ms.date: 05/20/2024
9-
author: mrbullwinkle
10-
ms.author: mbullwin
8+
ms.date: 09/17/2024
9+
author: aahill
10+
ms.author: aahi
1111
recommendations: false
1212
ms.custom: devx-track-python
1313
---
@@ -21,7 +21,7 @@ This article provides reference documentation for Python and REST for the new As
2121
## Create a thread
2222

2323
```http
24-
POST https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads?api-version=2024-05-01-preview
24+
POST https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads?api-version=2024-08-01-preview
2525
```
2626

2727
Create a thread.
@@ -32,6 +32,22 @@ Create a thread.
3232
|--- |--- |--- |--- |
3333
|`messages`|array| Optional | A list of messages to start the thread with. |
3434
|`metadata`| map | Optional | Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. |
35+
| `tool_resources` | [object](#tool_resources-properties) | Optional | A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. |
36+
37+
### tool_resources properties
38+
39+
**code_interpreter**
40+
41+
| Name | Type | Description | Default |
42+
|--- |--- |--- |--- |
43+
| `file_ids` | array | A list of file IDs made available to the code_interpreter tool. There can be a maximum of 20 files associated with the tool. | `[]` |
44+
45+
**file_search**
46+
47+
| Name | Type | Description | Default |
48+
|--- |--- |--- |--- |
49+
| `vector_store_ids` | array | The vector store attached to this thread. There can be a maximum of 1 vector store attached to the thread. | `[]` |
50+
| `vector_stores` | array | A helper to create a vector store with file_ids and attach it to this thread. There can be a maximum of 1 vector store attached to the thread. | `[]` |
3551

3652
### Returns
3753

@@ -46,7 +62,7 @@ from openai import AzureOpenAI
4662

4763
client = AzureOpenAI(
4864
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
49-
api_version="2024-05-01-preview",
65+
api_version="2024-08-01-preview",
5066
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
5167
)
5268

@@ -57,7 +73,7 @@ print(empty_thread)
5773
# [REST](#tab/rest)
5874

5975
```console
60-
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads?api-version=2024-05-01-preview \
76+
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads?api-version=2024-08-01-preview \
6177
-H "api-key: $AZURE_OPENAI_API_KEY" \
6278
-H 'Content-Type: application/json' \
6379
-d ''
@@ -68,7 +84,7 @@ curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads?api-version=2024
6884
## Retrieve thread
6985

7086
```http
71-
GET https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads/{thread_id}?api-version=2024-05-01-preview
87+
GET https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads/{thread_id}?api-version=2024-08-01-preview
7288
```
7389

7490
Retrieves a thread.
@@ -93,7 +109,7 @@ from openai import AzureOpenAI
93109

94110
client = AzureOpenAI(
95111
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
96-
api_version="2024-05-01-preview",
112+
api_version="2024-08-01-preview",
97113
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
98114
)
99115

@@ -104,7 +120,7 @@ print(my_thread)
104120
# [REST](#tab/rest)
105121

106122
```console
107-
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads/{thread_id}?api-version=2024-05-01-preview \
123+
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads/{thread_id}?api-version=2024-08-01-preview \
108124
-H "api-key: $AZURE_OPENAI_API_KEY" \
109125
-H 'Content-Type: application/json'
110126
```
@@ -114,7 +130,7 @@ curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads/{thread_id}?api-
114130
## Modify thread
115131

116132
```http
117-
POST https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads/{thread_id}?api-version=2024-05-01-preview
133+
POST https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads/{thread_id}?api-version=2024-08-01-preview
118134
```
119135

120136
Modifies a thread.
@@ -129,7 +145,8 @@ Modifies a thread.
129145

130146
|Name | Type | Required | Description |
131147
|--- |--- |--- |--- |
132-
| metadata| map | Optional | Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.|
148+
| `metadata` | map | Optional | Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.|
149+
| `tool_resources` | [object](#tool_resources-properties) | Optional | A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. |
133150

134151
### Returns
135152

@@ -144,7 +161,7 @@ from openai import AzureOpenAI
144161

145162
client = AzureOpenAI(
146163
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
147-
api_version="2024-05-01-preview",
164+
api_version="2024-08-01-preview",
148165
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
149166
)
150167

@@ -161,7 +178,7 @@ print(my_updated_thread)
161178
# [REST](#tab/rest)
162179

163180
```console
164-
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads/{thread_id}?api-version=2024-05-01-preview \
181+
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads/{thread_id}?api-version=2024-08-01-preview \
165182
-H "api-key: $AZURE_OPENAI_API_KEY" \
166183
-H 'Content-Type: application/json' \
167184
-d '{

articles/ai-services/openai/assistants-reference.md

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ description: Learn how to use Azure OpenAI's Python & REST API with Assistants.
55
manager: nitinme
66
ms.service: azure-ai-openai
77
ms.topic: conceptual
8-
ms.date: 07/25/2024
9-
author: mrbullwinkle
10-
ms.author: mbullwin
8+
ms.date: 09/17/2024
9+
author: aahill
10+
ms.author: aahi
1111
recommendations: false
1212
ms.custom: devx-track-python
1313
---
@@ -41,6 +41,7 @@ Create an assistant with a model and instructions.
4141
| temperature | number or null | Optional | Defaults to 1. Determines what sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. |
4242
| top_p | number or null | Optional | Defaults to 1. An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both. |
4343
| response_format | string or object | Optional | Specifies the format that the model must output. Compatible with GPT-4 Turbo and all GPT-3.5 Turbo models since gpt-3.5-turbo-1106. Setting this parameter to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is valid JSON. Importantly, when using JSON mode, you must also instruct the model to produce JSON yourself using a system or user message. Without this instruction, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Additionally, the message content may be partially cut off if you use `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. |
44+
| tool_resources | object | Optional | A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. |
4445

4546
### Returns
4647

@@ -55,7 +56,7 @@ from openai import AzureOpenAI
5556

5657
client = AzureOpenAI(
5758
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
58-
api_version="2024-05-01-preview",
59+
api_version="2024-08-01-preview",
5960
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
6061
)
6162

@@ -69,7 +70,7 @@ assistant = client.beta.assistants.create(
6970
# [REST](#tab/rest)
7071

7172
```console
72-
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/assistants?api-version=2024-05-01-preview \
73+
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/assistants?api-version=2024-08-01-preview \
7374
-H "api-key: $AZURE_OPENAI_API_KEY" \
7475
-H 'Content-Type: application/json' \
7576
-d '{
@@ -113,7 +114,7 @@ from openai import AzureOpenAI
113114

114115
client = AzureOpenAI(
115116
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
116-
api_version="2024-05-01-preview",
117+
api_version="2024-08-01-preview",
117118
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
118119
)
119120

@@ -128,7 +129,7 @@ print(my_assistants.data)
128129
# [REST](#tab/rest)
129130

130131
```console
131-
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/assistants?api-version=2024-05-01-preview \
132+
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/assistants?api-version=2024-08-01-preview \
132133
-H "api-key: $AZURE_OPENAI_API_KEY" \
133134
-H 'Content-Type: application/json'
134135
```
@@ -139,7 +140,7 @@ curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/assistants?api-version=2
139140
## Retrieve assistant
140141

141142
```http
142-
GET https://YOUR_RESOURCE_NAME.openai.azure.com/openai/assistants/{assistant_id}?api-version=2024-05-01-preview
143+
GET https://YOUR_RESOURCE_NAME.openai.azure.com/openai/assistants/{assistant_id}?api-version=2024-08-01-preview
143144
```
144145

145146
Retrieves an assistant.
@@ -161,7 +162,7 @@ The [assistant](#assistant-object) object matching the specified ID.
161162
```python
162163
client = AzureOpenAI(
163164
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
164-
api_version="2024-05-01-preview",
165+
api_version="2024-08-01-preview",
165166
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
166167
)
167168

@@ -172,7 +173,7 @@ print(my_assistant)
172173
# [REST](#tab/rest)
173174

174175
```console
175-
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/assistants/{assistant-id}?api-version=2024-05-01-preview \
176+
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/assistants/{assistant-id}?api-version=2024-08-01-preview \
176177
-H "api-key: $AZURE_OPENAI_API_KEY" \
177178
-H 'Content-Type: application/json'
178179
```
@@ -182,7 +183,7 @@ curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/assistants/{assistant-id
182183
## Modify assistant
183184

184185
```http
185-
POST https://YOUR_RESOURCE_NAME.openai.azure.com/openai/assistants/{assistant_id}?api-version=2024-05-01-preview
186+
POST https://YOUR_RESOURCE_NAME.openai.azure.com/openai/assistants/{assistant_id}?api-version=2024-08-01-preview
186187
```
187188

188189
Modifies an assistant.
@@ -202,8 +203,11 @@ Modifies an assistant.
202203
| `description` | string or null | Optional | The description of the assistant. The maximum length is 512 characters. |
203204
| `instructions` | string or null | Optional | The system instructions that the assistant uses. The maximum length is 32768 characters. |
204205
| `tools` | array | Optional | Defaults to []. A list of tools enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types code_interpreter, or function. A `function` description can be a maximum of 1,024 characters. |
205-
| `file_ids` | array | Optional | Defaults to []. A list of File IDs attached to this assistant. There can be a maximum of 20 files attached to the assistant. Files are ordered by their creation date in ascending order. If a file was previously attached to the list but does not show up in the list, it will be deleted from the assistant. |
206206
| `metadata` | map | Optional | Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. |
207+
| `temperature` | number or null | Optional | Defaults to 1. Determines what sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. |
208+
| `top_p` | number or null | Optional | Defaults to 1. An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both. |
209+
| `response_format` | string or object | Optional | Specifies the format that the model must output. Compatible with GPT-4 Turbo and all GPT-3.5 Turbo models since gpt-3.5-turbo-1106. Setting this parameter to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is valid JSON. Importantly, when using JSON mode, you must also instruct the model to produce JSON yourself using a system or user message. Without this instruction, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Additionally, the message content may be partially cut off if you use `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. |
210+
| `tool_resources` | object | Optional | A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. |
207211

208212
**Returns**
209213

@@ -216,7 +220,7 @@ The modified [assistant object](#assistant-object).
216220
```python
217221
client = AzureOpenAI(
218222
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
219-
api_version="2024-05-01-preview",
223+
api_version="2024-08-01-preview",
220224
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
221225
)
222226

@@ -235,7 +239,7 @@ print(my_updated_assistant)
235239
# [REST](#tab/rest)
236240

237241
```console
238-
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/assistants/{assistant-id}?api-version=2024-05-01-preview \
242+
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/assistants/{assistant-id}?api-version=2024-08-01-preview \
239243
-H "api-key: $AZURE_OPENAI_API_KEY" \
240244
-H 'Content-Type: application/json' \
241245
-d '{
@@ -251,7 +255,7 @@ curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/assistants/{assistant-id
251255
## Delete assistant
252256

253257
```http
254-
DELETE https://YOUR_RESOURCE_NAME.openai.azure.com/openai/assistants/{assistant_id}?api-version=2024-05-01-preview
258+
DELETE https://YOUR_RESOURCE_NAME.openai.azure.com/openai/assistants/{assistant_id}?api-version=2024-08-01-preview
255259
```
256260

257261
Delete an assistant.
@@ -273,7 +277,7 @@ Deletion status.
273277
```python
274278
client = AzureOpenAI(
275279
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
276-
api_version="2024-05-01-preview",
280+
api_version="2024-08-01-preview",
277281
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
278282
)
279283

@@ -284,7 +288,7 @@ print(response)
284288
# [REST](#tab/rest)
285289

286290
```console
287-
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/assistants/{assistant-id}?api-version=2024-05-01-preview \
291+
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/assistants/{assistant-id}?api-version=2024-08-01-preview \
288292
-H "api-key: $AZURE_OPENAI_API_KEY" \
289293
-H 'Content-Type: application/json' \
290294
-X DELETE
@@ -311,3 +315,8 @@ Assistants use the [same API for file upload as fine-tuning](/rest/api/azureopen
311315
| `tools` | array | A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types code_interpreter, or function. A `function` description can be a maximum of 1,024 characters.|
312316
| `file_ids` | array | A list of file IDs attached to this assistant. There can be a maximum of 20 files attached to the assistant. Files are ordered by their creation date in ascending order.|
313317
| `metadata` | map | Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.|
318+
319+
| `temperature` | number or null | Optional | Defaults to 1. Determines what sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. |
320+
| `top_p` | number or null | Optional | Defaults to 1. An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both. |
321+
| `response_format` | string or object | Optional | Specifies the format that the model must output. Compatible with GPT-4 Turbo and all GPT-3.5 Turbo models since gpt-3.5-turbo-1106. Setting this parameter to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is valid JSON. Importantly, when using JSON mode, you must also instruct the model to produce JSON yourself using a system or user message. Without this instruction, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Additionally, the message content may be partially cut off if you use `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. |
322+
| `tool_resources` | object | Optional | A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. |

0 commit comments

Comments
 (0)