mirror of
https://github.com/bendtherules/ask262.git
synced 2026-08-18 13:21:55 +00:00
refactor(config): centralize storage and graph file paths
- Added `constants.mjs` defining `STORAGE_DIR` and `GRAPH_FILE`. - Replaced hard‑coded path strings in `agent.mjs`, `build_graph.mjs`, and `ingest.mjs` with imports from the new constants module. - Updated console log in `ingest.mjs` to reference `STORAGE_DIR`. - Adjusted `GRAPH_FILE` path to `./graphology/graph.json` via the constant.
This commit is contained in:
@@ -10,8 +10,7 @@ import { OllamaEmbedding } from '@llamaindex/ollama';
|
|||||||
import { OpenAI } from '@llamaindex/openai';
|
import { OpenAI } from '@llamaindex/openai';
|
||||||
import { Graph } from 'graphology';
|
import { Graph } from 'graphology';
|
||||||
|
|
||||||
const STORAGE_DIR = './storage';
|
import { STORAGE_DIR, GRAPH_FILE } from './constants.mjs';
|
||||||
const GRAPH_FILE = './graph.json';
|
|
||||||
|
|
||||||
// Configure Settings
|
// Configure Settings
|
||||||
Settings.embedModel = new OllamaEmbedding({
|
Settings.embedModel = new OllamaEmbedding({
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ import { Graph } from 'graphology';
|
|||||||
|
|
||||||
const SPEC_DIR = './spec-built/multipage';
|
const SPEC_DIR = './spec-built/multipage';
|
||||||
const CODE_DIR = './engine262/src';
|
const CODE_DIR = './engine262/src';
|
||||||
const GRAPH_FILE = './graph.json';
|
import { GRAPH_FILE } from './constants.mjs';
|
||||||
|
|
||||||
async function buildGraph() {
|
async function buildGraph() {
|
||||||
const graph = new Graph({ multi: true });
|
const graph = new Graph({ multi: true });
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export const STORAGE_DIR = './storage';
|
||||||
|
export const GRAPH_FILE = './graphology/graph.json';
|
||||||
+2
-2
@@ -18,7 +18,7 @@ Settings.embedModel = new OllamaEmbedding({
|
|||||||
|
|
||||||
const SPEC_DIR = './spec-built/multipage';
|
const SPEC_DIR = './spec-built/multipage';
|
||||||
const CODE_DIR = './engine262/src';
|
const CODE_DIR = './engine262/src';
|
||||||
const STORAGE_DIR = './storage';
|
import { STORAGE_DIR } from './constants.mjs';
|
||||||
|
|
||||||
// Initialize a SentenceSplitter with even smaller chunk size
|
// Initialize a SentenceSplitter with even smaller chunk size
|
||||||
const sentenceSplitter = new SentenceSplitter({ chunkSize: 256, chunkOverlap: 20 });
|
const sentenceSplitter = new SentenceSplitter({ chunkSize: 256, chunkOverlap: 20 });
|
||||||
@@ -113,7 +113,7 @@ async function main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Index built and persisted to ./storage");
|
console.log(`Index built and persisted to ${STORAGE_DIR}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
main().catch(console.error);
|
main().catch(console.error);
|
||||||
|
|||||||
Reference in New Issue
Block a user