diff --git a/workers/index.js b/workers/index.js index d0fe233..fb0aff1 100644 --- a/workers/index.js +++ b/workers/index.js @@ -10,6 +10,8 @@ const { runGraphWorker } = require("./graphWorker"); const { runSignalWorker } = require("./signalWorker"); +require("dotenv").config({ path: path.resolve(__dirname, "../.env") }); + const configPath = path.resolve(__dirname, "../config.json"); const configDir = path.dirname(configPath); 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); } +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 = { 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")), llm: rawConfig.llm || {}, workers: rawConfig.workers || {}, - openRouter: rawConfig.openRouter || {}, + openRouter, intelligence: rawConfig.intelligence || {}, };