🎨 chore(*): run black to format the code

This commit is contained in:
2023-08-16 09:46:28 +02:00
parent ee825be892
commit c8997ab418
2 changed files with 5 additions and 2 deletions

View File

@@ -131,7 +131,7 @@ async def chatgpt_process(
messages=msgs, messages=msgs,
functions=called_functions, functions=called_functions,
function_call="auto", function_call="auto",
user=Hasher(str(message.author.id)), #for user banning in case of abuse user=Hasher(str(message.author.id)), # for user banning in case of abuse
) )
response = response["choices"][0]["message"] # type: ignore response = response["choices"][0]["message"] # type: ignore
if response.get("function_call"): if response.get("function_call"):

View File

@@ -16,12 +16,15 @@ async def moderate(api_key, text, recall_func=None):
class ModerationError(Exception): class ModerationError(Exception):
pass pass
class hasher: class hasher:
def __init__(self): def __init__(self):
self.hashes = {} self.hashes = {}
def __call__(self, text: str) -> str: def __call__(self, text: str) -> str:
if self.hashes.get(text, None) is None: if self.hashes.get(text, None) is None:
self.hashes[text] = hashlib.sha256(text.encode()).hexdigest() self.hashes[text] = hashlib.sha256(text.encode()).hexdigest()
return self.hashes[text] return self.hashes[text]
Hasher = hasher()
Hasher = hasher()