-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloader.py
More file actions
52 lines (45 loc) · 1.23 KB
/
loader.py
File metadata and controls
52 lines (45 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import httpx
from aiogram import Bot, Dispatcher, Router
from openai import AsyncOpenAI
from ai.service import OpenAIService
from config import config
from config.config import AI_API_MODEL, AI_SCHEMA, AI_SYSTEM_PROMPT, AI_USER_PROMPT
from ics.creator import ICSCreator
from storage.sqlite import Database
# Bot
ADMINS = config.ADMINS
TOKEN = config.BOT_TOKEN
router = Router()
bot = Bot(TOKEN)
db = Database(path_to_db="storage/main.db")
dp = Dispatcher()
ics_creator = ICSCreator()
# Ai
AI_API_KEY = config.AI_API_KEY
AI_API_URL = config.AI_API_URL
PROXY_URL = config.AI_PROXY_URL
if not AI_API_URL:
AI_API_URL = None
else:
AI_API_URL = AI_API_URL.rstrip("/")
if not AI_API_URL.endswith("/v1"):
AI_API_URL += "/v1"
if PROXY_URL:
http_client = httpx.AsyncClient(proxy=PROXY_URL)
ai_client = AsyncOpenAI(
api_key=AI_API_KEY,
base_url=AI_API_URL,
http_client=http_client
)
else:
ai_client = AsyncOpenAI(
api_key=AI_API_KEY,
base_url=AI_API_URL)
# Инициализация сервиса OpenAI
openai_service = OpenAIService(
api_client=ai_client,
model=AI_API_MODEL,
schema=AI_SCHEMA,
system_prompt=AI_SYSTEM_PROMPT,
user_prompt=AI_USER_PROMPT,
)