Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 9b7f1e6

Browse files
authored
FIX: Helper wasn't working when the persona doesn't use structured output (#1433)
1 parent 22da440 commit 9b7f1e6

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/ai_helper/assistant.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ def generate_prompt(
140140
end
141141
elsif type.blank?
142142
# Assume response is a regular completion.
143-
helper_response << helper_chunk
144-
block.call(helper_chunk) if block
143+
helper_response << partial
144+
block.call(partial) if block
145145
end
146146
end
147147

spec/lib/modules/ai_helper/assistant_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,20 @@
176176

177177
expect(response[:suggestions]).to contain_exactly(english_text)
178178
end
179+
180+
context "when the persona is not using structured outputs" do
181+
it "still works" do
182+
regular_persona = Fabricate(:ai_persona, response_format: nil)
183+
SiteSetting.ai_helper_translator_persona = regular_persona.id
184+
185+
response =
186+
DiscourseAi::Completions::Llm.with_prepared_responses([english_text]) do
187+
subject.generate_and_send_prompt(mode, text_to_translate, user)
188+
end
189+
190+
expect(response[:suggestions]).to contain_exactly(english_text)
191+
end
192+
end
179193
end
180194

181195
context "when using a prompt that returns a list" do

0 commit comments

Comments
 (0)