From b1e0eac4b6ee307cf3b1affcae074086348867fd Mon Sep 17 00:00:00 2001 From: salmonik Date: Mon, 19 Jan 2026 10:45:58 +0100 Subject: ai improvements --- cogs/jarvis.py | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'cogs/jarvis.py') 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 import shutil from dotenv import load_dotenv import os -from cogs.compression import Compression from cogs.downloader import Downloader logger = logging.getLogger(__name__) @@ -34,6 +33,7 @@ class Jarvis(commands.Cog): async def jarvis(message): url = "https://openrouter.ai/api/v1/chat/completions" headers = { + "Authorization": f"Bearer {os.getenv("OPENROUTER_API_KEY")}", "Content-Type": "application/json" } @@ -42,12 +42,7 @@ class Jarvis(commands.Cog): "messages": [ { "role": "system", - "content": "respond in JSON format ONLY.\n" - "your task is to tell the program what to do and how to respond after receiving a message.\n" - "in the json, only two fields need to be filled out, message and action\n" - "message is the response that the program will send the user, " - "and action is the action the program will do\n" - "action can either be: compress, download or none.\n" + "content": "your task is to tell the program what to do and how to respond after receiving a message.\n" "message field has to be filled out in polish.\n" "act like jarvis, be a personal assistant to user, do not use emojis\n" "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): "role": "user", "content": f"{message.content}" } + ], + "response_format": { + "type": "json_schema", + "json_schema": { + "name": "response", + "strict": True, + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string", + "description": "the message that user will receive", + }, + "action": { + "type": "string", + "description": "the action to do, either download, compress or none" + } + }, + "required": ["message", "action"], + "additionalProperties": False, + } + } + }, + "plugins": [ + {"id": "response-healing"} ] } - response = requests.post(url, headers=headers, json=payload) + response = requests.post(url=url, headers=headers, json=payload) # Parse the JSON response response_data = response.json() logger.info(response_data) -- cgit v1.2.3