-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest-indexing.ts
More file actions
65 lines (52 loc) · 1.55 KB
/
Copy pathtest-indexing.ts
File metadata and controls
65 lines (52 loc) · 1.55 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
* Test script to verify indexing and search functionality.
* Run with: npx tsx test-indexing.ts
*/
import { SourceRetriever } from './src/indexing/source-retriever.js';
import path from 'node:path';
const CODEBASE_PATH = path.resolve('../codebaxing');
async function main() {
console.log('='.repeat(60));
console.log('CODEBAXING-NODE TEST');
console.log('='.repeat(60));
console.log(`\nIndexing: ${CODEBASE_PATH}\n`);
const retriever = new SourceRetriever({
codebasePath: CODEBASE_PATH,
embeddingModel: 'all-MiniLM-L6-v2',
verbose: true,
});
// Index the codebase
console.log('\n--- INDEXING ---\n');
await retriever.indexCodebase();
// Get stats
console.log('\n--- STATS ---\n');
const stats = retriever.getStats();
console.log(JSON.stringify(stats, null, 2));
// Test search queries
const queries = [
'semantic search for code',
'parse python file',
'embedding model',
'MCP server tools',
'memory retriever',
];
console.log('\n--- SEARCH TESTS ---\n');
for (const query of queries) {
console.log(`\n🔍 Query: "${query}"`);
console.log('-'.repeat(50));
const { documents, sources } = await retriever.getSourcesForQuestion(query, {
nResults: 3,
});
if (sources.length === 0) {
console.log(' No results found');
} else {
sources.forEach((source, i) => {
console.log(` ${i + 1}. ${source}`);
});
}
}
console.log('\n' + '='.repeat(60));
console.log('TEST COMPLETE');
console.log('='.repeat(60));
}
main().catch(console.error);