Agent 서버 구축: 멀티테넌트 협상 PoC (UCB Q-Table 학습 + /chat + 14 API + 학습검증 하네스), config 단일화(local.toml) + 빌드 경량화
This commit is contained in:
1 parent
212725e5f9
commit
951d6eab84
140 files changed
+6689
-214
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import tomllib
|
||||
from typing import Optional, Type, Dict, TypeVar
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class ConfigModel(BaseModel):
|
||||
pass
|
||||
|
||||
|
||||
# APP_ENV (backend 와 동일 규약)
|
||||
# local : 로컬 환경(개인 pc) / dev : 개발환경 / prod : 서비스 환경
|
||||
# 실행 시: export APP_ENV=dev (linux) / set APP_ENV=dev (windows)
|
||||
class Configs:
|
||||
ConfigType = TypeVar("ConfigType", bound=ConfigModel)
|
||||
|
||||
def __init__(self, file_path: str):
|
||||
self._settings: Dict[Type["Configs.ConfigType"], "Configs.ConfigType"] = self._load_settings_from_toml(file_path)
|
||||
|
||||
def _load_settings_from_toml(self, file_path: str) -> Dict[Type[ConfigType], ConfigType]:
|
||||
with open(file_path, "rb") as f:
|
||||
toml_content = tomllib.load(f)
|
||||
|
||||
config_subclasses = ConfigModel.__subclasses__()
|
||||
configs = {
|
||||
config_class: config_class.model_validate(toml_content[config_class.__name__])
|
||||
for config_class in config_subclasses
|
||||
if config_class.__name__ in toml_content
|
||||
}
|
||||
return configs
|
||||
|
||||
def get(self, config_class: Type[ConfigType]) -> Optional[ConfigType]:
|
||||
return self._settings.get(config_class)
|
||||
Reference in new issue
Block a user