FIX: Make sure prompt uploads get included in the prompt when triaging (#1008)
This commit is contained in:
parent
a55216773a
commit
7ebbcd2de3
|
@ -32,7 +32,7 @@ module DiscourseAi
|
||||||
|
|
||||||
content = llm.tokenizer.truncate(content, max_post_tokens) if max_post_tokens.present?
|
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
|
result = nil
|
||||||
|
|
||||||
|
|
|
@ -164,6 +164,10 @@ module DiscourseAi
|
||||||
@prompts << prompt.dup if @prompts
|
@prompts << prompt.dup if @prompts
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def prompts
|
||||||
|
@prompts
|
||||||
|
end
|
||||||
|
|
||||||
def proxy(model)
|
def proxy(model)
|
||||||
llm_model =
|
llm_model =
|
||||||
if model.is_a?(LlmModel)
|
if model.is_a?(LlmModel)
|
||||||
|
|
|
@ -161,4 +161,23 @@ describe DiscourseAi::Automation::LlmTriage do
|
||||||
|
|
||||||
expect(reviewable.target).to eq(post)
|
expect(reviewable.target).to eq(post)
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue