diff --git a/crates/erp-ai/src/error.rs b/crates/erp-ai/src/error.rs index 018c666..cf42f38 100644 --- a/crates/erp-ai/src/error.rs +++ b/crates/erp-ai/src/error.rs @@ -49,6 +49,9 @@ pub enum AiError { #[error("AI 配置错误: {0}")] ConfigError(String), + + #[error("不支持的操作: {0}")] + UnsupportedOperation(String), } impl From for AppError { diff --git a/crates/erp-ai/src/provider/mod.rs b/crates/erp-ai/src/provider/mod.rs index 5388dcc..3d4b431 100644 --- a/crates/erp-ai/src/provider/mod.rs +++ b/crates/erp-ai/src/provider/mod.rs @@ -27,4 +27,20 @@ pub trait AiProvider: Send + Sync { /// 健康检查 async fn health_check(&self) -> AiResult; + + /// Agent 专用生成方法 — 支持 Function Calling + /// 不支持 FC 的 Provider 使用默认实现(返回错误) + async fn generate_with_tools( + &self, + _messages: Vec, + _tools: Vec, + _system_prompt: &str, + _model: &str, + _temperature: f32, + _max_tokens: u32, + ) -> AiResult { + Err(crate::error::AiError::UnsupportedOperation( + "Function Calling not supported by this provider".into(), + )) + } }