use secrecy::SecretString;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DIDLlmConfig {
pub provider: String,
pub model: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub instructions: Option<String>,
}
pub struct DIDConfig {
pub api_key: SecretString,
pub api_base_url: String,
pub agent_id: String,
pub llm_config: Option<DIDLlmConfig>,
pub knowledge_id: Option<String>,
}
impl DIDConfig {
pub fn new(api_key: impl Into<String>, agent_id: impl Into<String>) -> Self {
Self {
api_key: SecretString::from(api_key.into()),
api_base_url: "https://api.d-id.com".to_string(),
agent_id: agent_id.into(),
llm_config: None,
knowledge_id: None,
}
}
pub fn with_llm_config(mut self, llm_config: DIDLlmConfig) -> Self {
self.llm_config = Some(llm_config);
self
}
pub fn with_knowledge_id(mut self, knowledge_id: impl Into<String>) -> Self {
self.knowledge_id = Some(knowledge_id.into());
self
}
pub fn with_base_url(mut self, url: impl Into<String>) -> Self {
self.api_base_url = url.into();
self
}
}
impl std::fmt::Debug for DIDConfig {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("DIDConfig")
.field("api_key", &"[REDACTED]")
.field("api_base_url", &self.api_base_url)
.field("agent_id", &self.agent_id)
.field("llm_config", &self.llm_config)
.field("knowledge_id", &self.knowledge_id)
.finish()
}
}