use lellm_core::ChatRequest;
#[derive(Debug, Clone, Default)]
pub struct RequestOptions {
pub temperature: Option<f64>,
pub top_p: Option<f64>,
pub seed: Option<u64>,
pub tool_choice: Option<lellm_core::ToolChoice>,
pub stop_sequences: Option<Vec<String>>,
pub prefill: Option<String>,
pub reasoning: Option<lellm_core::ReasoningConfig>,
pub max_reasoning_tokens: Option<u32>,
pub extra: Option<serde_json::Map<String, serde_json::Value>>,
}
impl RequestOptions {
pub fn new() -> Self {
Self::default()
}
pub fn apply(&self, req: &mut ChatRequest) {
if self.temperature.is_some() {
req.temperature = self.temperature;
}
if self.top_p.is_some() {
req.top_p = self.top_p;
}
if self.seed.is_some() {
req.seed = self.seed;
}
if self.tool_choice.is_some() {
req.tool_choice = self.tool_choice.clone();
}
if self.stop_sequences.is_some() {
req.stop_sequences = self.stop_sequences.clone();
}
if self.prefill.is_some() {
req.prefill = self.prefill.clone();
}
if self.reasoning.is_some() {
req.reasoning = self.reasoning;
}
if self.max_reasoning_tokens.is_some() {
req.max_reasoning_tokens = self.max_reasoning_tokens;
}
if self.extra.is_some() {
req.extra = self.extra.clone();
}
}
}
impl RequestOptions {
pub fn temperature(mut self, t: f64) -> Self {
self.temperature = Some(t);
self
}
pub fn top_p(mut self, p: f64) -> Self {
self.top_p = Some(p);
self
}
pub fn seed(mut self, s: u64) -> Self {
self.seed = Some(s);
self
}
pub fn tool_choice(mut self, choice: lellm_core::ToolChoice) -> Self {
self.tool_choice = Some(choice);
self
}
pub fn stop_sequences(mut self, seqs: Vec<String>) -> Self {
self.stop_sequences = Some(seqs);
self
}
pub fn prefill(mut self, text: String) -> Self {
self.prefill = Some(text);
self
}
pub fn reasoning(mut self, r: lellm_core::ReasoningConfig) -> Self {
self.reasoning = Some(r);
self
}
pub fn max_reasoning_tokens(mut self, max: u32) -> Self {
self.max_reasoning_tokens = Some(max);
self
}
pub fn extra(mut self, extra: serde_json::Map<String, serde_json::Value>) -> Self {
self.extra = Some(extra);
self
}
}