Skip to content

Commit 7ebbcd2

Browse files
authored
FIX: Make sure prompt uploads get included in the prompt when triaging (#1008)
1 parent a552167 commit 7ebbcd2

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

lib/automation/llm_triage.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def self.handle(
3232

3333
content = llm.tokenizer.truncate(content, max_post_tokens) if max_post_tokens.present?
3434

35-
prompt.push(type: :user, content: content)
35+
prompt.push(type: :user, content: content, upload_ids: post.upload_ids)
3636

3737
result = nil
3838

lib/completions/llm.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ def record_prompt(prompt)
164164
@prompts << prompt.dup if @prompts
165165
end
166166

167+
def prompts
168+
@prompts
169+
end
170+
167171
def proxy(model)
168172
llm_model =
169173
if model.is_a?(LlmModel)

spec/lib/modules/automation/llm_triage_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,23 @@ def triage(**args)
161161

162162
expect(reviewable.target).to eq(post)
163163
end
164+
165+
it "includes post uploads when triaging" do
166+
post_upload = Fabricate(:image_upload, posts: [post])
167+
168+
DiscourseAi::Completions::Llm.with_prepared_responses(["bad"]) do
169+
triage(
170+
post: post,
171+
model: "custom:#{llm_model.id}",
172+
system_prompt: "test %%POST%%",
173+
search_for_text: "bad",
174+
flag_post: true,
175+
automation: nil,
176+
)
177+
178+
triage_prompt = DiscourseAi::Completions::Llm.prompts.last
179+
180+
expect(triage_prompt.messages.last[:upload_ids]).to contain_exactly(post_upload.id)
181+
end
182+
end
164183
end

0 commit comments

Comments
 (0)