Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/automation/llm_triage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ def self.handle(

changes = {}
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?
first_post = post.topic.posts.where(post_number: 1).first
Expand Down
20 changes: 20 additions & 0 deletions spec/lib/modules/automation/llm_triage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,24 @@ def triage(**args)
expect(spy.model_params[:stop_sequences]).to contain_exactly(*sequences)
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
Loading