Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/ai_bot/chat_streamer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def initialize(message:, channel:, guardian:, thread_id:, in_reply_to_id:, force

def <<(partial)
return if partial.to_s.empty?
# we throw away leading spaces prior to message creation for now
# by design
return if partial.to_s.blank? && !@reply

if @client_id
ChatSDK::Channel.stop_reply(
Expand Down
5 changes: 4 additions & 1 deletion spec/lib/modules/ai_bot/playground_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@
)

prompts = nil
DiscourseAi::Completions::Llm.with_prepared_responses(["world"]) do |_, _, _prompts|
DiscourseAi::Completions::Llm.with_prepared_responses([[" ", "world"]]) do |_, _, _prompts|
message =
ChatSDK::Message.create(
channel_id: channel.id,
Expand Down Expand Up @@ -386,6 +386,9 @@
TEXT

expect(content.strip).to eq(expected)

reply = Chat::Message.order(:id).last
expect(reply.message).to eq("world")
end

it "should reply to a mention if properly enabled" do
Expand Down