🐛 fix(chat.py): fix typo in message.channel.send() method call

🔒 chore(chat.py): add moderation check for message content in call_function() to prevent sending blocked messages
🔒 chore(chat.py): add moderation check for query in call_function() to prevent sending blocked queries
🔒 chore(makeprompt.py): add moderation check for content in chatgpt_process() to prevent sending blocked content
🔒 chore(makeprompt.py): add depth check to prevent recursive answering in chatgpt_process()
This commit is contained in:
2023-08-16 09:20:29 +02:00
parent d520b8b87c
commit 303d3c07ac
3 changed files with 29 additions and 15 deletions

View File

@@ -135,7 +135,7 @@ async def chatgpt_process(
response = response["choices"][0]["message"] # type: ignore
if response.get("function_call"):
function_call = response.get("function_call")
returned = await call_function(message, function_call)
returned = await call_function(message, function_call, api_key)
if returned != None:
msgs.append(
{
@@ -153,13 +153,23 @@ async def chatgpt_process(
await chatgpt_process(self, msgs, message, api_key, prompt, model, depth)
else:
content = response.get("content", "")
while len(content) != 0:
if len(content) > 2000:
await message.channel.send(content[:2000])
content = content[2000:]
else:
await message.channel.send(content)
content = ""
if moderate(api_key, content, error_call):
depth += 1
if depth > 2:
await message.channel.send(
"Oh uh, it seems like i am answering recursively. I will stop now."
)
await chatgpt_process(
self, msgs, message, api_key, prompt, model, error_call, depth
)
else:
while len(content) != 0:
if len(content) > 2000:
await message.channel.send(content[:2000])
content = content[2000:]
else:
await message.channel.send(content)
content = ""
async def chat_process(self, message):