diff options
Diffstat (limited to 'src/client/views/nodes/ChatBox/tools')
-rw-r--r-- | src/client/views/nodes/ChatBox/tools/DataAnalysisTool.ts | 30 | ||||
-rw-r--r-- | src/client/views/nodes/ChatBox/tools/RAGTool.ts | 4 |
2 files changed, 32 insertions, 2 deletions
diff --git a/src/client/views/nodes/ChatBox/tools/DataAnalysisTool.ts b/src/client/views/nodes/ChatBox/tools/DataAnalysisTool.ts new file mode 100644 index 000000000..d2edc4847 --- /dev/null +++ b/src/client/views/nodes/ChatBox/tools/DataAnalysisTool.ts @@ -0,0 +1,30 @@ +import { BaseTool } from './BaseTool'; + +export class DataAnalysisTool extends BaseTool<{ csv_file_name: string }> { + private csv_files_function: () => { [filename: string]: string }; + constructor(csv_files: () => { [filename: string]: string }) { + super( + 'dataAnalysis', + 'Analyzes, and provides insights, from a CSV file', + { + csv_file_name: { + type: 'string', + description: 'Name of the CSV file to analyze', + required: 'true', + }, + }, + 'Provide the name of the CSV file to analyze based on the user query and whichever available CSV file may be relevant.', + 'Provides the full CSV file text for your analysis based on the user query and the available CSV file. ' + ); + this.csv_files_function = csv_files; + } + + getFileContent(filename: string): string | undefined { + const files = this.csv_files_function(); + return files[filename]; + } + + async execute(args: { csv_file_name: string }): Promise<any> { + return [{ type: 'text', text: this.getFileContent(args.csv_file_name) }]; + } +} diff --git a/src/client/views/nodes/ChatBox/tools/RAGTool.ts b/src/client/views/nodes/ChatBox/tools/RAGTool.ts index be591fa9a..26fa2adc5 100644 --- a/src/client/views/nodes/ChatBox/tools/RAGTool.ts +++ b/src/client/views/nodes/ChatBox/tools/RAGTool.ts @@ -1,6 +1,6 @@ import { BaseTool } from './BaseTool'; import { Vectorstore } from '../vectorstore/Vectorstore'; -import { Chunk } from '../types'; +import { RAGChunk } from '../types'; import * as fs from 'fs'; import { Networking } from '../../../../Network'; import { file } from 'jszip'; @@ -117,7 +117,7 @@ export class RAGTool extends BaseTool<{ hypothetical_document_chunk: string }> { return formatted_chunks; } - async getFormattedChunks(relevantChunks: Chunk[]): Promise<{ type: string; text?: string; image_url?: { url: string } }[]> { + async getFormattedChunks(relevantChunks: RAGChunk[]): Promise<{ type: string; text?: string; image_url?: { url: string } }[]> { try { const { formattedChunks } = await Networking.PostToServer('/formatChunks', { relevantChunks }); |