diff options
| author | A.J. Shulman <Shulman.aj@gmail.com> | 2024-08-20 18:32:08 -0400 |
|---|---|---|
| committer | A.J. Shulman <Shulman.aj@gmail.com> | 2024-08-20 18:32:08 -0400 |
| commit | 79e4c4a3fba42b90ffa656db3ca435505f978afe (patch) | |
| tree | c1515c97bf88a9e40c95f094c68d7bc0118e0522 /src/client/views/nodes/ChatBox/tools/DataAnalysisTool.ts | |
| parent | 57dcd9e29a9b622493f8a4246545675385223572 (diff) | |
supports multiple inputs
maybe also make it so web results cannot have overlap (no same url in websites returned by search)
Also make sure it will cite multiple websites
Diffstat (limited to 'src/client/views/nodes/ChatBox/tools/DataAnalysisTool.ts')
| -rw-r--r-- | src/client/views/nodes/ChatBox/tools/DataAnalysisTool.ts | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/src/client/views/nodes/ChatBox/tools/DataAnalysisTool.ts b/src/client/views/nodes/ChatBox/tools/DataAnalysisTool.ts index b45733639..a12ee46e5 100644 --- a/src/client/views/nodes/ChatBox/tools/DataAnalysisTool.ts +++ b/src/client/views/nodes/ChatBox/tools/DataAnalysisTool.ts @@ -1,21 +1,22 @@ import { BaseTool } from './BaseTool'; -export class DataAnalysisTool extends BaseTool<{ csv_file_name: string }> { +export class DataAnalysisTool extends BaseTool<{ csv_file_name: string | string[] }> { private csv_files_function: () => { filename: string; id: string; text: string }[]; constructor(csv_files: () => { filename: string; id: string; text: string }[]) { super( 'dataAnalysis', - 'Analyzes, and provides insights, from a CSV file', + 'Analyzes, and provides insights, from one or more CSV files', { csv_file_name: { type: 'string', - description: 'Name of the CSV file to analyze', + description: 'Name(s) of the CSV file(s) to analyze', required: 'true', + max_inputs: '3', }, }, - '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. ' + 'Provide the name(s) of up to 3 CSV files to analyze based on the user query and whichever available CSV files may be relevant.', + 'Provides the full CSV file text for your analysis based on the user query and the available CSV file(s). ' ); this.csv_files_function = csv_files; } @@ -32,8 +33,27 @@ export class DataAnalysisTool extends BaseTool<{ csv_file_name: string }> { return file?.id; } - async execute(args: { csv_file_name: string }): Promise<any> { - console.log(this.csv_files_function()); - return [{ type: 'text', text: `<chunk chunk_id=${this.getFileID(args.csv_file_name)} chunk_type=csv}>` + this.getFileContent(args.csv_file_name) + '</chunk>' }]; + async execute(args: { csv_file_name: string | string[] }): Promise<any> { + const filenames = Array.isArray(args.csv_file_name) ? args.csv_file_name : [args.csv_file_name]; + const results = []; + + for (const filename of filenames) { + const fileContent = this.getFileContent(filename); + const fileID = this.getFileID(filename); + + if (fileContent && fileID) { + results.push({ + type: 'text', + text: `<chunk chunk_id=${fileID} chunk_type=csv>${fileContent}</chunk>`, + }); + } else { + results.push({ + type: 'text', + text: `File not found: ${filename}`, + }); + } + } + + return results; } } |
