aboutsummaryrefslogtreecommitdiffstats
path: root/cogs/jarvis.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/jarvis.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/jarvis.py36
1 files changed, 28 insertions, 8 deletions
diff --git a/cogs/jarvis.py b/cogs/jarvis.py
index b488508..3382f5b 100644
--- a/cogs/jarvis.py
+++ b/cogs/jarvis.py
@@ -7,7 +7,6 @@ import logging
7import shutil 7import shutil
8from dotenv import load_dotenv 8from dotenv import load_dotenv
9import os 9import os
10from cogs.compression import Compression
11from cogs.downloader import Downloader 10from cogs.downloader import Downloader
12 11
13logger = logging.getLogger(__name__) 12logger = logging.getLogger(__name__)
@@ -34,6 +33,7 @@ class Jarvis(commands.Cog):
34 async def jarvis(message): 33 async def jarvis(message):
35 url = "https://openrouter.ai/api/v1/chat/completions" 34 url = "https://openrouter.ai/api/v1/chat/completions"
36 headers = { 35 headers = {
36
37 "Authorization": f"Bearer {os.getenv("OPENROUTER_API_KEY")}", 37 "Authorization": f"Bearer {os.getenv("OPENROUTER_API_KEY")}",
38 "Content-Type": "application/json" 38 "Content-Type": "application/json"
39 } 39 }
@@ -42,12 +42,7 @@ class Jarvis(commands.Cog):
42 "messages": [ 42 "messages": [
43 { 43 {
44 "role": "system", 44 "role": "system",
45 "content": "respond in JSON format ONLY.\n" 45 "content": "your task is to tell the program what to do and how to respond after receiving a message.\n"
46 "your task is to tell the program what to do and how to respond after receiving a message.\n"
47 "in the json, only two fields need to be filled out, message and action\n"
48 "message is the response that the program will send the user, "
49 "and action is the action the program will do\n"
50 "action can either be: compress, download or none.\n"
51 "message field has to be filled out in polish.\n" 46 "message field has to be filled out in polish.\n"
52 "act like jarvis, be a personal assistant to user, do not use emojis\n" 47 "act like jarvis, be a personal assistant to user, do not use emojis\n"
53 "do not ask the user if they want to do an action. the user will tell you that" 48 "do not ask the user if they want to do an action. the user will tell you that"
@@ -56,10 +51,35 @@ class Jarvis(commands.Cog):
56 "role": "user", 51 "role": "user",
57 "content": f"{message.content}" 52 "content": f"{message.content}"
58 } 53 }
54 ],
55 "response_format": {
56 "type": "json_schema",
57 "json_schema": {
58 "name": "response",
59 "strict": True,
60 "schema": {
61 "type": "object",
62 "properties": {
63 "message": {
64 "type": "string",
65 "description": "the message that user will receive",
66 },
67 "action": {
68 "type": "string",
69 "description": "the action to do, either download, compress or none"
70 }
71 },
72 "required": ["message", "action"],
73 "additionalProperties": False,
74 }
75 }
76 },
77 "plugins": [
78 {"id": "response-healing"}
59 ] 79 ]
60 } 80 }
61 81
62 response = requests.post(url, headers=headers, json=payload) 82 response = requests.post(url=url, headers=headers, json=payload)
63 # Parse the JSON response 83 # Parse the JSON response
64 response_data = response.json() 84 response_data = response.json()
65 logger.info(response_data) 85 logger.info(response_data)