mirror of
https://github.com/Paillat-dev/Botator.git
synced 2026-01-02 01:06:19 +00:00
🐛 fix(makeprompt.py): import ModerationError from src.utils.misc to handle moderation errors in chatgpt_process function
🐛 fix(makeprompt.py): raise ModerationError with message "Too many recursive messages" when answering recursively in chatgpt_process function
This commit is contained in:
@@ -6,7 +6,7 @@ import datetime
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
from src.config import curs_data, max_uses, curs_premium, gpt_3_5_turbo_prompt
|
from src.config import curs_data, max_uses, curs_premium, gpt_3_5_turbo_prompt
|
||||||
from src.utils.misc import moderate
|
from src.utils.misc import moderate, ModerationError
|
||||||
from src.utils.openaicaller import openai_caller
|
from src.utils.openaicaller import openai_caller
|
||||||
from src.functionscalls import (
|
from src.functionscalls import (
|
||||||
call_function,
|
call_function,
|
||||||
@@ -159,6 +159,7 @@ async def chatgpt_process(
|
|||||||
await message.channel.send(
|
await message.channel.send(
|
||||||
"Oh uh, it seems like i am answering recursively. I will stop now."
|
"Oh uh, it seems like i am answering recursively. I will stop now."
|
||||||
)
|
)
|
||||||
|
raise ModerationError("Too many recursive messages")
|
||||||
await chatgpt_process(
|
await chatgpt_process(
|
||||||
self, msgs, message, api_key, prompt, model, error_call, depth
|
self, msgs, message, api_key, prompt, model, error_call, depth
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,3 +9,7 @@ async def moderate(api_key, text, recall_func=None):
|
|||||||
input=text,
|
input=text,
|
||||||
)
|
)
|
||||||
return response["results"][0]["flagged"] # type: ignore
|
return response["results"][0]["flagged"] # type: ignore
|
||||||
|
|
||||||
|
|
||||||
|
class ModerationError(Exception):
|
||||||
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user