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")