Skip to content

Commit a562a2f

Browse files
committed
Merge branch 'main' of https://github.com/MicrosoftDocs/azure-docs-pr into vm-toc
2 parents 6cfac4c + ad544c2 commit a562a2f

24 files changed

+98
-374
lines changed

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

Lines changed: 40 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Learn how to use Azure OpenAI's Python & REST API messages with Ass
55
manager: nitinme
66
ms.service: azure-ai-openai
77
ms.topic: conceptual
8-
ms.date: 02/01/2024
8+
ms.date: 07/25/2024
99
author: mrbullwinkle
1010
ms.author: mbullwin
1111
recommendations: false
@@ -136,63 +136,6 @@ curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads/{thread_id}/mess
136136

137137
---
138138

139-
## List message files
140-
141-
```http
142-
GET https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads/{thread_id}/messages/{message_id}/files?api-version=2024-05-01-preview
143-
```
144-
145-
Returns a list of message files.
146-
147-
|Parameter| Type | Required | Description |
148-
|---|---|---|---|
149-
|`thread_id` | string | Required | The ID of the thread that the message and files belong to. |
150-
|`message_id`| string | Required | The ID of the message that the files belong to. |
151-
152-
**Query Parameters**
153-
154-
|Name | Type | Required | Description |
155-
|--- |--- |--- |--- |
156-
| `limit` | integer | Optional - Defaults to 20 |A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.|
157-
| `order` | string | Optional - Defaults to desc |Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.|
158-
| `after` | string | Optional | A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.|
159-
| `before` | string | Optional | A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.|
160-
161-
### Returns
162-
163-
A list of [message file](#message-file-object) objects
164-
165-
### Example list message files request
166-
167-
# [Python 1.x](#tab/python)
168-
169-
```python
170-
from openai import AzureOpenAI
171-
172-
client = AzureOpenAI(
173-
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
174-
api_version="2024-05-01-preview",
175-
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
176-
)
177-
178-
message_files = client.beta.threads.messages.files.list(
179-
thread_id="thread_abc123",
180-
message_id="msg_abc123"
181-
)
182-
print(message_files)
183-
184-
```
185-
186-
# [REST](#tab/rest)
187-
188-
```console
189-
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads/{thread_id}/messages/files?api-version=2024-05-01-preview \
190-
-H "api-key: $AZURE_OPENAI_API_KEY" \
191-
-H 'Content-Type: application/json'
192-
```
193-
194-
---
195-
196139
## Retrieve message
197140

198141
```http
@@ -219,7 +162,7 @@ The [message](#message-object) object matching the specified ID.
219162

220163
```python
221164
from openai import AzureOpenAI
222-
165+
223166
client = AzureOpenAI(
224167
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
225168
api_version="2024-05-01-preview",
@@ -244,27 +187,30 @@ curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads/{thread_id}/mess
244187

245188
---
246189

247-
## Retrieve message file
190+
## Modify message
248191

249192
```http
250-
GET https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads/{thread_id}/messages/{message_id}/files/{file_id}?api-version=2024-05-01-preview
193+
POST https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads/{thread_id}/messages/{message_id}?api-version=2024-05-01-preview
251194
```
252195

253-
Retrieves a message file.
196+
Modifies a message.
254197

255198
**Path parameters**
256199

257200
|Parameter| Type | Required | Description |
258201
|---|---|---|---|
259-
|`thread_id` | string | Required | The ID of the thread, which the message and file belongs to. |
260-
|`message_id`| string | Required | The ID of the message that the file belongs to. |
261-
|`file_id` | string | Required | The ID of the file being retrieved. |
202+
|`thread_id` | string | Required | The ID of the thread to which the message belongs. |
203+
|`message_id`| string | Required | The ID of the message to modify. |
204+
205+
**Request body**
262206

263-
**Returns**
207+
|Parameter| Type | Required | Description |
208+
|---|---|---|---|
209+
| 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.|
264210

265-
The [message file](#message-file-object) object.
211+
### Returns
266212

267-
### Example retrieve message file request
213+
The modified [message](#message-object) object.
268214

269215
# [Python 1.x](#tab/python)
270216

@@ -277,32 +223,43 @@ client = AzureOpenAI(
277223
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
278224
)
279225

280-
message_files = client.beta.threads.messages.files.retrieve(
281-
thread_id="thread_abc123",
282-
message_id="msg_abc123",
283-
file_id="assistant-abc123"
226+
message = client.beta.threads.messages.update(
227+
message_id="msg_abc12",
228+
thread_id="thread_abc123",
229+
metadata={
230+
"modified": "true",
231+
"user": "abc123",
232+
},
284233
)
285-
print(message_files)
234+
print(message)
286235
```
287236

288237
# [REST](#tab/rest)
289238

290239
```console
291-
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads/{thread_id}/messages/{message_id}/files/{file_id}?api-version=2024-05-01-preview
240+
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads/{thread_id}/messages/{message_id}?api-version=2024-05-01-preview
292241
``` \
293242
-H "api-key: $AZURE_OPENAI_API_KEY" \
294-
-H 'Content-Type: application/json'
243+
-H 'Content-Type: application/json' \
244+
-d '{
245+
"metadata": {
246+
"modified": "true",
247+
"user": "abc123"
248+
}
249+
}'
250+
295251
```
296252

297253
---
298254

299-
## Modify message
255+
## Delete message
256+
300257

301258
```http
302-
POST https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads/{thread_id}/messages/{message_id}?api-version=2024-05-01-preview
259+
DELETE https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads/{thread_id}/messages/{message_id}?api-version=2024-05-01-preview
303260
```
304261

305-
Modifies a message.
262+
Deletes a message.
306263

307264
**Path parameters**
308265

@@ -311,52 +268,33 @@ Modifies a message.
311268
|`thread_id` | string | Required | The ID of the thread to which the message belongs. |
312269
|`message_id`| string | Required | The ID of the message to modify. |
313270

314-
**Request body**
315-
316-
|Parameter| Type | Required | Description |
317-
|---|---|---|---|
318-
| 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.|
319-
320271
### Returns
321272

322-
The modified [message](#message-object) object.
273+
The deletion status of the [message](#message-object) object.
323274

324275
# [Python 1.x](#tab/python)
325276

326277
```python
327278
from openai import AzureOpenAI
328-
329279
client = AzureOpenAI(
330280
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
331281
api_version="2024-05-01-preview",
332282
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
333283
)
334284

335-
message = client.beta.threads.messages.update(
285+
deleted_message = client.beta.threads.messages.delete(
336286
message_id="msg_abc12",
337287
thread_id="thread_abc123",
338-
metadata={
339-
"modified": "true",
340-
"user": "abc123",
341-
},
342288
)
343-
print(message)
289+
print(deleted_message)
344290
```
345291

346292
# [REST](#tab/rest)
347293

348294
```console
349-
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads/{thread_id}/messages/{message_id}?api-version=2024-05-01-preview
350-
``` \
295+
curl -x DELETE https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads/{thread_id}/messages/{message_id}?api-version=2024-05-01-preview \
351296
-H "api-key: $AZURE_OPENAI_API_KEY" \
352-
-H 'Content-Type: application/json' \
353-
-d '{
354-
"metadata": {
355-
"modified": "true",
356-
"user": "abc123"
357-
}
358-
}'
359-
297+
-H 'Content-Type: application/json'
360298
```
361299

362300
---
@@ -377,14 +315,3 @@ Represents a message within a thread.
377315
| `run_id` | string or null |If applicable, the ID of the run associated with the authoring of this message.|
378316
| `file_ids` | array |A list of file IDs that the assistant should use. Useful for tools like retrieval and code_interpreter that can access files. A maximum of 10 files can be attached to a message.|
379317
| `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.|
380-
381-
## Message file object
382-
383-
A list of files attached to a message.
384-
385-
|Name | Type | Description |
386-
|--- |--- |--- |
387-
| `id`| string | The identifier, which can be referenced in API endpoints.|
388-
|`object`|string| The object type, which is always `thread.message.file`.|
389-
|`created_at`|integer | The Unix timestamp (in seconds) for when the message file was created.|
390-
|`message_id`| string | The ID of the message that the File is attached to.|

0 commit comments

Comments
 (0)