aboutsummaryrefslogtreecommitdiffstats
path: root/cogs/ai.py
diff options
context:
space:
mode:
Diffstat (limited to 'cogs/ai.py')
-rw-r--r--cogs/ai.py73
1 files changed, 0 insertions, 73 deletions
diff --git a/cogs/ai.py b/cogs/ai.py
deleted file mode 100644
index dbdb02e..0000000
--- a/cogs/ai.py
+++ /dev/null
@@ -1,73 +0,0 @@
1# This file is part of Senator Sperma
2# Licensed under the GPL-3.0 License
3# Copyright (C) 2026 Salmonik @ salmonik@tuta.io
4# https://codeberg.org/salmonik/senator-sperma
5
6import os
7import discord
8from discord.ext import commands
9import logging
10from gtts import gTTS
11import io
12from cogs.utils.llm import llm_completion
13
14logger = logging.getLogger(__name__)
15
16_DEFAULT_SENATOR_MODEL = "cognitivecomputations/dolphin-mistral-24b-venice-edition:free"
17
18class AI(commands.Cog):
19 def __init__(self, bot):
20 self.bot = bot
21
22 @commands.slash_command(
23 name="senator",
24 description="SEENATOR",
25 )
26 async def senator(
27 self,
28 ctx: discord.ApplicationContext,
29 text: str = discord.Option(str, "message", required=True),
30 tts: str = discord.Option(bool, "face?", default=False)
31 ):
32 await ctx.defer()
33
34 model = (
35 os.getenv("LLM_MODEL")
36 or os.getenv("OPENROUTER_MODEL")
37 or _DEFAULT_SENATOR_MODEL
38 )
39 messages = [
40 {
41 "role": "system",
42 "content": "You are Senator Steaven Sperma Armstrong from Metal Gear Rising Vengeance. \
43 You are racist and you hate other minorities. Respond in plain text, no markdown tricks. \
44 If the message is in Polish, respond in Polish. Respond in 100 words."
45 },
46 {
47 "role": "user",
48 "content": text
49 }
50 ]
51
52 response_text = await llm_completion(messages, model=model)
53
54 if response_text is None:
55 await ctx.send_followup("bot siem zesroĊ‚")
56 return
57
58 if tts:
59 tts_obj = gTTS(text=response_text, lang='pl')
60 tts_buffer = io.BytesIO()
61 tts_obj.write_to_fp(tts_buffer)
62 tts_buffer.seek(0)
63 from cogs.voice import get_voice_manager
64 vm = get_voice_manager(self.bot)
65 channel = ctx.author.voice.channel
66 await vm.play_source(channel, discord.FFmpegPCMAudio(tts_buffer), interrupt=False)
67 else:
68 await ctx.send_followup(response_text)
69
70
71
72def setup(bot):
73 bot.add_cog(AI(bot))