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.
This commit is contained in:
parent
bc64d9e708
commit
1d72a6afa6
1 changed files with 12 additions and 2 deletions
|
|
@ -58,7 +58,9 @@ type chatRequest struct {
|
||||||
Messages []chatMessage `json:"messages"`
|
Messages []chatMessage `json:"messages"`
|
||||||
Temperature float64 `json:"temperature"`
|
Temperature float64 `json:"temperature"`
|
||||||
MaxTokens int `json:"max_tokens"`
|
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 {
|
type chatMessage struct {
|
||||||
|
|
@ -86,12 +88,20 @@ func (c *LLMClient) Complete(ctx context.Context, systemPrompt, userPrompt strin
|
||||||
Model: c.Model,
|
Model: c.Model,
|
||||||
Messages: messages,
|
Messages: messages,
|
||||||
Temperature: 0.1,
|
Temperature: 0.1,
|
||||||
MaxTokens: 512,
|
MaxTokens: 2048,
|
||||||
}
|
}
|
||||||
if c.NoThinking {
|
if c.NoThinking {
|
||||||
|
// llama.cpp: chat_template_kwargs
|
||||||
body.ChatTemplateKwargs = map[string]any{
|
body.ChatTemplateKwargs = map[string]any{
|
||||||
"enable_thinking": false,
|
"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)
|
jsonBody, err := json.Marshal(body)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue