diff options
| author | salmonik <raisersoft@proton.me> | 2026-01-29 21:43:19 +0100 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2026-01-29 21:43:19 +0100 |
| commit | 89c5f0b9f1fa244895b88ad226e042a79edcb17c (patch) | |
| tree | 61b43313cc9709857c79cacc51a2137c8a1779ea /cogs | |
| parent | bump requirements (diff) | |
| download | senator-sperma-89c5f0b9f1fa244895b88ad226e042a79edcb17c.tar.gz senator-sperma-89c5f0b9f1fa244895b88ad226e042a79edcb17c.zip | |
better reply context
Diffstat (limited to '')
| -rw-r--r-- | cogs/jarvis.py | 45 |
1 files changed, 32 insertions, 13 deletions
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): | |||
| 44 | "Authorization": f"Bearer {os.getenv("OPENROUTER_API_KEY")}", | 44 | "Authorization": f"Bearer {os.getenv("OPENROUTER_API_KEY")}", |
| 45 | "Content-Type": "application/json" | 45 | "Content-Type": "application/json" |
| 46 | } | 46 | } |
| 47 | |||
| 48 | # Build messages array | ||
| 49 | messages = [ | ||
| 50 | { | ||
| 51 | "role": "system", | ||
| 52 | "content": "your task is to tell the program what to do and how to respond after receiving a message.\n" | ||
| 53 | "message field has to be filled out in polish.\n" | ||
| 54 | "act like jarvis, be a personal assistant to user, do not use emojis\n" | ||
| 55 | "do not ask the user if they want to do an action. the user will tell you that" | ||
| 56 | } | ||
| 57 | ] | ||
| 58 | |||
| 59 | # Add original message with display name | ||
| 60 | messages.append({ | ||
| 61 | "role": "user", | ||
| 62 | "content": f"[from {message.author.display_name}]: {message.content}" | ||
| 63 | }) | ||
| 64 | |||
| 65 | # If it's a reply, add the original message and reply as separate messages | ||
| 66 | if message.reference and (message.type == discord.MessageType.reply or message.reference.resolved): | ||
| 67 | if message.reference.resolved: | ||
| 68 | original_msg = message.reference.resolved | ||
| 69 | messages.append({ | ||
| 70 | "role": "user", | ||
| 71 | "content": f"[original message from {original_msg.author.display_name}]: {original_msg.content}" | ||
| 72 | }) | ||
| 73 | messages.append({ | ||
| 74 | "role": "user", | ||
| 75 | "content": f"[reply from {message.author.display_name}]: {message.content}" | ||
| 76 | }) | ||
| 77 | |||
| 47 | payload = { | 78 | payload = { |
| 48 | "model": "arcee-ai/trinity-large-preview:free", | 79 | "model": "arcee-ai/trinity-large-preview:free", |
| 49 | "messages": [ | 80 | "messages": messages, |
| 50 | { | ||
| 51 | "role": "system", | ||
| 52 | "content": "your task is to tell the program what to do and how to respond after receiving a message.\n" | ||
| 53 | "message field has to be filled out in polish.\n" | ||
| 54 | "act like jarvis, be a personal assistant to user, do not use emojis\n" | ||
| 55 | "do not ask the user if they want to do an action. the user will tell you that" | ||
| 56 | }, | ||
| 57 | { | ||
| 58 | "role": "user", | ||
| 59 | "content": f"{content}" | ||
| 60 | } | ||
| 61 | ], | ||
| 62 | "response_format": { | 81 | "response_format": { |
| 63 | "type": "json_schema", | 82 | "type": "json_schema", |
| 64 | "json_schema": { | 83 | "json_schema": { |
