use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
use std::collections::HashMap;
use std::time::Duration;
#[skip_serializing_none]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ModelOptions<T> {
pub model: String,
pub system: Option<String>,
pub reasoning: Option<bool>,
pub temperature: Option<f32>,
pub top_p: Option<f32>,
pub max_tokens: Option<u32>,
pub provider: T,
}
impl<T: Default> ModelOptions<T> {
pub fn new(model: impl Into<String>) -> Self {
Self {
model: model.into(),
system: None,
reasoning: None,
temperature: None,
top_p: None,
max_tokens: None,
provider: T::default(),
}
}
}
#[derive(Debug, Clone)]
pub enum TransportOptions {
Http {
timeout: Option<Duration>,
proxy: Option<String>,
headers: Option<HashMap<String, String>>,
},
}
impl Default for TransportOptions {
fn default() -> Self {
TransportOptions::Http {
timeout: None,
proxy: None,
headers: None,
}
}
}
impl TransportOptions {
pub fn new() -> Self {
Self::default()
}
pub fn with_timeout(mut self, duration: Duration) -> Self {
match &mut self {
TransportOptions::Http { timeout, .. } => *timeout = Some(duration),
}
self
}
pub fn with_proxy(mut self, proxy_url: String) -> Self {
match &mut self {
TransportOptions::Http { proxy, .. } => *proxy = Some(proxy_url),
}
self
}
pub fn with_header(mut self, key: String, value: String) -> Self {
match &mut self {
TransportOptions::Http { headers, .. } => {
headers.get_or_insert_with(HashMap::new).insert(key, value);
}
}
self
}
}