feat: optimize WebUI stream output and sanitize user-facing answers

This commit is contained in:
2026-03-13 13:14:37 +08:00
parent 8dc5354fa4
commit 33c357a1de
8 changed files with 228 additions and 45 deletions

View File

@@ -0,0 +1,24 @@
package llm
import "testing"
func TestShouldDisableThinkingParam(t *testing.T) {
if !shouldDisableThinkingParam("https://dashscope.aliyuncs.com/compatible-mode/v1") {
t.Fatal("expected DashScope base URL to require enable_thinking=false")
}
if shouldDisableThinkingParam("https://api.openai.com/v1") {
t.Fatal("expected standard OpenAI base URL not to require enable_thinking=false")
}
}
func TestChatCompletionRequestOptions(t *testing.T) {
client := &OpenAICompatibleClient{disableThinkingParam: true}
if got := len(client.chatCompletionRequestOptions()); got != 1 {
t.Fatalf("expected 1 request option when disableThinkingParam=true, got %d", got)
}
client.disableThinkingParam = false
if got := len(client.chatCompletionRequestOptions()); got != 0 {
t.Fatalf("expected 0 request options when disableThinkingParam=false, got %d", got)
}
}