redis-service

This commit is contained in:
2024-09-27 09:03:34 +03:00
parent a951759c81
commit c1e481ded8
4 changed files with 91 additions and 15 deletions

View File

@@ -1,6 +1,6 @@
import logging
import math
from utils.store import redis, get_average_toxic
from utils.store import redis, get_average_pattern
from bot.api import telegram_api
from bot.config import FEEDBACK_CHAT_ID
from nlp.toxicity_detector import detector
@@ -44,9 +44,10 @@ async def messages_routing(msg, state):
reply_to_msg_id = int(latest_toxic_message_id)
# count average between all of messages
toxic_score = await get_average_toxic(msg)
toxic_pattern = f"toxic:{cid}:{uid}:*"
toxic_score = await get_average_pattern(toxic_pattern)
#
# current mesasage toxicity
if reply_to_msg_id:
one_score = await redis.get(f"toxic:{cid}:{uid}:{reply_to_msg_id}")
if one_score: