pub struct LLMStreamingEvent { /* private fields */ }Expand description
An LLM event carrying a response chunk, a final marker, or an error.
Implementations§
Source§impl LLMStreamingEvent
impl LLMStreamingEvent
Sourcepub fn builder(chunk: impl Into<String>) -> LLMStreamingEventBuilder
pub fn builder(chunk: impl Into<String>) -> LLMStreamingEventBuilder
Return a builder for constructing a new event; chunk is the only required field.
Sourcepub fn chunk_event(
session_id: Option<String>,
node_id: Option<String>,
stream_id: Option<String>,
chunk: impl Into<String>,
metadata: FxHashMap<String, Value>,
) -> Self
pub fn chunk_event( session_id: Option<String>, node_id: Option<String>, stream_id: Option<String>, chunk: impl Into<String>, metadata: FxHashMap<String, Value>, ) -> Self
Create a partial-chunk event.
Sourcepub fn final_event(
session_id: Option<String>,
node_id: Option<String>,
stream_id: Option<String>,
chunk: impl Into<String>,
metadata: FxHashMap<String, Value>,
) -> Self
pub fn final_event( session_id: Option<String>, node_id: Option<String>, stream_id: Option<String>, chunk: impl Into<String>, metadata: FxHashMap<String, Value>, ) -> Self
Create a final-chunk event marking the end of the stream.
Sourcepub fn error_event(
session_id: Option<String>,
node_id: Option<String>,
stream_id: Option<String>,
error_message: impl Into<String>,
) -> Self
pub fn error_event( session_id: Option<String>, node_id: Option<String>, stream_id: Option<String>, error_message: impl Into<String>, ) -> Self
Create an error event marking a failed streaming session.
Sourcepub fn session_id(&self) -> Option<&str>
pub fn session_id(&self) -> Option<&str>
Returns the session ID, if set.
Sourcepub fn scope(&self) -> &LLMStreamingEventScope
pub fn scope(&self) -> &LLMStreamingEventScope
Returns the scope discriminant.
Sourcepub fn with_metadata(self, metadata: FxHashMap<String, Value>) -> Self
pub fn with_metadata(self, metadata: FxHashMap<String, Value>) -> Self
Replace the metadata map and return self.
Sourcepub fn with_timestamp(self, timestamp: DateTime<Utc>) -> Self
pub fn with_timestamp(self, timestamp: DateTime<Utc>) -> Self
Replace the timestamp and return self.
Trait Implementations§
Source§impl Clone for LLMStreamingEvent
impl Clone for LLMStreamingEvent
Source§impl Debug for LLMStreamingEvent
impl Debug for LLMStreamingEvent
Source§impl<'de> Deserialize<'de> for LLMStreamingEvent
impl<'de> Deserialize<'de> for LLMStreamingEvent
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for LLMStreamingEvent
Source§impl PartialEq for LLMStreamingEvent
impl PartialEq for LLMStreamingEvent
Source§impl Serialize for LLMStreamingEvent
impl Serialize for LLMStreamingEvent
impl StructuralPartialEq for LLMStreamingEvent
Auto Trait Implementations§
impl Freeze for LLMStreamingEvent
impl RefUnwindSafe for LLMStreamingEvent
impl Send for LLMStreamingEvent
impl Sync for LLMStreamingEvent
impl Unpin for LLMStreamingEvent
impl UnsafeUnpin for LLMStreamingEvent
impl UnwindSafe for LLMStreamingEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> JsonSerializable<PersistenceError> for Twhere
T: Serialize + for<'de> DeserializeOwned,
impl<T> JsonSerializable<PersistenceError> for Twhere
T: Serialize + for<'de> DeserializeOwned,
Source§fn to_json_string(&self) -> Result<String, PersistenceError>
fn to_json_string(&self) -> Result<String, PersistenceError>
Serialize to a JSON string.
Source§fn from_json_str(s: &str) -> Result<T, PersistenceError>
fn from_json_str(s: &str) -> Result<T, PersistenceError>
Deserialize from a JSON string.