feat: openai proxying
This commit is contained in:
3
bot.py
3
bot.py
@@ -14,6 +14,7 @@ from aiogram.exceptions import TelegramBadRequest
|
||||
from aiogram.filters import Command, CommandStart
|
||||
from aiogram.types import Message
|
||||
from dotenv import load_dotenv
|
||||
from httpx import AsyncClient as HttpxAsyncClient
|
||||
from openai import APIConnectionError, APIError, APITimeoutError, AsyncOpenAI, NotFoundError, RateLimitError
|
||||
|
||||
|
||||
@@ -136,11 +137,13 @@ def load_settings() -> Settings:
|
||||
|
||||
|
||||
settings = load_settings()
|
||||
http_client = HttpxAsyncClient(proxy=settings.telegram_proxy) if settings.telegram_proxy else None
|
||||
client = AsyncOpenAI(
|
||||
api_key=settings.api_token,
|
||||
base_url=settings.api_base_url,
|
||||
timeout=settings.api_timeout_seconds,
|
||||
max_retries=settings.api_max_retries,
|
||||
http_client=http_client,
|
||||
)
|
||||
user_locks: dict[int, asyncio.Lock] = {}
|
||||
pending_user_messages: dict[int, list[str]] = {}
|
||||
|
||||
Reference in New Issue
Block a user