配置 API

读取与更新运行时配置的 API:供应商、模型、通道与功能开关。

读取配置

Get All Config

GET /api/config
Response: { "success": true, "config": { "llm": {...}, "agent": {...}, "channels": {...} } }

Get Section

GET /api/config/{section}

section 可选值:llm / agent / channels / memory / logging / security / server / routes

Update Section

PUT /api/config/{section}
Body: { "value": { ... } }
Response: { "success": true }

Validate Config

GET /api/config/validate
Response: { "success": true, "valid": true, "errors": [] }

Config Status

GET /api/config/status
Response: { "success": true, "sections": { "llm": "loaded", "agent": "loaded" } }

重载配置

Reload All

POST /api/config/reload
Response: { "success": true, "message": "配置已重新加载" }

Reload Section

POST /api/config/reload/{section}
Response: { "success": true, "section": "llm" }

Toggle Auto Reload

POST /api/config/auto-reload?enabled=true
Response: { "success": true, "enabled": true }

模型

Switch Model

POST /api/config/model/switch
Content-Type: application/json

{
  "name": "main",
  "provider": "openai",
  "base_url": "https://api.openai.com/v1",
  "model": "gpt-4o",
  "api_key": "sk-...",
  "temperature": 0.7,
  "timeout": 120
}

Response: { "success": true, "model": "gpt-4o" }

Reload LLM Engine

POST /api/config/model/reload-engine
Response: { "success": true }

List Local Models

POST /api/config/model/list-local
Body: { "base_url": "http://localhost:11434/v1" }
Response: { "success": true, "models": [ "qwen2.5:7b", "llama3.1:8b" ] }

供应商

List Providers

GET /api/config/providers
Response: { "success": true, "providers": [ { "id": "openai", "name": "OpenAI" } ] }

Fetch Provider Models

POST /api/config/provider/models
Body: { "provider_id": "openai", "api_key": "sk-..." }
Response: { "success": true, "models": [ "gpt-4o", "gpt-4o-mini" ] }