Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 0f34ce9

Browse files
authored
FIX: omit thinking tokens from chat (#1264)
* FIX: omit thinking tokens from chat Thinking tokens cause a lot of confusion in chat, get rid of them * also catch partial tool just in case
1 parent 274a54a commit 0f34ce9

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lib/ai_bot/playground.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,9 @@ def reply_to_chat_message(message, channel, context_post_ids)
335335
in_reply_to_id = channel.direct_message_channel? ? message.id : nil
336336

337337
new_prompts =
338-
bot.reply(context) do |partial, cancel, placeholder|
338+
bot.reply(context) do |partial, cancel, placeholder, type|
339339
# no support for tools or thinking by design
340-
next if !partial.is_a?(String)
340+
next if type == :thinking || type == :tool_details || type == :partial_tool
341341
if !reply
342342
# just eat all leading spaces we can not create the message
343343
next if partial.blank?

spec/lib/modules/ai_bot/playground_spec.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,14 +397,21 @@
397397
guardian: guardian,
398398
)
399399

400+
thinking_partial =
401+
DiscourseAi::Completions::Thinking.new(
402+
message: "I should say hello",
403+
signature: "thinking-signature-123",
404+
partial: true,
405+
)
406+
400407
thinking =
401408
DiscourseAi::Completions::Thinking.new(
402409
message: "I should say hello",
403410
signature: "thinking-signature-123",
404411
partial: false,
405412
)
406413
DiscourseAi::Completions::Llm.with_prepared_responses(
407-
[[thinking, thinking, "wo", "rld", thinking]],
414+
[[thinking_partial, thinking, "wo", "rld"]],
408415
) do |_, _, _prompts|
409416
ChatSDK::Message.create(
410417
channel_id: channel.id,

0 commit comments

Comments
 (0)