feat(agent-runtime): 接入多服务商安全配置
This commit is contained in:
@@ -14,6 +14,9 @@ class AgentRuntimeConfig:
|
||||
api_key: str
|
||||
model: str
|
||||
agent_name: str
|
||||
provider_code: str = "openai"
|
||||
protocol: str = "openai_responses"
|
||||
base_url: str = "https://api.openai.com/v1"
|
||||
|
||||
@classmethod
|
||||
def from_settings(cls) -> "AgentRuntimeConfig":
|
||||
@@ -36,3 +39,19 @@ class AgentRuntimeConfig:
|
||||
if missing:
|
||||
raise AgentConfigurationError(f"真实 Agent 执行缺少配置:{', '.join(missing)}。")
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def from_user(cls, user) -> "AgentRuntimeConfig":
|
||||
"""从用户已验证的服务商配置构建运行配置,供真实 Gateway 接入使用。"""
|
||||
|
||||
from .services import resolve_runtime_model_config
|
||||
|
||||
runtime = resolve_runtime_model_config(user)
|
||||
return cls(
|
||||
api_key=runtime.api_key,
|
||||
model=runtime.model,
|
||||
agent_name=str(settings.AGENT_DEFAULT_NAME or "job_research").strip(),
|
||||
provider_code=runtime.provider_code,
|
||||
protocol=runtime.protocol,
|
||||
base_url=runtime.base_url,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user