Spaces:
Runtime error
Runtime error
Create config_data/config.py
Browse files- config_data/config.py +52 -0
config_data/config.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from dataclasses import dataclass
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
@dataclass
|
| 6 |
+
class TgBot:
|
| 7 |
+
token: str
|
| 8 |
+
admin_ids: list[int]
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
@dataclass
|
| 12 |
+
class DataConfig:
|
| 13 |
+
dataset: str
|
| 14 |
+
cls_vec: str
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
@dataclass
|
| 18 |
+
class ModelConfig:
|
| 19 |
+
bi_checkpoint: str
|
| 20 |
+
cross_checkpoint: str
|
| 21 |
+
device: str
|
| 22 |
+
hf_client: str
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
@dataclass
|
| 26 |
+
class Config:
|
| 27 |
+
tg_bot: TgBot
|
| 28 |
+
data: DataConfig
|
| 29 |
+
model: ModelConfig
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def load_config(path: str='.env') -> Config:
|
| 33 |
+
|
| 34 |
+
env: Env = Env()
|
| 35 |
+
env.read_env()
|
| 36 |
+
|
| 37 |
+
return Config(
|
| 38 |
+
tg_bot=TgBot(
|
| 39 |
+
token=os.environ['telegram_token'],
|
| 40 |
+
admin_ids=os.environ['telegram_admin']
|
| 41 |
+
),
|
| 42 |
+
data=DataConfig(
|
| 43 |
+
dataset='ekaterinatao/house_md_context3',
|
| 44 |
+
cls_vec='ekaterinatao/house_md_cls_embeds'
|
| 45 |
+
),
|
| 46 |
+
model=ModelConfig(
|
| 47 |
+
bi_checkpoint='ekaterinatao/house-md-bot-bert-bi-encoder',
|
| 48 |
+
cross_checkpoint='ekaterinatao/house-md-bot-bert-cross-encoder',
|
| 49 |
+
device='cpu',
|
| 50 |
+
hf_client='ekaterinatao/house_md_bot'
|
| 51 |
+
)
|
| 52 |
+
)
|