pub struct ChatResponse { /* private fields */ }Expand description
Response from a chat completion request.
Contains the AI’s response message plus metadata like token usage, completion ID, and timestamps. Use this when you need more than just the response text.
§When to Use
Use ChippClient::chat_detailed() to get a ChatResponse
when you need:
- Token usage for rate limiting and monitoring
- Completion ID for debugging/logging
- Finish reason to understand why completion stopped
For simple use cases where you only need the response text,
use ChippClient::chat() instead.
§Example
use chipp::{ChippClient, ChippConfig, ChippSession, ChippMessage};
let mut session = ChippSession::new();
let response = client.chat_detailed(&mut session, &[ChippMessage::user("Hello!")]).await?;
println!("Response: {}", response.content());
println!("Tokens used: {}", response.usage().total_tokens);
println!("Completion ID: {}", response.completion_id());Implementations§
Source§impl ChatResponse
impl ChatResponse
Sourcepub fn session_id(&self) -> &str
pub fn session_id(&self) -> &str
Get the chat session ID.
Use this to continue conversations across requests.
Sourcepub fn usage(&self) -> &Usage
pub fn usage(&self) -> &Usage
Get token usage information.
Use this for rate limiting and monitoring.
Sourcepub fn completion_id(&self) -> &str
pub fn completion_id(&self) -> &str
Get the completion ID.
Useful for debugging and request tracing.
Sourcepub fn created_at(&self) -> i64
pub fn created_at(&self) -> i64
Get the creation timestamp (Unix time).
Sourcepub fn finish_reason(&self) -> &str
pub fn finish_reason(&self) -> &str
Get the finish reason.
Common values:
"stop": Normal completion"length": Max tokens reached
Trait Implementations§
Source§impl Clone for ChatResponse
impl Clone for ChatResponse
Source§fn clone(&self) -> ChatResponse
fn clone(&self) -> ChatResponse
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 moreAuto Trait Implementations§
impl Freeze for ChatResponse
impl RefUnwindSafe for ChatResponse
impl Send for ChatResponse
impl Sync for ChatResponse
impl Unpin for ChatResponse
impl UnwindSafe for ChatResponse
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