Files
baibot-withmcp/src/agent/provider/anthropic/mod.rs

44 lines
1.1 KiB
Rust
Raw Normal View History

2024-09-12 13:44:06 +03:00
mod config;
mod controller;
mod utils;
pub use config::Config;
pub use controller::Controller;
use super::super::AgentInstantiationError;
use super::super::AgentInstantiationResult;
use super::ConfigTrait;
2025-02-27 07:46:16 +02:00
use super::controller::ControllerType;
2024-09-12 13:44:06 +03:00
pub fn create_controller_from_yaml_value_config(
agent_id: &str,
config: serde_yaml_ng::Value,
2024-09-12 13:44:06 +03:00
) -> AgentInstantiationResult<ControllerType> {
let config = match &config {
serde_yaml_ng::Value::Mapping(_) => {
2024-09-12 13:44:06 +03:00
let config: Config =
serde_yaml_ng::from_value(config).map_err(AgentInstantiationError::Yaml)?;
2024-09-12 13:44:06 +03:00
config
.validate()
.map_err(AgentInstantiationError::ConfigFailsValidation)?;
config
}
_ => {
return Err(AgentInstantiationError::ConfigForAgentIsNotAMapping(
agent_id.to_owned(),
));
}
};
let controller =
Controller::new(config).map_err(AgentInstantiationError::ConstructionFailed)?;
Ok(ControllerType::Anthropic(Box::new(controller)))
}
pub fn default_config() -> Config {
Config::default()
}