pub struct CompletionRequest {
pub model: String,
pub messages: Vec<ChatMessage>,
pub max_tokens: Option<u32>,
pub temperature: Option<f32>,
pub system: Option<String>,
pub tools: Vec<ToolDefinition>,
pub stop: Vec<String>,
pub metadata: HashMap<String, String>,
}Expand description
An LLM completion request.
Fields§
§model: StringModel identifier (e.g., “gpt-4”, “claude-3-opus”, “llama-3-70b”).
messages: Vec<ChatMessage>Messages in the conversation.
max_tokens: Option<u32>Maximum tokens to generate.
temperature: Option<f32>Temperature (0.0 = deterministic, 1.0 = creative).
system: Option<String>System prompt.
tools: Vec<ToolDefinition>Tool/function definitions (for function calling).
stop: Vec<String>Stop sequences.
metadata: HashMap<String, String>Request metadata (for tracking, routing).
Implementations§
Source§impl CompletionRequest
impl CompletionRequest
Sourcepub fn new(model: impl Into<String>, user_message: impl Into<String>) -> Self
pub fn new(model: impl Into<String>, user_message: impl Into<String>) -> Self
Create a simple completion request.
Sourcepub fn with_system(self, system: impl Into<String>) -> Self
pub fn with_system(self, system: impl Into<String>) -> Self
Add a system prompt.
Sourcepub fn with_max_tokens(self, max: u32) -> Self
pub fn with_max_tokens(self, max: u32) -> Self
Set max tokens.
Sourcepub fn with_temperature(self, temp: f32) -> Self
pub fn with_temperature(self, temp: f32) -> Self
Set temperature.
Sourcepub fn with_tool(self, tool: ToolDefinition) -> Self
pub fn with_tool(self, tool: ToolDefinition) -> Self
Add a tool definition.
Trait Implementations§
Source§impl Clone for CompletionRequest
impl Clone for CompletionRequest
Source§impl Debug for CompletionRequest
impl Debug for CompletionRequest
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> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.