refactor: load environment variables from .env file and update openRouter configuration
This commit is contained in:
parent
80236b9396
commit
7ceaaf2401
1 changed files with 8 additions and 1 deletions
|
|
@ -10,6 +10,8 @@ const { runGraphWorker } = require("./graphWorker");
|
||||||
const { runSignalWorker } = require("./signalWorker");
|
const { runSignalWorker } = require("./signalWorker");
|
||||||
|
|
||||||
|
|
||||||
|
require("dotenv").config({ path: path.resolve(__dirname, "../.env") });
|
||||||
|
|
||||||
const configPath = path.resolve(__dirname, "../config.json");
|
const configPath = path.resolve(__dirname, "../config.json");
|
||||||
const configDir = path.dirname(configPath);
|
const configDir = path.dirname(configPath);
|
||||||
const rawConfig = JSON.parse(fs.readFileSync(configPath, "utf8"));
|
const rawConfig = JSON.parse(fs.readFileSync(configPath, "utf8"));
|
||||||
|
|
@ -19,12 +21,17 @@ function resolvePath(p, fallback) {
|
||||||
return path.isAbsolute(p) ? p : path.resolve(configDir, p);
|
return path.isAbsolute(p) ? p : path.resolve(configDir, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const openRouter = { ...rawConfig.openRouter };
|
||||||
|
if (process.env.OPEN_ROUTER_API_KEY) openRouter.apiKey = process.env.OPEN_ROUTER_API_KEY;
|
||||||
|
if (process.env.OPEN_ROUTER_LLM_MODEL) openRouter.llmModel = process.env.OPEN_ROUTER_LLM_MODEL;
|
||||||
|
if (process.env.OPEN_ROUTER_EMBED_MODEL) openRouter.embeddingModel = process.env.OPEN_ROUTER_EMBED_MODEL;
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
duriin_db: process.env.DURIIN_DB || resolvePath(rawConfig.duriin_db, path.resolve(configDir, "archive.sqlite")),
|
duriin_db: process.env.DURIIN_DB || resolvePath(rawConfig.duriin_db, path.resolve(configDir, "archive.sqlite")),
|
||||||
intelligence_db: process.env.INTELLIGENCE_DB || resolvePath(rawConfig.intelligence_db, path.resolve(configDir, "intelligence.sqlite")),
|
intelligence_db: process.env.INTELLIGENCE_DB || resolvePath(rawConfig.intelligence_db, path.resolve(configDir, "intelligence.sqlite")),
|
||||||
llm: rawConfig.llm || {},
|
llm: rawConfig.llm || {},
|
||||||
workers: rawConfig.workers || {},
|
workers: rawConfig.workers || {},
|
||||||
openRouter: rawConfig.openRouter || {},
|
openRouter,
|
||||||
intelligence: rawConfig.intelligence || {},
|
intelligence: rawConfig.intelligence || {},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue