pub struct LLMRequest {
pub model: String,
pub messages: Vec<LLMMessage>,
pub params: GenerationParams,
pub stream: bool,
pub metadata: HashMap<String, Value>,
pub timeout: Option<Duration>,
}
Expand description
Request to an LLM provider
Fields§
§model: String
Model to use for generation
messages: Vec<LLMMessage>
Conversation messages
params: GenerationParams
Generation parameters
stream: bool
Enable streaming response
metadata: HashMap<String, Value>
Request metadata
timeout: Option<Duration>
Timeout for the request
Implementations§
Source§impl LLMRequest
impl LLMRequest
Sourcepub fn new(model: impl Into<String>, messages: Vec<LLMMessage>) -> Self
pub fn new(model: impl Into<String>, messages: Vec<LLMMessage>) -> Self
Create a new LLM request
Sourcepub fn with_params(self, params: GenerationParams) -> Self
pub fn with_params(self, params: GenerationParams) -> Self
Set generation parameters
Sourcepub fn with_streaming(self, stream: bool) -> Self
pub fn with_streaming(self, stream: bool) -> Self
Enable streaming
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Set timeout
Sourcepub fn with_metadata(self, key: String, value: Value) -> Self
pub fn with_metadata(self, key: String, value: Value) -> Self
Add metadata
Sourcepub fn get_user_message(&self) -> Option<&str>
pub fn get_user_message(&self) -> Option<&str>
Get the first user message
Sourcepub fn message_count(&self) -> usize
pub fn message_count(&self) -> usize
Count total messages
Trait Implementations§
Source§impl Clone for LLMRequest
impl Clone for LLMRequest
Source§fn clone(&self) -> LLMRequest
fn clone(&self) -> LLMRequest
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 moreSource§impl Debug for LLMRequest
impl Debug for LLMRequest
Source§impl<'de> Deserialize<'de> for LLMRequest
impl<'de> Deserialize<'de> for LLMRequest
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 LLMRequest
impl RefUnwindSafe for LLMRequest
impl Send for LLMRequest
impl Sync for LLMRequest
impl Unpin for LLMRequest
impl UnwindSafe for LLMRequest
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