Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
e3d57087
Unverified
Commit
e3d57087
authored
Aug 22, 2025
by
Devon Rifkin
Committed by
GitHub
Aug 22, 2025
Browse files
Merge pull request #12021 from ollama/drifkin/thinking-double-emit
thinking: fix double emit when no opening tag
parents
4be4dc87
2cb0a580
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletion
+12
-1
thinking/parser.go
thinking/parser.go
+3
-1
thinking/parser_test.go
thinking/parser_test.go
+9
-0
No files found.
thinking/parser.go
View file @
e3d57087
...
...
@@ -103,7 +103,9 @@ func eat(s *Parser) (string, string, bool) {
// note that we use the original content, not the trimmed one because we
// don't want to eat any whitespace in the real content if there were no
// thinking tags
return
""
,
s
.
acc
.
String
(),
false
untrimmed
:=
s
.
acc
.
String
()
s
.
acc
.
Reset
()
return
""
,
untrimmed
,
false
}
case
thinkingState_ThinkingStartedEatingWhitespace
:
trimmed
:=
strings
.
TrimLeftFunc
(
s
.
acc
.
String
(),
unicode
.
IsSpace
)
...
...
thinking/parser_test.go
View file @
e3d57087
...
...
@@ -58,6 +58,15 @@ func TestThinkingStreaming(t *testing.T) {
wantContent
:
" abc"
,
wantStateAfter
:
thinkingState_ThinkingDone
,
},
// regression test for a bug where we were transitioning directly to
// ThinkingDone without clearing the buffer. This would cuase the first
// step to be outputted twice
{
input
:
"def"
,
wantThinking
:
""
,
wantContent
:
"def"
,
wantStateAfter
:
thinkingState_ThinkingDone
,
},
},
},
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment