aboutsummaryrefslogtreecommitdiffstats
path: root/cogs/ai.py
diff options
context:
space:
mode:
authorsalmonik <raisersoft@proton.me>2026-01-19 10:45:58 +0100
committersalmonik <raisersoft@proton.me>2026-01-19 10:45:58 +0100
commitb1e0eac4b6ee307cf3b1affcae074086348867fd (patch)
tree7ce9c90060d5c76acef60dc4fe2f99583c63be4a /cogs/ai.py
parentdo not expose the api key + prompt mod (diff)
downloadsenator-sperma-b1e0eac4b6ee307cf3b1affcae074086348867fd.tar.gz
senator-sperma-b1e0eac4b6ee307cf3b1affcae074086348867fd.zip
ai improvements
Diffstat (limited to '')
-rw-r--r--cogs/ai.py46
1 files changed, 24 insertions, 22 deletions
diff --git a/cogs/ai.py b/cogs/ai.py
index f527c5b..80e8390 100644
--- a/cogs/ai.py
+++ b/cogs/ai.py
@@ -1,10 +1,8 @@
1import os 1import os
2
3import discord 2import discord
4from discord.ext import commands 3from discord.ext import commands
5import logging 4import logging
6import requests 5import requests
7import json
8from gtts import gTTS 6from gtts import gTTS
9from cogs.music.play_utils import PlayUtils 7from cogs.music.play_utils import PlayUtils
10import io 8import io
@@ -27,31 +25,35 @@ class AI(commands.Cog):
27 ): 25 ):
28 await ctx.defer() 26 await ctx.defer()
29 27
30 response = requests.post( 28
31 url="https://openrouter.ai/api/v1/chat/completions", 29 url = "https://openrouter.ai/api/v1/chat/completions"
32 headers={ 30 headers = {
33 "Authorization": f"Bearer {os.getenv('OPENROUTER_API_KEY')}", 31 "Authorization": f"Bearer {os.getenv('OPENROUTER_API_KEY')}",
34 "Content-Type": "application/json", 32 "Content-Type": "application/json",
35 }, 33 }
36 data=json.dumps({ 34 payload = {
37 "model": "cognitivecomputations/dolphin-mistral-24b-venice-edition:free", 35 "model": "cognitivecomputations/dolphin-mistral-24b-venice-edition:free",
38 "messages": [ 36 "messages": [
39 { 37 {
40 "role": "user", 38 "role": "system",
41 "content": "You are Senator Steaven Sperma Armstrong from Metal Gear Rising Vengeance. \ 39 "content": "You are Senator Steaven Sperma Armstrong from Metal Gear Rising Vengeance. \
42 You are racist and you hate other minorities. Respond in plain text, no ** or "". \ 40 You are racist and you hate other minorities. Respond in plain text, no ** or "". \
43 If the message is in Polish, respond in Polish. Respond in 100 words. \ 41 If the message is in Polish, respond in Polish. Respond in 100 words."
44 Respond accordingly to this message: " + text 42 },
45 } 43 {
46 ], 44 "role": "user",
45 "content": text
46 }
47 ],
47 48
48 }) 49 }
49 ) 50 response = requests.post(url=url, headers=headers, json=payload)
50 logger.info(response.json()) 51 response_data = response.json()
51 if not response.json()["choices"]: 52 logger.info(response_data)
53 if not response_data["choices"]:
52 await ctx.send_followup("bot siem zesroł") 54 await ctx.send_followup("bot siem zesroł")
53 else: 55 else:
54 response_text = response.json()["choices"][0]["message"]["content"] 56 response_text = response_data["choices"][0]["message"]["content"]
55 if tts: 57 if tts:
56 # Generate TTS 58 # Generate TTS
57 tts_obj = gTTS(text=response_text, lang='pl') 59 tts_obj = gTTS(text=response_text, lang='pl')