2023-02-24 11:25:02 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-03-14 15:03:50 -04:00
|
|
|
module ::DiscourseAi
|
2023-02-28 09:17:03 -05:00
|
|
|
class ChatMessageClassificator < Classificator
|
2023-02-24 11:25:02 -05:00
|
|
|
private
|
|
|
|
|
2023-03-07 13:39:28 -05:00
|
|
|
def flag!(chat_message, classification, verdicts, accuracies)
|
|
|
|
reviewable =
|
2023-03-14 15:03:50 -04:00
|
|
|
ReviewableAiChatMessage.needs_review!(
|
2023-03-07 13:39:28 -05:00
|
|
|
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)
|
2023-02-24 11:25:02 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|