async_openai_wasm::types

Enum AssistantStreamEvent

Source
#[non_exhaustive]
pub enum AssistantStreamEvent {
Show 25 variants TreadCreated(ThreadObject), ThreadRunCreated(RunObject), ThreadRunQueued(RunObject), ThreadRunInProgress(RunObject), ThreadRunRequiresAction(RunObject), ThreadRunCompleted(RunObject), ThreadRunIncomplete(RunObject), ThreadRunFailed(RunObject), ThreadRunCancelling(RunObject), ThreadRunCancelled(RunObject), ThreadRunExpired(RunObject), ThreadRunStepCreated(RunStepObject), ThreadRunStepInProgress(RunStepObject), ThreadRunStepDelta(RunStepDeltaObject), ThreadRunStepCompleted(RunStepObject), ThreadRunStepFailed(RunStepObject), ThreadRunStepCancelled(RunStepObject), ThreadRunStepExpired(RunStepObject), ThreadMessageCreated(MessageObject), ThreadMessageInProgress(MessageObject), ThreadMessageDelta(MessageDeltaObject), ThreadMessageCompleted(MessageObject), ThreadMessageIncomplete(MessageObject), ErrorEvent(ApiError), Done(String),
}
Expand description

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 to learn how to integrate the Assistants API with streaming.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

TreadCreated(ThreadObject)

Occurs when a new thread is created.

§

ThreadRunCreated(RunObject)

Occurs when a new run is created.

§

ThreadRunQueued(RunObject)

Occurs when a run moves to a queued status.

§

ThreadRunInProgress(RunObject)

Occurs when a run moves to an in_progress status.

§

ThreadRunRequiresAction(RunObject)

Occurs when a run moves to a requires_action status.

§

ThreadRunCompleted(RunObject)

Occurs when a run is completed.

§

ThreadRunIncomplete(RunObject)

Occurs when a run ends with status incomplete.

§

ThreadRunFailed(RunObject)

Occurs when a run fails.

§

ThreadRunCancelling(RunObject)

Occurs when a run moves to a cancelling status.

§

ThreadRunCancelled(RunObject)

Occurs when a run is cancelled.

§

ThreadRunExpired(RunObject)

Occurs when a run expires.

§

ThreadRunStepCreated(RunStepObject)

Occurs when a run step is created.

§

ThreadRunStepInProgress(RunStepObject)

Occurs when a run step moves to an in_progress state.

§

ThreadRunStepDelta(RunStepDeltaObject)

Occurs when parts of a run step are being streamed.

§

ThreadRunStepCompleted(RunStepObject)

Occurs when a run step is completed.

§

ThreadRunStepFailed(RunStepObject)

Occurs when a run step fails.

§

ThreadRunStepCancelled(RunStepObject)

Occurs when a run step is cancelled.

§

ThreadRunStepExpired(RunStepObject)

Occurs when a run step expires.

§

ThreadMessageCreated(MessageObject)

Occurs when a message is created.

§

ThreadMessageInProgress(MessageObject)

Occurs when a message moves to an in_progress state.

§

ThreadMessageDelta(MessageDeltaObject)

Occurs when parts of a Message are being streamed.

§

ThreadMessageCompleted(MessageObject)

Occurs when a message is completed.

§

ThreadMessageIncomplete(MessageObject)

Occurs when a message ends before it is completed.

§

ErrorEvent(ApiError)

Occurs when an error occurs. This can happen due to an internal server error or a timeout.

§

Done(String)

Occurs when a stream ends.

Trait Implementations§

Source§

impl Clone for AssistantStreamEvent

Source§

fn clone(&self) -> AssistantStreamEvent

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AssistantStreamEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for AssistantStreamEvent

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl TryFrom<Event> for AssistantStreamEvent

Source§

type Error = OpenAIError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Event) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into<'async_trait>( self, ) -> Pin<Box<dyn Future<Output = Result<U, <U as TryFrom<T>>::Error>> + 'async_trait>>
where T: 'async_trait,

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T