pub struct Response {
pub messages: Vec<Message>,
pub usage: Option<Usage>,
pub model: String,
pub provider: ProviderKind,
pub finish_reason: Option<String>,
}Expand description
The response from an AI generation request.
§Examples
use rai_sdk::{ClientBuilder, Model};
let client = ClientBuilder::new()
.from_env()
.model(Model::gpt4o_mini())
.build()?;
let response = client.request().prompt("Say hi.").generate().await?;
println!("{}", response.text());
println!("served by {} using {}", response.provider, response.model);
if let Some(usage) = &response.usage {
println!("{:?} total tokens", usage.total_tokens);
}Fields§
§messages: Vec<Message>The generated message(s).
usage: Option<Usage>Token usage information.
model: StringThe model that was used.
provider: ProviderKindThe provider that was used.
finish_reason: Option<String>Finish reason (e.g., “stop”, “length”, “tool_use”).
Implementations§
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
impl StructuralPartialEq for Response
Auto Trait Implementations§
impl Freeze for Response
impl RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnsafeUnpin 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