Strip Qwen 3.5 thinking tags from Ollama responses

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
prosolis
2026-03-14 12:17:36 -07:00
parent 4b53af776b
commit c00214e408
3 changed files with 25 additions and 2 deletions

View File

@@ -347,7 +347,14 @@ Respond with ONLY "yes" or "no".`, message, word)
return false
}
answer := strings.ToLower(strings.TrimSpace(result.Response))
response := result.Response
// Strip <think>...</think> blocks (Qwen 3.5 reasoning)
if i := strings.Index(response, "<think>"); i != -1 {
if j := strings.Index(response, "</think>"); j != -1 {
response = response[:i] + response[j+len("</think>"):]
}
}
answer := strings.ToLower(strings.TrimSpace(response))
accepted := strings.HasPrefix(answer, "yes")
slog.Debug("wotd: LLM verification", "word", word, "answer", answer, "accepted", accepted)
return accepted