mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-23 00:46:42 +08:00
Go: disable thinking for search ask summary to fix truncated AI summary (#17155)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user