mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-06-25 09:02:23 +00:00
FIX: eat all leading spaces llms provide when they stream them (#1280)
* FIX: eat all leading spaces llms provide when they stream them * improve so we don't stop replying...
This commit is contained in:
parent
2060426709
commit
65718f6dbe
@ -39,6 +39,9 @@ module DiscourseAi
|
|||||||
|
|
||||||
def <<(partial)
|
def <<(partial)
|
||||||
return if partial.to_s.empty?
|
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
|
if @client_id
|
||||||
ChatSDK::Channel.stop_reply(
|
ChatSDK::Channel.stop_reply(
|
||||||
|
@ -354,7 +354,7 @@ RSpec.describe DiscourseAi::AiBot::Playground do
|
|||||||
)
|
)
|
||||||
|
|
||||||
prompts = nil
|
prompts = nil
|
||||||
DiscourseAi::Completions::Llm.with_prepared_responses(["world"]) do |_, _, _prompts|
|
DiscourseAi::Completions::Llm.with_prepared_responses([[" ", "world"]]) do |_, _, _prompts|
|
||||||
message =
|
message =
|
||||||
ChatSDK::Message.create(
|
ChatSDK::Message.create(
|
||||||
channel_id: channel.id,
|
channel_id: channel.id,
|
||||||
@ -386,6 +386,9 @@ RSpec.describe DiscourseAi::AiBot::Playground do
|
|||||||
TEXT
|
TEXT
|
||||||
|
|
||||||
expect(content.strip).to eq(expected)
|
expect(content.strip).to eq(expected)
|
||||||
|
|
||||||
|
reply = Chat::Message.order(:id).last
|
||||||
|
expect(reply.message).to eq("world")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should reply to a mention if properly enabled" do
|
it "should reply to a mention if properly enabled" do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user