discourse-ai/lib/shared/chat_message_classificator.rb
Roman Rizzi a838116cd5
FEATURE: Use dedicated reviewables for AI flags. (#4)
This change adds two new reviewable types: ReviewableAIPost and ReviewableAIChatMessage. They have the same actions as their existing counterparts: ReviewableFlaggedPost and ReviewableChatMessage.

We'll display the model used and their accuracy when showing these flags in the review queue and adjust the latter after staff performs an action, tracking a global accuracy per existing model in a separate table.


* FEATURE: Dedicated reviewables for AI flags

* Store and adjust model accuracy

* Display accuracy in reviewable templates
2023-03-07 15:39:28 -03:00

26 lines
662 B
Ruby

# frozen_string_literal: true
module ::DiscourseAI
class ChatMessageClassificator < Classificator
private
def flag!(chat_message, classification, verdicts, accuracies)
reviewable =
ReviewableAIChatMessage.needs_review!(
created_by: Discourse.system_user,
target: chat_message,
reviewable_by_moderator: true,
potential_spam: false,
payload: {
classification: classification,
accuracies: accuracies,
verdicts: verdicts,
},
)
reviewable.update(target_created_by: chat_message.user)
add_score(reviewable)
end
end
end