use secrecy::SecretString;
use crate::chat::ReasoningEffort;
use super::{backend::LLMBackend, state::BuilderState};
pub struct LLMBuilder {
pub(super) state: BuilderState,
}
impl Default for LLMBuilder {
fn default() -> Self {
Self {
state: BuilderState::new(),
}
}
}
impl LLMBuilder {
pub fn new() -> Self {
Self::default()
}
pub fn backend(mut self, backend: LLMBackend) -> Self {
self.state.backend = Some(backend);
self
}
pub fn api_key(mut self, key: impl Into<String>) -> Self {
self.state.api_key = Some(SecretString::new(key.into()));
self
}
pub fn base_url(mut self, url: impl Into<String>) -> Self {
self.state.base_url = Some(url.into());
self
}
pub fn model(mut self, model: impl Into<String>) -> Self {
self.state.model = Some(model.into());
self
}
pub fn max_tokens(mut self, max_tokens: u32) -> Self {
self.state.max_tokens = Some(max_tokens);
self
}
pub fn temperature(mut self, temperature: f32) -> Self {
self.state.temperature = Some(temperature);
self
}
pub fn system(mut self, system: impl Into<String>) -> Self {
self.state.system = Some(system.into());
self
}
pub fn reasoning_effort(mut self, reasoning_effort: ReasoningEffort) -> Self {
self.state.reasoning_effort = Some(reasoning_effort.to_string());
self
}
pub fn reasoning(mut self, reasoning: bool) -> Self {
self.state.reasoning = Some(reasoning);
self
}
pub fn reasoning_budget_tokens(mut self, reasoning_budget_tokens: u32) -> Self {
self.state.reasoning_budget_tokens = Some(reasoning_budget_tokens);
self
}
pub fn timeout_seconds(mut self, timeout_seconds: u64) -> Self {
self.state.timeout_seconds = Some(timeout_seconds);
self
}
pub fn stream(self, _stream: bool) -> Self {
self
}
pub fn normalize_response(mut self, normalize_response: bool) -> Self {
self.state.normalize_response = Some(normalize_response);
self
}
pub fn top_p(mut self, top_p: f32) -> Self {
self.state.top_p = Some(top_p);
self
}
pub fn top_k(mut self, top_k: u32) -> Self {
self.state.top_k = Some(top_k);
self
}
}