mirror of
https://github.com/Paillat-dev/Botator.git
synced 2026-01-02 01:06:19 +00:00
added moderation for prefix & pretend & messages
This commit is contained in:
@@ -2,6 +2,7 @@ import logging
|
||||
import sqlite3
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
import openai
|
||||
load_dotenv()
|
||||
perspective_api_key = os.getenv("PERSPECTIVE_API_KEY")
|
||||
discord_token = os.getenv("DISCORD_TOKEN")
|
||||
@@ -15,6 +16,13 @@ c = conn.cursor()
|
||||
connp = sqlite3.connect('../database/premium.db')
|
||||
cp = connp.cursor()
|
||||
|
||||
async def moderate(api_key, text):
|
||||
openai.api_key = api_key
|
||||
response = await openai.Moderation.acreate(
|
||||
input=text,
|
||||
)
|
||||
return response["results"][0]["flagged"]
|
||||
|
||||
c.execute('''CREATE TABLE IF NOT EXISTS data (guild_id text, channel_id text, api_key text, is_active boolean, max_tokens integer, temperature real, frequency_penalty real, presence_penalty real, uses_count_today integer, prompt_size integer, prompt_prefix text, tts boolean, pretend_to_be text, pretend_enabled boolean)''')
|
||||
#we delete the moderation table and create a new one, with all theese parameters as floats: TOXICITY: {result[0]}; SEVERE_TOXICITY: {result[1]}; IDENTITY ATTACK: {result[2]}; INSULT: {result[3]}; PROFANITY: {result[4]}; THREAT: {result[5]}; SEXUALLY EXPLICIT: {result[6]}; FLIRTATION: {result[7]}; OBSCENE: {result[8]}; SPAM: {result[9]}
|
||||
expected_columns = 14
|
||||
|
||||
Reference in New Issue
Block a user