feat: Phase 5.1 - Client 扩展,添加 orchestrator 依赖

- 扩展 Client 结构体,添加 sessionManager、orchestrator、cancelFuncs 字段
- 创建 WSClient 适配器实现 orchestrator.Sender 接口
- 更新 ServeWS 函数签名,接收 orchestrator 参数
- 在 main.go 中初始化 AI 服务和 Orchestrator
This commit is contained in:
hhs
2026-06-13 16:13:22 +08:00
parent 8e43fb134e
commit 19535e6a37
2 changed files with 66 additions and 8 deletions

View File

@@ -10,8 +10,12 @@ import (
"github.com/gin-gonic/gin"
"github.com/hhs/camtalk/internal/ai/llm"
"github.com/hhs/camtalk/internal/ai/stt"
"github.com/hhs/camtalk/internal/ai/tts"
"github.com/hhs/camtalk/internal/config"
"github.com/hhs/camtalk/internal/logger"
"github.com/hhs/camtalk/internal/orchestrator"
"github.com/hhs/camtalk/internal/session"
"github.com/hhs/camtalk/internal/ws"
)
@@ -40,6 +44,14 @@ func main() {
sessionMgr = session.NewMemoryManager(30*time.Minute, 20)
defer sessionMgr.(*session.MemoryManager).Stop()
// 初始化 AI 服务
sttService := stt.NewDeepgramService(cfg.AI.STT.APIKey, cfg.AI.STT.Endpoint, logger.Log)
llmService := llm.NewOpenAIService(cfg.AI.LLM.APIKey, cfg.AI.LLM.Model, cfg.AI.LLM.Endpoint, cfg.AI.LLM.Timeout, logger.Log)
ttsService := tts.NewOpenAIService(cfg.AI.TTS.APIKey, cfg.AI.TTS.Voice, cfg.AI.TTS.Endpoint, cfg.AI.TTS.Speed, cfg.AI.TTS.Timeout, logger.Log)
// 初始化 Orchestrator
orch := orchestrator.New(sttService, llmService, ttsService, sessionMgr)
// Gin 模式
if cfg.App.Env == "prod" {
gin.SetMode(gin.ReleaseMode)
@@ -55,7 +67,7 @@ func main() {
}
// WebSocket
r.GET("/ws", ws.ServeWS(sessionMgr))
r.GET("/ws", ws.ServeWS(sessionMgr, orch))
// HTTP Server
srv := &http.Server{