mirror of
https://github.com/Paillat-dev/Botator.git
synced 2026-03-03 18:34:55 +00:00
🐛 fix(makeprompt.py): import Hasher class from src.utils.misc to resolve NameError
🔒 chore(makeprompt.py): add user hashing to prevent abuse and enable user banning if necessary
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import hashlib
|
||||
|
||||
from src.utils.openaicaller import openai_caller
|
||||
|
||||
|
||||
@@ -13,3 +15,13 @@ async def moderate(api_key, text, recall_func=None):
|
||||
|
||||
class ModerationError(Exception):
|
||||
pass
|
||||
|
||||
class hasher:
|
||||
def __init__(self):
|
||||
self.hashes = {}
|
||||
def __call__(self, text: str) -> str:
|
||||
if self.hashes.get(text, None) is None:
|
||||
self.hashes[text] = hashlib.sha256(text.encode()).hexdigest()
|
||||
return self.hashes[text]
|
||||
|
||||
Hasher = hasher()
|
||||
Reference in New Issue
Block a user