feat: 更新配置文档

This commit is contained in:
hhs
2026-06-13 19:57:35 +08:00
parent f764b3a7d8
commit 0d9d3db73b
12 changed files with 83 additions and 34 deletions

View File

@@ -22,6 +22,7 @@ type Pipeline struct {
llmService llm.Service
ttsService tts.Service
sessionMgr session.Manager
model string // LLM 模型名,用于 llm_done 上报
}
// New 创建 Pipeline 实例。
@@ -30,12 +31,14 @@ func New(
llmService llm.Service,
ttsService tts.Service,
sessionMgr session.Manager,
model string,
) *Pipeline {
return &Pipeline{
sttService: sttService,
llmService: llmService,
ttsService: ttsService,
sessionMgr: sessionMgr,
model: model,
}
}
@@ -206,7 +209,7 @@ func (p *Pipeline) ProcessQuery(
Type: "llm_done",
RequestID: req.RequestID,
FullText: fullText,
Model: "gpt-4o",
Model: p.model,
LatencyMs: latency,
}); err != nil {
log.Errorw("发送 llm_done 失败", "error", err)

View File

@@ -254,7 +254,7 @@ func TestProcessQuery_Success(t *testing.T) {
mockSender.On("SendTTSAudio", mock.Anything).Return(nil)
// 创建 Pipeline
pipeline := New(mockSTT, mockLLM, mockTTS, mockSession)
pipeline := New(mockSTT, mockLLM, mockTTS, mockSession, "gpt-4o")
// 执行
ctx := context.Background()
@@ -305,7 +305,7 @@ func TestProcessQuery_STTError(t *testing.T) {
mockSender.On("SendError", mock.Anything).Return(nil)
pipeline := New(mockSTT, mockLLM, mockTTS, mockSession)
pipeline := New(mockSTT, mockLLM, mockTTS, mockSession, "gpt-4o")
ctx := context.Background()
err := pipeline.ProcessQuery(ctx, "session-123", req, nil, mockSender)
@@ -357,7 +357,7 @@ func TestProcessQuery_LLMError(t *testing.T) {
mockSender.On("SendError", mock.Anything).Return(nil)
pipeline := New(mockSTT, mockLLM, mockTTS, mockSession)
pipeline := New(mockSTT, mockLLM, mockTTS, mockSession, "gpt-4o")
ctx := context.Background()
err := pipeline.ProcessQuery(ctx, "session-123", req, nil, mockSender)
@@ -415,7 +415,7 @@ func TestProcessQuery_TTSError(t *testing.T) {
mockTTS.On("SynthesizeStream", mock.Anything, mock.Anything, mock.Anything).
Return(nil, errors.New("TTS service unavailable"))
pipeline := New(mockSTT, mockLLM, mockTTS, mockSession)
pipeline := New(mockSTT, mockLLM, mockTTS, mockSession, "gpt-4o")
ctx := context.Background()
err := pipeline.ProcessQuery(ctx, "session-123", req, nil, mockSender)
@@ -485,7 +485,7 @@ func TestProcessQuery_ContextCancelled(t *testing.T) {
}()
mockTTS.On("SynthesizeStream", mock.Anything, mock.Anything, mock.Anything).Return((<-chan tts.Chunk)(ttsCh), nil)
pipeline := New(mockSTT, mockLLM, mockTTS, mockSession)
pipeline := New(mockSTT, mockLLM, mockTTS, mockSession, "gpt-4o")
// 创建可取消的上下文
ctx, cancel := context.WithCancel(context.Background())
@@ -545,7 +545,7 @@ func TestProcessQuery_DisabledTTS(t *testing.T) {
mockSender.On("SendLLMChunk", mock.Anything).Return(nil)
mockSender.On("SendLLMDone", mock.Anything).Return(nil)
pipeline := New(mockSTT, mockLLM, mockTTS, mockSession)
pipeline := New(mockSTT, mockLLM, mockTTS, mockSession, "gpt-4o")
ctx := context.Background()
err := pipeline.ProcessQuery(ctx, "session-123", req, nil, mockSender)
@@ -617,7 +617,7 @@ func TestProcessQuery_InvalidAudio(t *testing.T) {
mockSender.On("SendError", mock.Anything).Return(nil)
pipeline := New(mockSTT, mockLLM, mockTTS, mockSession)
pipeline := New(mockSTT, mockLLM, mockTTS, mockSession, "gpt-4o")
ctx := context.Background()
err := pipeline.ProcessQuery(ctx, "session-123", req, nil, mockSender)
@@ -650,7 +650,7 @@ func TestProcessQuery_SessionNotFound(t *testing.T) {
mockSender.On("SendError", mock.Anything).Return(nil)
pipeline := New(mockSTT, mockLLM, mockTTS, mockSession)
pipeline := New(mockSTT, mockLLM, mockTTS, mockSession, "gpt-4o")
ctx := context.Background()
err := pipeline.ProcessQuery(ctx, "session-123", req, nil, mockSender)