Spaces:
Configuration error
Configuration error
File size: 565 Bytes
7bd11ed |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import execjs
from app.config.models.configs import Config
def load_config(app_config_path: str, model_config_path: str = None) -> Config:
doc_config_dict = load_js_object(app_config_path)
if model_config_path is not None:
model_config_dict = load_js_object(model_config_path)
return Config(**(doc_config_dict if model_config_path is None else {**doc_config_dict, "llm": model_config_dict}))
def load_js_object(config_path: str) -> dict:
with open(config_path, "r") as f:
return execjs.compile(f.read()).eval("module.exports")
|