Skip to content

Commit

Permalink
Implement moderate_user_message function
Browse files Browse the repository at this point in the history
  • Loading branch information
Flagro committed Nov 6, 2024
1 parent de4b75f commit 4677761
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions bot/rp_bot/ai_agent/moderation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import io

from ...models.handlers_input import Message


class ModerationError(Exception):
pass
Expand Down Expand Up @@ -27,3 +29,16 @@ def moderate_text(text: str) -> bool:
"""
# TODO: implement this
return True


def moderate_user_message(message: Message) -> bool:
"""
Moderates the user message and returns True if the message is safe
"""
return all(
[
moderate_text(message.message_text),
moderate_image(message.in_file_image) if message.in_file_image else True,
moderate_audio(message.in_file_audio) if message.in_file_audio else True,
]
)

0 comments on commit 4677761

Please sign in to comment.