From 1d72a6afa67650d496e0dde4e229ba9a92de893e Mon Sep 17 00:00:00 2001 From: BeaconCat Date: Tue, 14 Apr 2026 20:29:39 +0800 Subject: [PATCH] feat: --no-thinking adapts to llama.cpp, Ollama, and GLM backends Send all three disable-thinking fields simultaneously: - chat_template_kwargs.enable_thinking=false (llama.cpp, GLM) - think=false (Ollama 0.9+) - thinking.type=disabled (GLM/Zhipu) Each backend picks the field it recognizes and ignores the rest. Also bumps max_tokens from 512 to 2048 for thinking models. --- cmd/membench/llm_client.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cmd/membench/llm_client.go b/cmd/membench/llm_client.go index f84173192..2cccd95b7 100644 --- a/cmd/membench/llm_client.go +++ b/cmd/membench/llm_client.go @@ -58,7 +58,9 @@ type chatRequest struct { Messages []chatMessage `json:"messages"` Temperature float64 `json:"temperature"` MaxTokens int `json:"max_tokens"` - ChatTemplateKwargs map[string]any `json:"chat_template_kwargs,omitempty"` + ChatTemplateKwargs map[string]any `json:"chat_template_kwargs,omitempty"` // llama.cpp + Think *bool `json:"think,omitempty"` // Ollama + Thinking map[string]any `json:"thinking,omitempty"` // GLM (智谱) } type chatMessage struct { @@ -86,12 +88,20 @@ func (c *LLMClient) Complete(ctx context.Context, systemPrompt, userPrompt strin Model: c.Model, Messages: messages, Temperature: 0.1, - MaxTokens: 512, + MaxTokens: 2048, } if c.NoThinking { + // llama.cpp: chat_template_kwargs body.ChatTemplateKwargs = map[string]any{ "enable_thinking": false, } + // Ollama (0.9+): think field + thinkFalse := false + body.Think = &thinkFalse + // GLM (智谱): thinking field + body.Thinking = map[string]any{ + "type": "disabled", + } } jsonBody, err := json.Marshal(body)