pub struct Request {
pub model: String,
pub system: Option<String>,
pub messages: Vec<Message>,
pub temperature: Option<f64>,
pub max_tokens: Option<u32>,
pub tools: Vec<Tool>,
pub stop_sequences: Vec<String>,
}Expand description
A single call to a model.
Fields§
§model: String§system: Option<String>Instructions that frame the conversation. Kept apart from the messages because Anthropic wants it as a top-level field, and because a system prompt is configuration rather than dialogue.
messages: Vec<Message>§temperature: Option<f64>§max_tokens: Option<u32>§tools: Vec<Tool>§stop_sequences: Vec<String>Implementations§
Source§impl Request
impl Request
pub fn new(model: impl Into<String>) -> Request
pub fn model(self, model: impl Into<String>) -> Request
pub fn system(self, system: impl Into<String>) -> Request
pub fn message(self, message: Message) -> Request
pub fn messages(self, messages: impl IntoIterator<Item = Message>) -> Request
pub fn conversation(self, conversation: Conversation) -> Request
pub fn user(self, text: impl Into<String>) -> Request
pub fn assistant(self, text: impl Into<String>) -> Request
Sourcepub fn temperature(self, temperature: f64) -> Request
pub fn temperature(self, temperature: f64) -> Request
How adventurous the model may be, from 0.0 to 1.0.
pub fn max_tokens(self, max_tokens: u32) -> Request
pub fn tool(self, tool: Tool) -> Request
pub fn tools(self, tools: impl IntoIterator<Item = Tool>) -> Request
pub fn stop(self, sequence: impl Into<String>) -> Request
Sourcepub fn effective_system(&self) -> Option<String>
pub fn effective_system(&self) -> Option<String>
The system prompt as the provider should see it.
A caller can set system directly or push Role::System messages
into the conversation; both are honoured, joined in order, so no
instruction is silently dropped just because it arrived the other way.
Sourcepub fn dialogue(&self) -> impl Iterator<Item = &Message>
pub fn dialogue(&self) -> impl Iterator<Item = &Message>
The messages minus the system ones, which every provider carries separately or not at all.
Sourcepub fn last_user_text(&self) -> Option<String>
pub fn last_user_text(&self) -> Option<String>
The last thing the user said, for logs and fakes that match on it.
Trait Implementations§
impl StructuralPartialEq for Request
Auto Trait Implementations§
impl Freeze for Request
impl RefUnwindSafe for Request
impl Send for Request
impl Sync for Request
impl Unpin for Request
impl UnsafeUnpin for Request
impl UnwindSafe for Request
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