pub struct LLMResponse {
pub message: LLMMessage,
pub model: String,
pub usage: TokenUsage,
pub stop_reason: Option<String>,
pub metadata: HashMap<String, Value>,
pub timestamp: DateTime<Utc>,
}
Expand description
Response from an LLM provider
Fields§
§message: LLMMessage
Generated message
model: String
Model used for generation
usage: TokenUsage
Token usage information
stop_reason: Option<String>
Stop reason
metadata: HashMap<String, Value>
Response metadata
timestamp: DateTime<Utc>
Generation timestamp
Implementations§
Source§impl LLMResponse
impl LLMResponse
Sourcepub fn new(
message: LLMMessage,
model: impl Into<String>,
usage: TokenUsage,
) -> Self
pub fn new( message: LLMMessage, model: impl Into<String>, usage: TokenUsage, ) -> Self
Create a new LLM response
Sourcepub fn with_stop_reason(self, stop_reason: impl Into<String>) -> Self
pub fn with_stop_reason(self, stop_reason: impl Into<String>) -> Self
Set stop reason
Sourcepub fn with_metadata(self, key: String, value: Value) -> Self
pub fn with_metadata(self, key: String, value: Value) -> Self
Add metadata
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Check if response is complete
Trait Implementations§
Source§impl Clone for LLMResponse
impl Clone for LLMResponse
Source§fn clone(&self) -> LLMResponse
fn clone(&self) -> LLMResponse
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for LLMResponse
impl Debug for LLMResponse
Source§impl<'de> Deserialize<'de> for LLMResponse
impl<'de> Deserialize<'de> for LLMResponse
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
Auto Trait Implementations§
impl Freeze for LLMResponse
impl RefUnwindSafe for LLMResponse
impl Send for LLMResponse
impl Sync for LLMResponse
impl Unpin for LLMResponse
impl UnwindSafe for LLMResponse
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