forked from NekshaDeSilva/CatalystAI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinitVectorStore.js
More file actions
32 lines (25 loc) · 830 Bytes
/
initVectorStore.js
File metadata and controls
32 lines (25 loc) · 830 Bytes
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
import dotenv from 'dotenv';
import { AstraDBVectorStore } from '@langchain/community/vectorstores/astradb';
import { GoogleGenerativeAIEmbeddings } from '@langchain/google-genai';
dotenv.config();
const embeddings = new GoogleGenerativeAIEmbeddings({
apiKey: process.env.GEMINI_API_KEY,
modelName: 'models/embedding-001',
});
async function initCollection() {
await AstraDBVectorStore.fromTexts(
["test document 1", "test document 2"],
[{ id: 1 }, { id: 2 }],
embeddings,
{
token: process.env.ASTRA_DB_TOKEN,
endpoint: process.env.ASTRA_DB_ENDPOINT,
collection: "pdfdatacatalyst",
vector: {
dimension: 768, // Gemini output dimension
},
}
);
console.log("✅ Collection initialized with proper vector settings.");
}
initCollection().catch(console.error);