feat: 配置控制面 + LLM Pool 接第三方在线 API (OpenAI 兼容)
后端从占位回显变为真实生成:管理员经控制面登记/激活模型,Gateway 经 NATS 下发,Dispatcher 热更新 LLM Pool,Eino 图用 OpenAI 兼容流式真实推理。 - shared: contract.ModelConfig(provider/base_url/api_key/model) + 配置 subjects; bus.RequestModelConfig/ServeModelConfig/Publish/Subscribe ModelConfigUpdated - gateway: store.LLMModel→sundynix_model(AutoMigrate,唯一激活) + admin REST (GET/POST/active/delete/test models, api_key 脱敏) + main ServeModelConfig + 变更广播; 路由 /api/v1/admin/models* - dispatcher: llm.Pool OpenAI 兼容 SSE 流式客户端(ChatStream) + 热更新配置 + 未配置则降级桩; poolModel.Ready()?真实流式:注入记忆的桩; main 取配置+订阅 - 开发期接在线 API 不拉本地模型(见 llm-provider-strategy memory) - 验证: 4 模块 build✓ + e2e PASS; mock OpenAI 服务 live 跑通——登记/测试连接✓/ 激活→NATS 热更新→提交→真实 SSE 流出 mock 回复, mock 日志证明端点被调用且 注入画像(老王)进了模型上下文 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/sundynix/sundynix-dispatcher/internal/eino"
|
||||
"github.com/sundynix/sundynix-dispatcher/internal/harness"
|
||||
@@ -23,6 +24,18 @@ func main() {
|
||||
sub := dnats.MustConnect(natsURL)
|
||||
defer sub.Close()
|
||||
|
||||
// 配置控制面:启动时取激活模型配置,并订阅热更新。
|
||||
cctx, ccancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
if cfg, _ := sub.RequestModelConfig(cctx); cfg != nil {
|
||||
pool.SetConfig(cfg)
|
||||
} else {
|
||||
log.Println("[dispatcher] 未取到在线模型配置,降级桩运行(控制台配置后将热更新)")
|
||||
}
|
||||
ccancel()
|
||||
if _, err := sub.SubscribeModelConfigUpdated(pool.SetConfig); err != nil {
|
||||
log.Printf("[dispatcher] subscribe model config: %v", err)
|
||||
}
|
||||
|
||||
// sub 同时作为 Token 回流出口(TokenSink)与 MCP 工具调用出口(ToolCaller)。
|
||||
orch, err := eino.NewOrchestrator(pool, breaker, sub, sub)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user