From f5d3884d5a55439487a21094a48925135f89ba8b Mon Sep 17 00:00:00 2001 From: bendtherules Date: Wed, 1 Apr 2026 18:31:30 +0530 Subject: [PATCH] refactor: move model info to constants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added EMBEDDING_MODEL and RERANKER_MODEL to `constants.ts`. - Updated imports to use these constants in `agent.ts`, `agent_tools/reranker.ts`, and `setup/ingest.ts`. - Replaced hard‑coded model strings with the new constants for Ollama embeddings and reranker. --- agent.ts | 4 ++-- agent_tools/reranker.ts | 3 ++- constants.ts | 4 ++++ setup/ingest.ts | 4 ++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/agent.ts b/agent.ts index 3bea1cd..cd0e57c 100644 --- a/agent.ts +++ b/agent.ts @@ -11,10 +11,10 @@ import { createSectionRetrieverTool, createSpecRetrieverTool, } from "./agent_tools"; -import { GRAPH_FILE, STORAGE_DIR } from "./constants"; +import { EMBEDDING_MODEL, GRAPH_FILE, STORAGE_DIR } from "./constants"; const embeddings = new OllamaEmbeddings({ - model: "qwen3-embedding:0.6b", + model: EMBEDDING_MODEL, }); const config = JSON.parse(fs.readFileSync("./config.json", "utf-8")); diff --git a/agent_tools/reranker.ts b/agent_tools/reranker.ts index 910903c..19c9376 100644 --- a/agent_tools/reranker.ts +++ b/agent_tools/reranker.ts @@ -3,7 +3,8 @@ * Uses Ollama's reranker API to score documents against a query. */ -const RERANKER_MODEL = "dengcao/Qwen3-Reranker-0.6B:Q8_0"; +import { RERANKER_MODEL } from "../constants"; + const OLLAMA_HOST = process.env.OLLAMA_HOST || "http://localhost:11434"; export interface RerankResult { diff --git a/constants.ts b/constants.ts index 7702c5b..124407e 100644 --- a/constants.ts +++ b/constants.ts @@ -2,3 +2,7 @@ export const STORAGE_DIR = "./storage"; export const SPEC_DIR = "./spec-built/multipage"; export const CODE_DIR = "./engine262/src"; export const GRAPH_FILE = "./graphology/graph.json"; + +// Model configurations +export const EMBEDDING_MODEL = "qwen3-embedding:0.6b"; +export const RERANKER_MODEL = "dengcao/Qwen3-Reranker-0.6B:Q8_0"; diff --git a/setup/ingest.ts b/setup/ingest.ts index df615f1..b8bde91 100644 --- a/setup/ingest.ts +++ b/setup/ingest.ts @@ -9,10 +9,10 @@ import { RecursiveCharacterTextSplitter } from "@langchain/textsplitters"; import * as cheerio from "cheerio"; import { glob } from "glob"; import ora from "ora"; -import { SPEC_DIR, STORAGE_DIR } from "../constants"; +import { EMBEDDING_MODEL, SPEC_DIR, STORAGE_DIR } from "../constants"; const embeddings = new OllamaEmbeddings({ - model: "qwen3-embedding:0.6b", + model: EMBEDDING_MODEL, }); const htmlSplitter = new RecursiveCharacterTextSplitter({