mirror of
https://github.com/ollama/ollama.git
synced 2026-04-17 15:53:27 +02:00
gemma4: fix nothink case renderer (#15553)
Regressed in #15490 Fixes: #15536
This commit is contained in:
@@ -40,6 +40,7 @@ func (r *Gemma4Renderer) Render(messages []api.Message, tools []api.Tool, thinkV
|
|||||||
|
|
||||||
// Emit system turn if there's a system/developer role, tools, or thinking.
|
// Emit system turn if there's a system/developer role, tools, or thinking.
|
||||||
hasThink := thinkValue != nil && thinkValue.Bool()
|
hasThink := thinkValue != nil && thinkValue.Bool()
|
||||||
|
thinkingExplicitlyDisabled := thinkValue != nil && thinkValue.IsBool() && !thinkValue.Bool()
|
||||||
if hasSystemRole || len(tools) > 0 || hasThink {
|
if hasSystemRole || len(tools) > 0 || hasThink {
|
||||||
sb.WriteString("<|turn>system\n")
|
sb.WriteString("<|turn>system\n")
|
||||||
if hasThink {
|
if hasThink {
|
||||||
@@ -124,7 +125,7 @@ func (r *Gemma4Renderer) Render(messages []api.Message, tools []api.Tool, thinkV
|
|||||||
// Generation prompt.
|
// Generation prompt.
|
||||||
if prevMessageType != "tool_response" && prevMessageType != "tool_call" {
|
if prevMessageType != "tool_response" && prevMessageType != "tool_call" {
|
||||||
sb.WriteString("<|turn>model\n")
|
sb.WriteString("<|turn>model\n")
|
||||||
if !hasThink {
|
if !hasThink && !thinkingExplicitlyDisabled {
|
||||||
sb.WriteString("<|channel>thought\n<channel|>")
|
sb.WriteString("<|channel>thought\n<channel|>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user