You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/ai-services/openai/assistants-reference-runs.md
+113-1Lines changed: 113 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ description: Learn how to use Azure OpenAI's Python & REST API runs with Assista
5
5
manager: nitinme
6
6
ms.service: azure-ai-openai
7
7
ms.topic: conceptual
8
-
ms.date: 02/01/2024
8
+
ms.date: 04/16/2024
9
9
author: mrbullwinkle
10
10
ms.author: mbullwin
11
11
recommendations: false
@@ -585,3 +585,115 @@ Represent a step in execution of a run.
585
585
|`failed_at`| integer or null | The Unix timestamp (in seconds) for when the run step failed.|
586
586
|`completed_at`| integer or null | The Unix timestamp (in seconds) for when the run step completed.|
587
587
|`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.|
588
+
589
+
## Stream a run result (preview)
590
+
591
+
Stream the result of executing a Run or resuming a Run after submitting tool outputs. You can stream events after:
To stream a result, pass `"stream": true` while creating a run. The response will be a [Server-Sent events](https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events) stream.
597
+
598
+
### Streaming example
599
+
600
+
```python
601
+
from typing_extensions import override
602
+
from openai import AssistantEventHandler
603
+
604
+
# First, we create a EventHandler class to define
605
+
# how we want to handle the events in the response stream.
Events are emitted whenever a new object is created, transitions to a new state, or is being streamed in parts (deltas). For example, `thread.run.created` is emitted when a new run is created, `thread.run.completed` when a run completes, and so on. When an Assistant chooses to create a message during a run, we emit a `thread.message.created` event, a `thread.message.in_progress` event, many thread.`message.delta` events, and finally a `thread.message.completed` event.
673
+
674
+
|Name | Type | Description |
675
+
|--- |--- |--- |
676
+
|`thread.created`|`data` is a thread. | Occurs when a new thread is created. |
677
+
|`thread.run.created`|`data` is a run. | Occurs when a new run is created. |
678
+
|`thread.run.queued`|`data` is a run. | Occurs when a run moves to a queued status. |
679
+
|`thread.run.in_progress`|`data` is a run. | Occurs when a run moves to an in_progress status. |
680
+
|`thread.run.requires_action`|`data` is a run. | Occurs when a run moves to a `requires_action` status. |
681
+
|`thread.run.completed`|`data` is a run. | Occurs when a run is completed. |
682
+
|`thread.run.failed`|`data` is a run. | Occurs when a run fails. |
683
+
|`thread.run.cancelling`|`data` is a run. | Occurs when a run moves to a `cancelling` status. |
684
+
|`thread.run.cancelled`|`data` is a run. | Occurs when a run is cancelled. |
685
+
|`thread.run.expired`|`data` is a run. | Occurs when a run expires. |
686
+
|`thread.run.step.created`|`data` is a run step. | Occurs when a run step is created. |
687
+
|`thread.run.step.in_progress`|`data` is a run step. | Occurs when a run step moves to an `in_progress` state. |
688
+
|`thread.run.step.delta`|`data` is a run step delta. | Occurs when parts of a run step are being streamed. |
689
+
|`thread.run.step.completed`|`data` is a run step. | Occurs when a run step is completed. |
690
+
|`thread.run.step.failed`|`data` is a run step. | Occurs when a run step fails. |
691
+
|`thread.run.step.cancelled`|`data` is a run step. | Occurs when a run step is cancelled. |
692
+
|`thread.run.step.expired`|`data` is a run step. | Occurs when a run step expires. |
693
+
|`thread.message.created`|`data` is a message. | Occurs when a message is created. |
694
+
|`thread.message.in_progress`|`data` is a message. | Occurs when a message moves to an in_progress state. |
695
+
|`thread.message.delta`|`data` is a message delta. | Occurs when parts of a Message are being streamed. |
696
+
|`thread.message.completed`|`data` is a message. | Occurs when a message is completed. |
697
+
|`thread.message.incomplete`|`data` is a message. | Occurs when a message ends before it is completed. |
698
+
|`error`|`data` is an error. | Occurs when an error occurs. This can happen due to an internal server error or a timeout. |
699
+
|`done`|`data` is `[DONE]`| Occurs when a stream ends. |
0 commit comments