I have this code (only relevant code shown) that does not work. My database is in the…
- User
I have this code (only relevant code shown) that does not work. My database is in the folder set in the constant DB_DIR. Help me fix it: const chromadb = require('chromadb');
// Configuration const DB_DIR = './vector_db'; const COLLECTION_NAME = 'document_chunks'; const TOP_K = 5;
class RAG { constructor() { // Initialize ChromaDB client this.client = new chromadb.ChromaClient({path: DB_DIR}); this.collection = this.client.getCollection({COLLECTION_NAME}); } async retrieve(query) { //Other stuff // Search ChromaDB for relevant documents const results = await this._searchDatabase(queryEmbedding); //Other stuff } async _searchDatabase(queryEmbedding) { try { const results = await this.collection.query({ query_embeddings: [queryEmbedding], n_results: TOP_K, include: ['metadatas'], });
// Extract metadata (e.g., file paths) from results return results.metadatas[0]; } catch (error) { console.error('Error querying ChromaDB:', error); return []; }
} //More code
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.