Skip to main content
Glama

In Memoria

test-vector-db.jsโ€ข2.37 kB
#!/usr/bin/env node import { SemanticVectorDB } from '../dist/storage/vector-db.js'; async function testVectorDB() { console.log('๐Ÿงช Testing Vector Database Implementation...\n'); // Test with and without OpenAI API key const apiKey = process.env.OPENAI_API_KEY; console.log(`OpenAI API Key: ${apiKey ? 'โœ… Available' : 'โŒ Not set'}`); const vectorDB = new SemanticVectorDB(apiKey); // Test code samples const testCodes = [ { code: ` function fibonacci(n) { if (n <= 1) return n; return fibonacci(n - 1) + fibonacci(n - 2); }`, metadata: { id: 'test1', filePath: 'test.js', language: 'javascript', functionName: 'fibonacci' } }, { code: ` class Calculator { add(a, b) { return a + b; } multiply(a, b) { return a * b; } }`, metadata: { id: 'test2', filePath: 'calc.js', language: 'javascript', className: 'Calculator' } }, { code: ` async function fetchUserData(userId) { const response = await fetch(\`/api/users/\${userId}\`); return response.json(); }`, metadata: { id: 'test3', filePath: 'api.js', language: 'javascript', functionName: 'fetchUserData' } } ]; try { console.log('๐Ÿ“Š Testing embedding generation...'); for (const { code, metadata } of testCodes) { console.log(`\n๐Ÿ”ง Processing: ${metadata.functionName || metadata.className || metadata.id}`); const startTime = Date.now(); // Test the private method by accessing it through a wrapper const vectorDB_internal = vectorDB; const embedding = await vectorDB_internal.generateRealSemanticEmbedding(code); const duration = Date.now() - startTime; console.log(`โœ… Generated embedding: ${embedding.length} dimensions`); console.log(`โฑ๏ธ Time taken: ${duration}ms`); console.log(`๐Ÿ“ˆ Sample values: [${embedding.slice(0, 5).map(v => v.toFixed(4)).join(', ')}, ...]`); } console.log('\n๐ŸŽ‰ Vector database test completed successfully!'); } catch (error) { console.error('โŒ Test failed:', error.message); console.error('Stack trace:', error.stack); process.exit(1); } } // Make generateRealSemanticEmbedding accessible for testing SemanticVectorDB.prototype.testGenerateEmbedding = function (code) { return this.generateRealSemanticEmbedding(code); }; testVectorDB().catch(console.error);

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pi22by7/In-Memoria'

If you have feedback or need assistance with the MCP directory API, please join our Discord server