FIX: Helper wasn't working when the persona doesn't use structured output (#1433)

This commit is contained in:
Roman Rizzi
2025-06-12 12:33:12 -03:00
committed by GitHub
parent 22da440130
commit 9b7f1e6ee9
2 changed files with 16 additions and 2 deletions
+2 -2
View File
@@ -140,8 +140,8 @@ module DiscourseAi
end
elsif type.blank?
# Assume response is a regular completion.
helper_response << helper_chunk
block.call(helper_chunk) if block
helper_response << partial
block.call(partial) if block
end
end
@@ -176,6 +176,20 @@ RSpec.describe DiscourseAi::AiHelper::Assistant do
expect(response[:suggestions]).to contain_exactly(english_text)
end
context "when the persona is not using structured outputs" do
it "still works" do
regular_persona = Fabricate(:ai_persona, response_format: nil)
SiteSetting.ai_helper_translator_persona = regular_persona.id
response =
DiscourseAi::Completions::Llm.with_prepared_responses([english_text]) do
subject.generate_and_send_prompt(mode, text_to_translate, user)
end
expect(response[:suggestions]).to contain_exactly(english_text)
end
end
end
context "when using a prompt that returns a list" do