pub struct Response {
pub id: Uuid,
pub conversation_id: String,
pub content: String,
pub response_type: ResponseType,
pub error: Option<ResponseError>,
pub metadata: HashMap<String, Value>,
pub timestamp: DateTime<Utc>,
pub usage: Option<TokenUsage>,
pub flags: ResponseFlags,
pub suggestions: Vec<Suggestion>,
}Expand description
A response from the bot
Fields§
§id: UuidUnique response ID
conversation_id: StringConversation ID
content: StringResponse content
response_type: ResponseTypeResponse type
error: Option<ResponseError>Optional error information
metadata: HashMap<String, Value>Response metadata
timestamp: DateTime<Utc>Timestamp
usage: Option<TokenUsage>Token usage information
flags: ResponseFlagsResponse flags
suggestions: Vec<Suggestion>Optional suggested actions
Implementations§
Source§impl Response
impl Response
Sourcepub fn text(
conversation_id: impl Into<String>,
content: impl Into<String>,
) -> Self
pub fn text( conversation_id: impl Into<String>, content: impl Into<String>, ) -> Self
Create a new text response
Sourcepub fn error(conversation_id: impl Into<String>, error: ResponseError) -> Self
pub fn error(conversation_id: impl Into<String>, error: ResponseError) -> Self
Create an error response
Sourcepub fn with_usage(self, usage: TokenUsage) -> Self
pub fn with_usage(self, usage: TokenUsage) -> Self
Add token usage information
Sourcepub fn with_suggestion(self, suggestion: Suggestion) -> Self
pub fn with_suggestion(self, suggestion: Suggestion) -> Self
Add a suggestion
Sourcepub fn with_flags(self, flags: ResponseFlags) -> Self
pub fn with_flags(self, flags: ResponseFlags) -> Self
Set response flags
Sourcepub fn total_tokens(&self) -> usize
pub fn total_tokens(&self) -> usize
Get the total tokens used
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Response
impl<'de> Deserialize<'de> for Response
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 Response
impl RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnwindSafe for Response
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