From bb1ecf1ec4746bbbe597908c020b4ff4d9d2d7d3 Mon Sep 17 00:00:00 2001 From: SamlonDev Date: Wed, 21 May 2025 17:59:31 +0200 Subject: added ai --- cogs/ai.py | 36 ++++++++++++++++++++++++++++++++++++ main.py | 1 + 2 files changed, 37 insertions(+) create mode 100644 cogs/ai.py diff --git a/cogs/ai.py b/cogs/ai.py new file mode 100644 index 0000000..484776c --- /dev/null +++ b/cogs/ai.py @@ -0,0 +1,36 @@ +import discord +from discord.ext import commands +import google.generativeai as genai +import os + +class AI(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.slash_command( + name="senator", + description="SEENATOR", + ) + async def senator( + self, + ctx: discord.ApplicationContext, + text = discord.Option(str, "message", required=True) + ): + ''' + OOWA this so impressive gwachan >w< + I can't believe you made this you are so good gwachan :3 + ''' + 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 Armstrong from Metal Gear Rising Vengeance. Respond in plain text, no ** or "". If the message is in Polish, respond in Polish. Respond accordingly to this message: "+text, + generation_config=genai.types.GenerationConfig( + max_output_tokens=100 + ) + ) + await ctx.respond(response.text) + +def setup(bot): + bot.add_cog(AI(bot)) + \ No newline at end of file diff --git a/main.py b/main.py index 4610baa..7722ce4 100644 --- a/main.py +++ b/main.py @@ -20,6 +20,7 @@ if __name__ == "__main__": "cogs.compression", 'cogs.tts', 'cogs.web', + 'cogs.ai', 'cogs.music.play', 'cogs.music.play_compressed', 'cogs.music.skip', -- cgit v1.2.3