Skip to content

Commit 956b8ff

Browse files
committed
fix ingest - pull from config file
1 parent da7e9d1 commit 956b8ff

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

bin/commands/data/ingest.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,28 @@ export async function ingestData(config, options) {
1212
throw new Error("Configuration missing. Run 'npx mongodb-rag init' first.");
1313
}
1414

15+
// Restructure the config to match expected format
16+
const ragConfig = {
17+
mongodb: {
18+
uri: config.mongoUrl,
19+
database: config.database,
20+
collection: config.collection
21+
},
22+
embedding: {
23+
provider: config.embedding?.provider || config.provider,
24+
apiKey: config.apiKey,
25+
model: config.embedding?.model || config.model,
26+
dimensions: config.embedding?.dimensions || config.dimensions,
27+
baseUrl: config.embedding?.baseUrl || config.baseUrl,
28+
batchSize: config.embedding?.batchSize || 100
29+
},
30+
search: {
31+
maxResults: config.search?.maxResults || 5,
32+
minScore: config.search?.minScore || 0.7
33+
},
34+
indexName: config.indexName
35+
};
36+
1537
// Set environment variables from config if they're not already set
1638
if (!process.env.EMBEDDING_API_KEY && config.apiKey) {
1739
process.env.EMBEDDING_API_KEY = config.apiKey;
@@ -69,12 +91,12 @@ export async function ingestData(config, options) {
6991
console.log(chalk.blue(`📊 Found ${documents.length} documents to process`));
7092
}
7193

72-
const rag = new MongoRAG(config);
94+
const rag = new MongoRAG(ragConfig);
7395
await rag.connect();
7496

7597
const result = await rag.ingestBatch(documents, {
76-
database: options.database,
77-
collection: options.collection
98+
database: options.database || config.database,
99+
collection: options.collection || config.collection
78100
});
79101

80102
console.log(chalk.green(`✅ Successfully ingested ${result.processed} documents!`));

0 commit comments

Comments
 (0)