feat: Agent 服务日志功能和后端更新
- agent/main.py: 添加日志记录功能 - agent/llm: 更新 anthropic, openai, factory - agent/core/agent.py: 更新 - server: agent_handler, agent_service, chat_service 更新 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
LLM Factory - LLM 工厂类
|
||||
"""
|
||||
from typing import Dict, Any
|
||||
from typing import Optional
|
||||
from app.agent.llm.openai import OpenAILLM
|
||||
from app.agent.llm.anthropic import AnthropicLLM
|
||||
|
||||
@@ -10,21 +10,23 @@ class LLMFactory:
|
||||
"""LLM 工厂类"""
|
||||
|
||||
@staticmethod
|
||||
def create(provider: str, model_name: str):
|
||||
def create(provider: str, model_name: str, api_key: Optional[str] = None, base_url: Optional[str] = None):
|
||||
"""
|
||||
创建 LLM 实例
|
||||
|
||||
Args:
|
||||
provider: 模型提供商 (openai/anthropic)
|
||||
model_name: 模型名称
|
||||
api_key: API Key(可选)
|
||||
base_url: Base URL(可选)
|
||||
|
||||
Returns:
|
||||
LLM 实例
|
||||
"""
|
||||
if provider.lower() == "openai":
|
||||
return OpenAILLM(model_name)
|
||||
return OpenAILLM(model_name, api_key, base_url)
|
||||
elif provider.lower() == "anthropic":
|
||||
return AnthropicLLM(model_name)
|
||||
return AnthropicLLM(model_name, api_key)
|
||||
else:
|
||||
# 默认使用 OpenAI
|
||||
return OpenAILLM(model_name)
|
||||
return OpenAILLM(model_name, api_key, base_url)
|
||||
|
||||
Reference in New Issue
Block a user