diff options
| author | salmonik <raisersoft@proton.me> | 2026-01-19 08:12:08 +0100 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2026-01-19 08:12:08 +0100 |
| commit | 8dc90a590d165d0064cb5ae0ea4da9784bf6c36e (patch) | |
| tree | 6681c4e2fdf49a747b3a4756e6f3c3f4ba6f071b /cogs | |
| parent | fix removing (diff) | |
| download | senator-sperma-8dc90a590d165d0064cb5ae0ea4da9784bf6c36e.tar.gz senator-sperma-8dc90a590d165d0064cb5ae0ea4da9784bf6c36e.zip | |
do not expose the api key + prompt mod
Diffstat (limited to 'cogs')
| -rw-r--r-- | cogs/jarvis.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/cogs/jarvis.py b/cogs/jarvis.py index 2d2a601..b488508 100644 --- a/cogs/jarvis.py +++ b/cogs/jarvis.py | |||
| @@ -5,12 +5,13 @@ import requests | |||
| 5 | import json | 5 | import json |
| 6 | import logging | 6 | import logging |
| 7 | import shutil | 7 | import shutil |
| 8 | 8 | from dotenv import load_dotenv | |
| 9 | import os | ||
| 9 | from cogs.compression import Compression | 10 | from cogs.compression import Compression |
| 10 | from cogs.downloader import Downloader | 11 | from cogs.downloader import Downloader |
| 11 | 12 | ||
| 12 | logger = logging.getLogger(__name__) | 13 | logger = logging.getLogger(__name__) |
| 13 | 14 | load_dotenv() | |
| 14 | 15 | ||
| 15 | class Jarvis(commands.Cog): | 16 | class Jarvis(commands.Cog): |
| 16 | def __init__(self, bot): | 17 | def __init__(self, bot): |
| @@ -33,7 +34,7 @@ class Jarvis(commands.Cog): | |||
| 33 | async def jarvis(message): | 34 | async def jarvis(message): |
| 34 | url = "https://openrouter.ai/api/v1/chat/completions" | 35 | url = "https://openrouter.ai/api/v1/chat/completions" |
| 35 | headers = { | 36 | headers = { |
| 36 | "Authorization": f"Bearer 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", | 37 | "Authorization": f"Bearer {os.getenv("OPENROUTER_API_KEY")}", |
| 37 | "Content-Type": "application/json" | 38 | "Content-Type": "application/json" |
| 38 | } | 39 | } |
| 39 | payload = { | 40 | payload = { |
| @@ -43,12 +44,13 @@ class Jarvis(commands.Cog): | |||
| 43 | "role": "system", | 44 | "role": "system", |
| 44 | "content": "respond in JSON format ONLY.\n" | 45 | "content": "respond in JSON format ONLY.\n" |
| 45 | "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" |
| 46 | "in the json, only fields need to be filled out, message and action\n" | 47 | "in the json, only two fields need to be filled out, message and action\n" |
| 47 | "message is the response that the program will send the user, " | 48 | "message is the response that the program will send the user, " |
| 48 | "and action is the action the program will do\n" | 49 | "and action is the action the program will do\n" |
| 49 | "action can either be: compress or download.\n" | 50 | "action can either be: compress, download or none.\n" |
| 50 | "message field has to be filled out in polish.\n" | 51 | "message field has to be filled out in polish.\n" |
| 51 | "act like jarvis, be a personal assistant to user, do not use emojis" | 52 | "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" | ||
| 52 | }, | 54 | }, |
| 53 | { | 55 | { |
| 54 | "role": "user", | 56 | "role": "user", |
| @@ -103,4 +105,4 @@ class Jarvis(commands.Cog): | |||
| 103 | pass | 105 | pass |
| 104 | 106 | ||
| 105 | def setup(bot): | 107 | def setup(bot): |
| 106 | bot.add_cog(Jarvis(bot)) \ No newline at end of file | 108 | bot.add_cog(Jarvis(bot)) |
