mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-16 00:52:40 +00:00
Strip Qwen 3.5 thinking tags from Ollama responses
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -218,5 +218,13 @@ func callOllama(host, model, prompt string) (string, error) {
|
|||||||
return "", fmt.Errorf("parse response: %w", err)
|
return "", fmt.Errorf("parse response: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.TrimSpace(result.Response), nil
|
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>"):]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.TrimSpace(response), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -548,6 +548,14 @@ Message: %s`, messageText)
|
|||||||
func parseClassification(raw string) (*classificationResult, error) {
|
func parseClassification(raw string) (*classificationResult, error) {
|
||||||
cleaned := raw
|
cleaned := raw
|
||||||
|
|
||||||
|
// Remove <think>...</think> blocks (Qwen 3.5 reasoning)
|
||||||
|
if i := strings.Index(cleaned, "<think>"); i != -1 {
|
||||||
|
if j := strings.Index(cleaned, "</think>"); j != -1 {
|
||||||
|
cleaned = cleaned[:i] + cleaned[j+len("</think>"):]
|
||||||
|
cleaned = strings.TrimSpace(cleaned)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove markdown code fences
|
// Remove markdown code fences
|
||||||
cleaned = strings.TrimSpace(cleaned)
|
cleaned = strings.TrimSpace(cleaned)
|
||||||
if strings.HasPrefix(cleaned, "```json") {
|
if strings.HasPrefix(cleaned, "```json") {
|
||||||
|
|||||||
@@ -347,7 +347,14 @@ Respond with ONLY "yes" or "no".`, message, word)
|
|||||||
return false
|
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")
|
accepted := strings.HasPrefix(answer, "yes")
|
||||||
slog.Debug("wotd: LLM verification", "word", word, "answer", answer, "accepted", accepted)
|
slog.Debug("wotd: LLM verification", "word", word, "answer", answer, "accepted", accepted)
|
||||||
return accepted
|
return accepted
|
||||||
|
|||||||
Reference in New Issue
Block a user