From 89c5f0b9f1fa244895b88ad226e042a79edcb17c Mon Sep 17 00:00:00 2001 From: salmonik Date: Thu, 29 Jan 2026 21:43:19 +0100 Subject: better reply context --- cogs/jarvis.py | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) (limited to 'cogs') diff --git a/cogs/jarvis.py b/cogs/jarvis.py index a03fdb9..0096b38 100644 --- a/cogs/jarvis.py +++ b/cogs/jarvis.py @@ -44,21 +44,40 @@ class Jarvis(commands.Cog): "Authorization": f"Bearer {os.getenv("OPENROUTER_API_KEY")}", "Content-Type": "application/json" } + + # Build messages array + messages = [ + { + "role": "system", + "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" + } + ] + + # Add original message with display name + messages.append({ + "role": "user", + "content": f"[from {message.author.display_name}]: {message.content}" + }) + + # If it's a reply, add the original message and reply as separate messages + if message.reference and (message.type == discord.MessageType.reply or message.reference.resolved): + if message.reference.resolved: + original_msg = message.reference.resolved + messages.append({ + "role": "user", + "content": f"[original message from {original_msg.author.display_name}]: {original_msg.content}" + }) + messages.append({ + "role": "user", + "content": f"[reply from {message.author.display_name}]: {message.content}" + }) + payload = { "model": "arcee-ai/trinity-large-preview:free", - "messages": [ - { - "role": "system", - "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" - }, - { - "role": "user", - "content": f"{content}" - } - ], + "messages": messages, "response_format": { "type": "json_schema", "json_schema": { -- cgit v1.2.3