use crate::{Hippox, HippoxConfig, IdentityInformation, WorkflowMode};
use langhub::types::ModelProvider;
use std::collections::HashMap;
pub struct HippoxBuilder {
provider: ModelProvider,
api_key: Option<String>,
extra_keys: Option<HashMap<String, String>>,
config: HippoxConfig,
}
impl HippoxBuilder {
pub fn new(provider: ModelProvider) -> Self {
Self { provider, api_key: None, extra_keys: None, config: HippoxConfig::default() }
}
pub fn api_key(mut self, key: impl Into<String>) -> Self {
self.api_key = Some(key.into());
self
}
pub fn extra_keys(mut self, keys: HashMap<String, String>) -> Self {
self.extra_keys = Some(keys);
self
}
pub fn lang(mut self, lang: impl Into<String>) -> Self {
self.config.lang = lang.into();
self
}
pub fn identity(mut self, f: impl FnOnce(&mut IdentityInformation)) -> Self {
f(&mut self.config.identity_information);
self
}
pub async fn build(self) -> anyhow::Result<Hippox> {
Hippox::with_workflow_mode(self.provider, self.api_key, self.extra_keys, Some(self.config)).await
}
}
impl Hippox {
pub fn builder(provider: ModelProvider) -> HippoxBuilder {
HippoxBuilder::new(provider)
}
}