mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-03-01 06:49:30 +00:00
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
26 lines
662 B
Ruby
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
|