Skip to content

Commit 2be0aac

Browse files
Alexey Panfilovclaude
andcommitted
fix: add no_think option to disable qwen3 thinking mode for classifier
qwen3 returns empty content when thinking mode is active, causing classifier to fail. no_think: true sends think=false in Ollama options. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7615bda commit 2be0aac

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

config/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ models:
7474
model: qwen3:0.6b
7575
base_url: http://host.docker.internal:11434
7676
max_tokens: 64
77+
no_think: true
7778

7879
# Ollama local — simple tasks via Ollama Cloud model (routed through local Ollama).
7980
ollama-local:

internal/config/config.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ type ModelConfig struct {
6969
APIKey string `yaml:"api_key"`
7070
MaxTokens int `yaml:"max_tokens"`
7171
BaseURL string `yaml:"base_url"`
72-
Vision bool `yaml:"vision"` // true if the model supports image input
72+
Vision bool `yaml:"vision"` // true if the model supports image input
73+
NoThink bool `yaml:"no_think"` // disable thinking mode (qwen3)
7374
}
7475

7576
type ModelsConfig struct {

internal/llm/ollama.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ type ollamaProvider struct {
2323
maxTokens int
2424
provName string
2525
vision bool
26+
noThink bool
2627
}
2728

2829
// NewOllama creates a provider for a local Ollama instance.
@@ -43,6 +44,7 @@ func NewOllama(cfg config.ModelConfig) (*ollamaProvider, error) {
4344
maxTokens: maxTokens,
4445
provName: "ollama",
4546
vision: cfg.Vision,
47+
noThink: cfg.NoThink,
4648
}, nil
4749
}
4850

@@ -92,7 +94,8 @@ type ollamaFunctionDef struct {
9294
}
9395

9496
type ollamaOptions struct {
95-
NumPredict int `json:"num_predict,omitempty"`
97+
NumPredict int `json:"num_predict,omitempty"`
98+
Think *bool `json:"think,omitempty"`
9699
}
97100

98101
type ollamaResponse struct {
@@ -105,11 +108,16 @@ type ollamaResponse struct {
105108
func (p *ollamaProvider) Chat(ctx context.Context, messages []Message, systemPrompt string, tools []Tool) (Response, error) {
106109
ollamaMsgs := p.buildMessages(messages, systemPrompt)
107110

111+
opts := &ollamaOptions{NumPredict: p.maxTokens}
112+
if p.noThink {
113+
f := false
114+
opts.Think = &f
115+
}
108116
req := ollamaRequest{
109117
Model: p.model,
110118
Messages: ollamaMsgs,
111119
Stream: false,
112-
Options: &ollamaOptions{NumPredict: p.maxTokens},
120+
Options: opts,
113121
}
114122
if len(tools) > 0 {
115123
req.Tools = buildOllamaTools(tools)

0 commit comments

Comments
 (0)