Skip to content

Commit db2a8a3

Browse files
committed
Handle bizarre deepseek-r1 stranded </think> tag
1 parent ecd61f0 commit db2a8a3

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [0.0.10] - 2025-07-06
2+
3+
- Handle bizarre deepseek-r1 stranded </think> tag
4+
15
## [0.0.9] - 2025-06-28
26

37
- Use temperature and replace Ask with GenerateNextMessage

Gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
foobara-llm-backed-command (0.0.9)
4+
foobara-llm-backed-command (0.0.10)
55
foobara (~> 0.0.132)
66
foobara-ai (~> 0.0.1)
77
foobara-json-schema-generator (~> 0.0.6)
@@ -63,7 +63,7 @@ GEM
6363
foobara-lru-cache (~> 0.0.2)
6464
foobara-util (>= 1.0.0)
6565
inheritable-thread-vars (~> 0.0.1)
66-
foobara-ai (0.0.13)
66+
foobara-ai (0.0.14)
6767
foobara-anthropic-api (0.0.11)
6868
foobara-cached-command
6969
foobara-http-api-command
@@ -200,7 +200,7 @@ GEM
200200
rb-fsevent (0.11.2)
201201
rb-inotify (0.11.1)
202202
ffi (~> 1.0)
203-
rdoc (6.14.1)
203+
rdoc (6.14.2)
204204
erb
205205
psych (>= 4.0.0)
206206
regexp_parser (2.10.0)

src/llm_backed_execute_method.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ def llm_instructions
106106

107107
def parse_answer
108108
stripped_answer = answer.gsub(/<THINK>.*?<\/THINK>/mi, "")
109+
# For some reason sometimes deepseek-r1:32b starts the answer with "\n\n</think>\n\n"
110+
# so removing it as a special case
111+
stripped_answer = stripped_answer.gsub(/\A\s*<\/think>\s*/mi, "")
109112
fencepostless_answer = stripped_answer.gsub(/^\s*```\w*\n(.*)```\s*\z/m, "\\1")
110113

111114
# TODO: should we verify against json-schema or no?

version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Foobara
22
module LlmBackedCommandVersion
3-
VERSION = "0.0.9".freeze
3+
VERSION = "0.0.10".freeze
44
MINIMUM_RUBY_VERSION = ">= 3.4.0".freeze
55
end
66
end

0 commit comments

Comments
 (0)