mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-06-25 17:12:16 +00:00
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
This commit is contained in:
parent
274a54a324
commit
0f34ce999f
@ -335,9 +335,9 @@ module DiscourseAi
|
|||||||
in_reply_to_id = channel.direct_message_channel? ? message.id : nil
|
in_reply_to_id = channel.direct_message_channel? ? message.id : nil
|
||||||
|
|
||||||
new_prompts =
|
new_prompts =
|
||||||
bot.reply(context) do |partial, cancel, placeholder|
|
bot.reply(context) do |partial, cancel, placeholder, type|
|
||||||
# no support for tools or thinking by design
|
# no support for tools or thinking by design
|
||||||
next if !partial.is_a?(String)
|
next if type == :thinking || type == :tool_details || type == :partial_tool
|
||||||
if !reply
|
if !reply
|
||||||
# just eat all leading spaces we can not create the message
|
# just eat all leading spaces we can not create the message
|
||||||
next if partial.blank?
|
next if partial.blank?
|
||||||
|
@ -397,6 +397,13 @@ RSpec.describe DiscourseAi::AiBot::Playground do
|
|||||||
guardian: guardian,
|
guardian: guardian,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
thinking_partial =
|
||||||
|
DiscourseAi::Completions::Thinking.new(
|
||||||
|
message: "I should say hello",
|
||||||
|
signature: "thinking-signature-123",
|
||||||
|
partial: true,
|
||||||
|
)
|
||||||
|
|
||||||
thinking =
|
thinking =
|
||||||
DiscourseAi::Completions::Thinking.new(
|
DiscourseAi::Completions::Thinking.new(
|
||||||
message: "I should say hello",
|
message: "I should say hello",
|
||||||
@ -404,7 +411,7 @@ RSpec.describe DiscourseAi::AiBot::Playground do
|
|||||||
partial: false,
|
partial: false,
|
||||||
)
|
)
|
||||||
DiscourseAi::Completions::Llm.with_prepared_responses(
|
DiscourseAi::Completions::Llm.with_prepared_responses(
|
||||||
[[thinking, thinking, "wo", "rld", thinking]],
|
[[thinking_partial, thinking, "wo", "rld"]],
|
||||||
) do |_, _, _prompts|
|
) do |_, _, _prompts|
|
||||||
ChatSDK::Message.create(
|
ChatSDK::Message.create(
|
||||||
channel_id: channel.id,
|
channel_id: channel.id,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user