aboutsummaryrefslogtreecommitdiffstats
path: root/cogs/assistant.py
diff options
context:
space:
mode:
authorsalmonik <raisersoft@proton.me>2026-04-19 15:43:32 +0200
committersalmonik <raisersoft@proton.me>2026-04-19 15:43:32 +0200
commit1dcdbe3cf03ff16b3ff2e2e6d572e0b3c72c18c0 (patch)
treef11dc45777d8b3c8ff0e2ca16be83f85b272bd48 /cogs/assistant.py
parenttest: add cron tests + improve existing tests (diff)
downloadsenator-sperma-1dcdbe3cf03ff16b3ff2e2e6d572e0b3c72c18c0.tar.gz
senator-sperma-1dcdbe3cf03ff16b3ff2e2e6d572e0b3c72c18c0.zip
refactor: simplify cogs, reduce complexity
- Remove unused imports and dead code - Cleaner error handling - Reduce cognitive complexity
Diffstat (limited to 'cogs/assistant.py')
-rw-r--r--cogs/assistant.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/cogs/assistant.py b/cogs/assistant.py
index 71f5150..21e4989 100644
--- a/cogs/assistant.py
+++ b/cogs/assistant.py
@@ -6,7 +6,7 @@
6import re 6import re
7import discord 7import discord
8from discord.ext import commands 8from discord.ext import commands
9import requests 9import httpx
10import json 10import json
11import logging 11import logging
12import shutil 12import shutil
@@ -133,11 +133,12 @@ class Jarvis(commands.Cog):
133 133
134 @staticmethod 134 @staticmethod
135 async def _make_api_request(payload, headers): 135 async def _make_api_request(payload, headers):
136 url = "https://openrouter.ai/api/v1/chat/completions" 136 async with httpx.AsyncClient() as client:
137 response = requests.post(url=url, headers=headers, json=payload) 137 url = "https://openrouter.ai/api/v1/chat/completions"
138 response_data = response.json() 138 response = await client.post(url=url, headers=headers, json=payload)
139 logger.info(response_data) 139 response_data = response.json()
140 return response_data 140 logger.info(response_data)
141 return response_data
141 142
142 @staticmethod 143 @staticmethod
143 def _parse_response(response_data): 144 def _parse_response(response_data):