aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/views/nodes/chatbot/tools/DictionaryTool.ts3
-rw-r--r--src/client/views/nodes/chatbot/tools/ReplicateUserTaskTool.ts0
-rw-r--r--src/client/views/nodes/chatbot/vectorstore/Vectorstore.ts30
3 files changed, 19 insertions, 14 deletions
diff --git a/src/client/views/nodes/chatbot/tools/DictionaryTool.ts b/src/client/views/nodes/chatbot/tools/DictionaryTool.ts
index 377101641..3493f38d7 100644
--- a/src/client/views/nodes/chatbot/tools/DictionaryTool.ts
+++ b/src/client/views/nodes/chatbot/tools/DictionaryTool.ts
@@ -20,6 +20,9 @@ const dictionaryToolInfo: ToolInfo<DictionaryToolParamsType> = {
description: 'Fetches the definition of a given word using an open dictionary API.',
};
+/**
+ * DictionaryTool is a tool that fetches the definition of a given word using an open dictionary API.
+ */
export class DictionaryTool extends BaseTool<DictionaryToolParamsType> {
constructor() {
super(dictionaryToolInfo);
diff --git a/src/client/views/nodes/chatbot/tools/ReplicateUserTaskTool.ts b/src/client/views/nodes/chatbot/tools/ReplicateUserTaskTool.ts
deleted file mode 100644
index e69de29bb..000000000
--- a/src/client/views/nodes/chatbot/tools/ReplicateUserTaskTool.ts
+++ /dev/null
diff --git a/src/client/views/nodes/chatbot/vectorstore/Vectorstore.ts b/src/client/views/nodes/chatbot/vectorstore/Vectorstore.ts
index d962b887f..5334f7df0 100644
--- a/src/client/views/nodes/chatbot/vectorstore/Vectorstore.ts
+++ b/src/client/views/nodes/chatbot/vectorstore/Vectorstore.ts
@@ -1,8 +1,8 @@
/**
* @file Vectorstore.ts
* @description This file defines the Vectorstore class, which integrates with Pinecone for vector-based document indexing and Cohere for text embeddings.
- * It handles tasks such as AI document management, document chunking, and retrieval of relevant document sections based on user queries.
- * The class supports adding documents to the vectorstore, managing document status, and querying Pinecone for document chunks matching a query.
+ * It manages AI document handling, including adding documents, processing media files, combining document chunks, indexing documents,
+ * and retrieving relevant sections based on user queries.
*/
import { Index, IndexList, Pinecone, PineconeRecord, QueryResponse, RecordMetadata } from '@pinecone-database/pinecone';
@@ -34,7 +34,7 @@ export class Vectorstore {
documents: AI_Document[] = []; // Store the documents indexed in the vectorstore.
/**
- * Constructor initializes the Pinecone and Cohere clients, sets up the document ID list,
+ * Initializes the Pinecone and Cohere clients, sets up the document ID list,
* and initializes the Pinecone index.
* @param id The unique identifier for the vectorstore instance.
* @param doc_ids A function that returns a list of document IDs.
@@ -54,8 +54,8 @@ export class Vectorstore {
}
/**
- * Initializes the Pinecone index by checking if it exists, and creating it if not.
- * The index is set to use the cosine metric for vector similarity.
+ * Initializes the Pinecone index by checking if it exists and creating it if necessary.
+ * Sets the index to use cosine similarity for vector similarity calculations.
*/
private async initializeIndex() {
const indexList: IndexList = await this.pinecone.listIndexes();
@@ -80,10 +80,10 @@ export class Vectorstore {
}
/**
- * Adds an AI document to the vectorstore, handling media files separately.
- * Preserves all existing document processing logic.
+ * Adds an AI document to the vectorstore. Handles media file processing for audio/video,
+ * and text embedding for all document types. Updates document metadata during processing.
* @param doc The document to add.
- * @param progressCallback Callback to track progress.
+ * @param progressCallback Callback to track the progress of the addition process.
*/
async addAIDoc(doc: Doc, progressCallback: (progress: number, step: string) => void) {
const ai_document_status: string = StrCast(doc.ai_document_status);
@@ -238,7 +238,8 @@ export class Vectorstore {
}
/**
- * Indexes the processed document by uploading the document's vector chunks to the Pinecone index.
+ * Uploads the document's vector chunks to the Pinecone index.
+ * Prepares the metadata for each chunk and uses Pinecone's upsert operation.
* @param document The processed document containing its chunks and metadata.
*/
private async indexDocument(document: AI_Document) {
@@ -256,9 +257,10 @@ export class Vectorstore {
}
/**
- * Combines chunks until their combined text is at least 500 words.
- * @param chunks The original chunks.
- * @returns Combined chunks.
+ * Combines document chunks until their combined text reaches a minimum word count.
+ * This is used to optimize retrieval and indexing processes.
+ * @param chunks The original chunks to combine.
+ * @returns Combined chunks with updated text and metadata.
*/
private combineChunks(chunks: RAGChunk[]): RAGChunk[] {
const combinedChunks: RAGChunk[] = [];
@@ -289,8 +291,8 @@ export class Vectorstore {
}
/**
- * Retrieves the top K document chunks relevant to the user's query.
- * This involves embedding the query using Cohere, then querying Pinecone for matching vectors.
+ * Retrieves the most relevant document chunks for a given query.
+ * Uses Cohere for embedding the query and Pinecone for vector similarity matching.
* @param query The search query string.
* @param topK The number of top results to return (default is 10).
* @returns A list of document chunks that match the query.