symmetry-core
Version:
Use this repository to become an inference provider on the Symmetry network programmatically.
43 lines (42 loc) • 1.26 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigManager = void 0;
const fs_1 = __importDefault(require("fs"));
const js_yaml_1 = __importDefault(require("js-yaml"));
class ConfigManager {
constructor(configPath) {
const configFile = fs_1.default.readFileSync(configPath, "utf8");
const config = js_yaml_1.default.load(configFile);
this.configPath = configPath;
this.config = config;
this.validate();
}
getConfigPath() {
return this.configPath;
}
getAll() {
return this.config;
}
validate() {
const requiredFields = [
"apiBasePath",
"apiHostname",
"apiPort",
"apiProtocol",
"modelName",
"serverKey",
];
for (const field of requiredFields) {
if (!(field in this.config)) {
throw new Error(`Missing required field in client configuration: ${field}`);
}
}
}
get(key) {
return this.config[key];
}
}
exports.ConfigManager = ConfigManager;