FIX: Triage rule should append selected tags instead of replacing them (#1022)
This commit is contained in:
parent
34f43f398d
commit
5fc7a730ef
|
@ -66,7 +66,9 @@ module DiscourseAi
|
||||||
|
|
||||||
changes = {}
|
changes = {}
|
||||||
changes[:category_id] = category_id if category_id.present?
|
changes[:category_id] = category_id if category_id.present?
|
||||||
changes[:tags] = tags if SiteSetting.tagging_enabled? && tags.present?
|
if SiteSetting.tagging_enabled? && tags.present?
|
||||||
|
changes[:tags] = post.topic.tags.map(&:name).concat(tags)
|
||||||
|
end
|
||||||
|
|
||||||
if changes.present?
|
if changes.present?
|
||||||
first_post = post.topic.posts.where(post_number: 1).first
|
first_post = post.topic.posts.where(post_number: 1).first
|
||||||
|
|
|
@ -198,4 +198,24 @@ describe DiscourseAi::Automation::LlmTriage do
|
||||||
expect(spy.model_params[:stop_sequences]).to contain_exactly(*sequences)
|
expect(spy.model_params[:stop_sequences]).to contain_exactly(*sequences)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "append rule tags instead of replacing them" do
|
||||||
|
tag_1 = Fabricate(:tag)
|
||||||
|
tag_2 = Fabricate(:tag)
|
||||||
|
post.topic.update!(tags: [tag_1])
|
||||||
|
|
||||||
|
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,
|
||||||
|
tags: [tag_2.name],
|
||||||
|
automation: nil,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(post.topic.reload.tags).to contain_exactly(tag_1, tag_2)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue