openai_struct/models/
assistant_stream_event.rs

1/*
2 * OpenAI API
3 *
4 * The OpenAI REST API. Please see pub https://platform.openai.com/docs/api-reference for more details.
5 *
6 * OpenAPI spec pub version: 2.3.0
7 *
8 * Generated pub by: https://github.com/swagger-api/swagger-codegen.git
9 */
10
11/// pub AssistantStreamEvent : Represents an event emitted when streaming a Run.  Each event in a server-sent events stream has an `event` and `data` property:  ``` event: thread.created data: {\"id\": \"thread_123\", \"object\": \"thread\", ...} ```  We emit events whenever a new object is created, transitions to a new state, or is being streamed in parts (deltas). For example, we emit `thread.run.created` 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.  We may add additional events over time, so we recommend handling unknown events gracefully in your code. See the [Assistants API quickstart](/docs/assistants/overview) to learn how to integrate the Assistants API with streaming.
12
13#[allow(unused_imports)]
14use serde_json::Value;
15
16use crate::{
17    DoneEvent, ErrorEvent, MessageStreamEvent, RunStepStreamEvent, RunStreamEvent,
18    ThreadStreamEvent,
19};
20
21/// # on openapi.yaml
22///
23/// ```yaml
24/// AssistantStreamEvent:
25///   description: >
26///     Represents an event emitted when streaming a Run.
27///
28///
29///     Each event in a server-sent events stream has an `event` and `data`
30///     property:
31///
32///
33///     ```
34///
35///     event: thread.created
36///
37///     data: {"id": "thread_123", "object": "thread", ...}
38///
39///     ```
40///
41///
42///     We emit events whenever a new object is created, transitions to a new
43///     state, or is being
44///
45///     streamed in parts (deltas). For example, we emit `thread.run.created`
46///     when a new run
47///
48///     is created, `thread.run.completed` when a run completes, and so on. When
49///     an Assistant chooses
50///
51///     to create a message during a run, we emit a `thread.message.created
52///     event`, a
53///
54///     `thread.message.in_progress` event, many `thread.message.delta` events,
55///     and finally a
56///
57///     `thread.message.completed` event.
58///
59///
60///     We may add additional events over time, so we recommend handling unknown
61///     events gracefully
62///
63///     in your code. See the [Assistants API
64///     quickstart](/docs/assistants/overview) to learn how to
65///
66///     integrate the Assistants API with streaming.
67///   oneOf:
68///     - $ref: "#/components/schemas/ThreadStreamEvent"
69///     - $ref: "#/components/schemas/RunStreamEvent"
70///     - $ref: "#/components/schemas/RunStepStreamEvent"
71///     - $ref: "#/components/schemas/MessageStreamEvent"
72///     - $ref: "#/components/schemas/ErrorEvent"
73///     - $ref: "#/components/schemas/DoneEvent"
74///   x-oaiMeta:
75///     name: Assistant stream events
76///     beta: true
77/// ````
78#[derive(Debug, Serialize, Deserialize)]
79pub enum AssistantStreamEvent {
80    ThreadStream(ThreadStreamEvent),
81    RunStream(RunStreamEvent),
82    RunStepStream(RunStepStreamEvent),
83    MessageStream(MessageStreamEvent),
84    Error(ErrorEvent),
85    Done(DoneEvent),
86}