Go: disable thinking for search ask summary to fix truncated AI summary (#17155)

This commit is contained in:
euvre
2026-07-21 14:54:14 +08:00
committed by GitHub
parent f7a5629487
commit 87417d083e
2 changed files with 22 additions and 8 deletions

View File

@@ -124,10 +124,14 @@ func (o *OpenAIModel) ChatWithMessages(modelName string, messages []Message, api
}
}
// Qwen3 family: disable thinking by default (matches Python's
// _apply_model_family_policies in rag/llm/chat_model.py:119-121).
if strings.Contains(strings.ToLower(modelName), "qwen3") && (chatModelConfig == nil || chatModelConfig.Thinking == nil) {
reqBody["enable_thinking"] = false
// Qwen3 family: disable thinking unless explicitly enabled (matches
// Python's _apply_model_family_policies in rag/llm/chat_model.py:119-121).
if strings.Contains(strings.ToLower(modelName), "qwen3") {
if chatModelConfig != nil && chatModelConfig.Thinking != nil {
reqBody["enable_thinking"] = *chatModelConfig.Thinking
} else {
reqBody["enable_thinking"] = false
}
}
jsonData, err := json.Marshal(reqBody)
@@ -302,9 +306,13 @@ func (o *OpenAIModel) ChatStreamlyWithSender(modelName string, messages []Messag
}
}
// Qwen3 family: disable thinking by default.
if strings.Contains(strings.ToLower(modelName), "qwen3") && (chatModelConfig == nil || chatModelConfig.Thinking == nil) {
reqBody["enable_thinking"] = false
// Qwen3 family: disable thinking unless explicitly enabled.
if strings.Contains(strings.ToLower(modelName), "qwen3") {
if chatModelConfig != nil && chatModelConfig.Thinking != nil {
reqBody["enable_thinking"] = *chatModelConfig.Thinking
} else {
reqBody["enable_thinking"] = false
}
}
jsonData, err := json.Marshal(reqBody)

View File

@@ -186,7 +186,12 @@ func (s *AskService) run(ctx context.Context, llm StreamingLLM, userID, question
{Role: "system", Content: sysPrompt},
{Role: "user", Content: question},
}
genConf := &modelModule.ChatConfig{Temperature: ptrFloat64(0.1)}
// Thinking is disabled: summarization does not need reasoning. With
// thinking enabled, the reasoning (which drafts the summary) streams
// first, then collapses into a hidden think block, and the provider may
// emit only a fragment as the visible answer once the reasoning has
// consumed the output budget.
genConf := &modelModule.ChatConfig{Temperature: ptrFloat64(0.1), Thinking: ptrBool(false)}
ch, err := llm.ChatStream(ctx, messages, genConf)
if err != nil {
@@ -279,3 +284,4 @@ func toFloat64Slice(v interface{}) []float64 {
func ptrInt(v int) *int { return &v }
func ptrFloat64(v float64) *float64 { return &v }
func ptrBool(v bool) *bool { return &v }