-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_config.js
More file actions
44 lines (33 loc) · 1.45 KB
/
generate_config.js
File metadata and controls
44 lines (33 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const fs = require('fs');
const path = require('path');
// --- Configuration ---
const RAG_DATA_DIR = path.join(__dirname, 'rag_data');
// NEW: Target file path for *only* the model list
const MODEL_LIST_OUTPUT_PATH = path.join(__dirname, 'src', 'model_list.js');
// ---------------------
console.log('--- Model Config Generator: Initiated ---');
try {
const files = fs.readdirSync(RAG_DATA_DIR);
// Filter for GGUF and map to the Ollama tag (base name)
const modelTags = files
.filter(file => file.endsWith('.gguf'))
.map(file => path.parse(file).name);
if (modelTags.length === 0) {
console.warn('⚠️ WARNING: No .gguf files found in /rag_data/.');
}
// Convert the array to a comma-separated, quoted string
const modelsArrayString = modelTags.map(tag => `\n "${tag}"`).join(',');
// --- Template for the minimal JS file ---
const jsContent = `
// AUTO-GENERATED by generate_config.js. Do not edit manually.
// Dynamic list of available chat models from /rag_data/
const AVAILABLE_CHAT_MODELS = [${modelsArrayString}
];
export default AVAILABLE_CHAT_MODELS;
`;
// 4. Write the new content to the separate file
fs.writeFileSync(MODEL_LIST_OUTPUT_PATH, jsContent, 'utf8');
console.log(`✅ Success! ${modelTags.length} models written to ${path.relative(__dirname, MODEL_LIST_OUTPUT_PATH)}`);
} catch (error) {
console.error('❌ Configuration Generation Failed:', error.message);
}