mirror of
https://github.com/zebrajr/ollama.git
synced 2025-12-06 12:19:56 +01:00
Merge pull request #12021 from ollama/drifkin/thinking-double-emit
thinking: fix double emit when no opening tag
This commit is contained in:
commit
e3d5708754
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user