Skip to content

Commit

Permalink
Adding the comments in the database
Browse files Browse the repository at this point in the history
  • Loading branch information
kanugurajesh committed Oct 14, 2024
1 parent 1a8dd6b commit 44779f2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/deleteEmbedding.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// This file is used to delete embeddings from the Pinecone index. The function deleteEmbeddings is defined and called to delete the embeddings from the Pinecone index.

// deleteEmbeddings.ts
import { Pinecone } from "@pinecone-database/pinecone";
import dotenv from "dotenv";
Expand Down
2 changes: 2 additions & 0 deletions src/generateEmbeddings.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// The below code snippet is used to generate embeddings for the text data using the Google Generative AI API. The text data is split into chunks of 200 words each, and embeddings are generated for each chunk using the `embedContent` method of the `GoogleGenerativeAI` class. The embeddings are stored in an array along with the chunk index and text data for reference. The generated embeddings are then logged to the console and returned as an array.

// generateEmbeddings.js
import { chunkText } from "./utils/chunkText"; // Adjust the path as necessary
import data from "./data/data"; // Adjust the path as necessary
Expand Down
2 changes: 2 additions & 0 deletions src/queryEmbeddings.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// The below code snippet is used to query embeddings for a given text input using the Google Generative AI API and the Pinecone database. The queryEmbeddings function is defined to generate embeddings for the input text and query the Pinecone index for similar embeddings. The top 3 matches are returned as the query response. The getData function is defined to extract the text data from the query response. The generateAnswer function is defined to generate an answer based on the query text and context using the Google Generative AI API. The query text is used as the prompt for the answer generation process.

// queryEmbeddings.ts
import { Pinecone } from "@pinecone-database/pinecone";
import { GoogleGenerativeAI } from "@google/generative-ai";
Expand Down
2 changes: 2 additions & 0 deletions src/storeEmbeddings.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// The below code snippet is used to store embeddings in the Pinecone database. The storeEmbeddings function is defined to generate embeddings using the generateEmbeddings function and store them in the Pinecone index. The embeddings are upserted to the Pinecone index using the upsert method. The index is initialized with the specified dimension, metric, and serverless configuration. The storeEmbeddings function is then called to store the embeddings in the Pinecone database.

// storeEmbeddings.ts
import { Pinecone } from "@pinecone-database/pinecone";
import dotenv from "dotenv";
Expand Down
2 changes: 2 additions & 0 deletions src/utils/chunkText.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// The below function is used to split the text into chunks of 200 words each.

export const chunkText = (text: string, chunkSize = 200) => {
const words = text.split(/\s+/);
const chunks: string[] = [];
Expand Down

0 comments on commit 44779f2

Please sign in to comment.