pub struct CompletionRequest {
pub system: String,
pub messages: Vec<Message>,
pub tools: Vec<ToolInfo>,
pub max_tokens: Option<u32>,
pub temperature: Option<f32>,
pub stop_sequences: Vec<String>,
}Expand description
A request to complete a conversation
This struct contains everything needed to make a completion request:
- System prompt (instructions for the model)
- Messages (the conversation history)
- Available tools
- Model parameters (temperature, max tokens, etc.)
Fields§
§system: StringSystem prompt - instructions for how the model should behave
messages: Vec<Message>The conversation messages
tools: Vec<ToolInfo>Tools available for the model to use
max_tokens: Option<u32>Maximum tokens to generate
temperature: Option<f32>Temperature for sampling (0.0 = deterministic, 1.0 = creative)
stop_sequences: Vec<String>Stop sequences - generation stops if any of these are produced
Implementations§
Source§impl CompletionRequest
impl CompletionRequest
Sourcepub fn new(system: impl Into<String>) -> Self
pub fn new(system: impl Into<String>) -> Self
Create a new completion request with a system prompt
Sourcepub fn with_message(self, message: Message) -> Self
pub fn with_message(self, message: Message) -> Self
Add a message to the conversation
Sourcepub fn with_messages(self, messages: impl IntoIterator<Item = Message>) -> Self
pub fn with_messages(self, messages: impl IntoIterator<Item = Message>) -> Self
Add multiple messages to the conversation
Sourcepub fn with_tools(self, tools: Vec<ToolInfo>) -> Self
pub fn with_tools(self, tools: Vec<ToolInfo>) -> Self
Set the available tools
Sourcepub fn with_max_tokens(self, max_tokens: u32) -> Self
pub fn with_max_tokens(self, max_tokens: u32) -> Self
Set the maximum tokens to generate
Sourcepub fn with_temperature(self, temperature: f32) -> Self
pub fn with_temperature(self, temperature: f32) -> Self
Set the temperature
Sourcepub fn with_stop_sequences(self, sequences: Vec<String>) -> Self
pub fn with_stop_sequences(self, sequences: Vec<String>) -> Self
Add stop sequences
Trait Implementations§
Source§impl Clone for CompletionRequest
impl Clone for CompletionRequest
Source§impl Debug for CompletionRequest
impl Debug for CompletionRequest
Source§impl<'de> Deserialize<'de> for CompletionRequest
impl<'de> Deserialize<'de> for CompletionRequest
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 CompletionRequest
impl RefUnwindSafe for CompletionRequest
impl Send for CompletionRequest
impl Sync for CompletionRequest
impl Unpin for CompletionRequest
impl UnsafeUnpin for CompletionRequest
impl UnwindSafe for CompletionRequest
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