diff options
| author | salmonik <raisersoft@proton.me> | 2026-04-19 15:43:32 +0200 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2026-04-19 15:43:32 +0200 |
| commit | 1dcdbe3cf03ff16b3ff2e2e6d572e0b3c72c18c0 (patch) | |
| tree | f11dc45777d8b3c8ff0e2ca16be83f85b272bd48 /cogs/assistant.py | |
| parent | test: add cron tests + improve existing tests (diff) | |
| download | senator-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.py | 13 |
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 @@ | |||
| 6 | import re | 6 | import re |
| 7 | import discord | 7 | import discord |
| 8 | from discord.ext import commands | 8 | from discord.ext import commands |
| 9 | import requests | 9 | import httpx |
| 10 | import json | 10 | import json |
| 11 | import logging | 11 | import logging |
| 12 | import shutil | 12 | import 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): |
