From c8997ab4181daec56db438d639df14a2f84b4c84 Mon Sep 17 00:00:00 2001 From: Paillat Date: Wed, 16 Aug 2023 09:46:28 +0200 Subject: [PATCH] :art: chore(*): run black to format the code --- src/makeprompt.py | 2 +- src/utils/misc.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/makeprompt.py b/src/makeprompt.py index c726793..f710269 100644 --- a/src/makeprompt.py +++ b/src/makeprompt.py @@ -131,7 +131,7 @@ async def chatgpt_process( messages=msgs, functions=called_functions, 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 if response.get("function_call"): diff --git a/src/utils/misc.py b/src/utils/misc.py index bdb5a75..15344e3 100644 --- a/src/utils/misc.py +++ b/src/utils/misc.py @@ -16,12 +16,15 @@ 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() \ No newline at end of file + +Hasher = hasher()