-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
61 lines (44 loc) · 1.8 KB
/
config.py
File metadata and controls
61 lines (44 loc) · 1.8 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
53
54
55
56
57
58
59
60
61
from pydantic_settings import BaseSettings
from pydantic import validator
from typing import Union
class Settings(BaseSettings):
DEEPSEEK_API_KEY: str
DEFAULT_MODEL: str = "deepseek/deepseek-chat-v3-0324"
BASE_URL: str = "https://openrouter.ai/api/v1"
MAX_HISTORY: int = 15
TELEGRAM_BOT_TOKEN: str
ADMIN_IDS: list[int] = []
DATABASE_URL: str
TEST_DATABASE_URL: str = "sqlite+aiosqlite:///./data.db"
ENV: str = "dev" # "dev" or "prod"
AVAILABLE_MODELS: dict[str, str] = {
"DeepSeek V3 (default)": "deepseek/deepseek-chat-v3-0324",
"DeepSeek V3": "deepseek/deepseek-chat-v3.1",
"DeepSeek V3.2-exp": "deepseek/deepseek-v3.2-exp",
"DeepSeek R1": "deepseek/deepseek-r1",
"DeepSeek V3 chat": "deepseek/deepseek-chat",
}
class Config:
env_file = ".env"
env_file_encoding = "utf-8"
@property
def current_database_url(self) -> str:
"""Возвращает URL базы для текущего ENV."""
return self.DATABASE_URL if self.ENV == "prod" else self.TEST_DATABASE_URL
@validator("ADMIN_IDS", pre=True)
def parse_admin_ids(cls, v: Union[str, int, list]):
if isinstance(v, int):
return [v]
if isinstance(v, str):
return [int(x.strip()) for x in v.split(",") if x.strip()]
return v
settings = Settings()
# import os
# from typing import List
# from dotenv import load_dotenv
# load_dotenv()
# DEEPSEEK_API_KEY = os.getenv("DEEPSEEK_API_KEY")
# TELEGRAM_BOT_TOKEN = os.getenv("TELEGRAM_BOT_TOKEN")
# DATABASE_URL = os.getenv("DATABASE_URL", "sqlite+aiosqlite:///./data.db")
# ADMIN_IDS: List[int] = [int(x) for x in os.getenv("ADMIN_IDS", "").split(",") if x.strip()]
# DEFAULT_MODEL = os.getenv("DEFAULT_MODEL", "deepseek/deepseek-chat-v3-0324")