diff options
Diffstat (limited to 'cogs/ai.py')
| -rw-r--r-- | cogs/ai.py | 36 |
1 files changed, 36 insertions, 0 deletions
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 @@ | |||
| 1 | import discord | ||
| 2 | from discord.ext import commands | ||
| 3 | import google.generativeai as genai | ||
| 4 | import os | ||
| 5 | |||
| 6 | class AI(commands.Cog): | ||
| 7 | def __init__(self, bot): | ||
| 8 | self.bot = bot | ||
| 9 | |||
| 10 | @commands.slash_command( | ||
| 11 | name="senator", | ||
| 12 | description="SEENATOR", | ||
| 13 | ) | ||
| 14 | async def senator( | ||
| 15 | self, | ||
| 16 | ctx: discord.ApplicationContext, | ||
| 17 | text = discord.Option(str, "message", required=True) | ||
| 18 | ): | ||
| 19 | ''' | ||
| 20 | OOWA this so impressive gwachan >w< | ||
| 21 | I can't believe you made this you are so good gwachan :3 | ||
| 22 | ''' | ||
| 23 | await ctx.defer() | ||
| 24 | genai.configure(api_key=os.getenv("GOOGLE_API_KEY")) | ||
| 25 | model = genai.GenerativeModel("gemini-1.5-flash") | ||
| 26 | response = model.generate_content( | ||
| 27 | "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, | ||
| 28 | generation_config=genai.types.GenerationConfig( | ||
| 29 | max_output_tokens=100 | ||
| 30 | ) | ||
| 31 | ) | ||
| 32 | await ctx.respond(response.text) | ||
| 33 | |||
| 34 | def setup(bot): | ||
| 35 | bot.add_cog(AI(bot)) | ||
| 36 | \ No newline at end of file | ||
