-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInsert-data.js
More file actions
31 lines (26 loc) · 911 Bytes
/
Insert-data.js
File metadata and controls
31 lines (26 loc) · 911 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
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone({
apiKey: 'pcsk_6TQn9a_Mfvh7oswfiVSUe3ipPnNDyeaNQkDQn1cRGVLoyyxJfiBtZj5F5BtgTNjHLydAvf',
});
const index = pc.index('indi');
import { GoogleGenerativeAI } from "@google/generative-ai";
const genAI = new GoogleGenerativeAI("AIzaSyCU6e_tCYt8khtlV3govGAq0jX4hhQa6Bg");
const model = genAI.getGenerativeModel({
model: "text-embedding-004",
dimension: 768, //Dimension is Predefined So we Cant Modify this ..
});
const content="Rich Dad Poor Dad Book Is very Curious to Read.";
const result = await model.embedContent(content);
console.log(result.embedding.values);
try{
await index.namespace('ns1').upsert([
{ id: `id${Date.now()}`, values:result.embedding.values , metadata: {content : content} },
]);
}
catch(err)
{
console.log(err)
}
finally{
console.log("Finally Inserted Data ")
}