From a7c330ab81e3d10f8a0c1a1af51db5721cc3a747 Mon Sep 17 00:00:00 2001 From: Samlon Date: Tue, 12 Aug 2025 21:11:23 +0200 Subject: rework ai and tts --- cogs/ai.py | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'cogs/ai.py') diff --git a/cogs/ai.py b/cogs/ai.py index 8c366a2..0a99c64 100644 --- a/cogs/ai.py +++ b/cogs/ai.py @@ -4,6 +4,8 @@ import discord import google.generativeai as genai from discord.ext import commands import logging +import requests +import json logger = logging.getLogger(__name__) @@ -22,13 +24,26 @@ class AI(commands.Cog): text=discord.Option(str, "message", required=True) ): await ctx.defer() - genai.configure(api_key=os.getenv("GOOGLE_API_KEY")) - model = genai.GenerativeModel("gemini-1.5-flash") - response = model.generate_content( - "You are Senator Steaven Sperma Armstrong from Metal Gear Rising Vengeance. Respond in plain text, no ** or "". If the message is in Polish, respond in Polish. Respond in 100 words. Respond accordingly to this message: " + text, + + response = requests.post( + url="https://openrouter.ai/api/v1/chat/completions", + headers={ + "Authorization": f"Bearer {os.getenv('OPENROUTER_API_KEY')}", + "Content-Type": "application/json", + }, + data=json.dumps({ + "model": "cognitivecomputations/dolphin-mistral-24b-venice-edition:free", + "messages": [ + { + "role": "user", + "content": "You are Senator Steaven Sperma Armstrong from Metal Gear Rising Vengeance. You are racist and you hate other minorities. Respond in plain text, no ** or "". If the message is in Polish, respond in Polish. Respond in 100 words. Respond accordingly to this message: " + text + } + ], + + }) ) - await ctx.respond(response.text) - logger.info(f"AI command executed successfully") + await ctx.send_followup(response.json()["choices"][0]["message"]["content"]) + def setup(bot): -- cgit v1.2.3