Skip to content

Commit

Permalink
FIX: Make sure prompt uploads get included in the prompt when triaging (
Browse files Browse the repository at this point in the history
  • Loading branch information
romanrizzi authored Dec 6, 2024
1 parent a552167 commit 7ebbcd2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/automation/llm_triage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def self.handle(

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

prompt.push(type: :user, content: content)
prompt.push(type: :user, content: content, upload_ids: post.upload_ids)

result = nil

Expand Down
4 changes: 4 additions & 0 deletions lib/completions/llm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ def record_prompt(prompt)
@prompts << prompt.dup if @prompts
end

def prompts
@prompts
end

def proxy(model)
llm_model =
if model.is_a?(LlmModel)
Expand Down
19 changes: 19 additions & 0 deletions spec/lib/modules/automation/llm_triage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,23 @@ def triage(**args)

expect(reviewable.target).to eq(post)
end

it "includes post uploads when triaging" do
post_upload = Fabricate(:image_upload, posts: [post])

DiscourseAi::Completions::Llm.with_prepared_responses(["bad"]) do
triage(
post: post,
model: "custom:#{llm_model.id}",
system_prompt: "test %%POST%%",
search_for_text: "bad",
flag_post: true,
automation: nil,
)

triage_prompt = DiscourseAi::Completions::Llm.prompts.last

expect(triage_prompt.messages.last[:upload_ids]).to contain_exactly(post_upload.id)
end
end
end

0 comments on commit 7ebbcd2

Please sign in to comment.