From 1dcdbe3cf03ff16b3ff2e2e6d572e0b3c72c18c0 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 19 Apr 2026 15:43:32 +0200 Subject: refactor: simplify cogs, reduce complexity - Remove unused imports and dead code - Cleaner error handling - Reduce cognitive complexity --- cogs/assistant.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'cogs/assistant.py') 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 @@ import re import discord from discord.ext import commands -import requests +import httpx import json import logging import shutil @@ -133,11 +133,12 @@ class Jarvis(commands.Cog): @staticmethod async def _make_api_request(payload, headers): - url = "https://openrouter.ai/api/v1/chat/completions" - response = requests.post(url=url, headers=headers, json=payload) - response_data = response.json() - logger.info(response_data) - return response_data + async with httpx.AsyncClient() as client: + url = "https://openrouter.ai/api/v1/chat/completions" + response = await client.post(url=url, headers=headers, json=payload) + response_data = response.json() + logger.info(response_data) + return response_data @staticmethod def _parse_response(response_data): -- cgit v1.2.3