diff --git a/lib/ai_helper/assistant.rb b/lib/ai_helper/assistant.rb index 8213458d..9a0aff2a 100644 --- a/lib/ai_helper/assistant.rb +++ b/lib/ai_helper/assistant.rb @@ -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 diff --git a/spec/lib/modules/ai_helper/assistant_spec.rb b/spec/lib/modules/ai_helper/assistant_spec.rb index 6ac8ef04..98cd9256 100644 --- a/spec/lib/modules/ai_helper/assistant_spec.rb +++ b/spec/lib/modules/ai_helper/assistant_spec.rb @@ -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