diff options
Diffstat (limited to 'src/client/views/nodes/ChatBox/tools/DataAnalysisTool.ts')
-rw-r--r-- | src/client/views/nodes/ChatBox/tools/DataAnalysisTool.ts | 30 |
1 files changed, 30 insertions, 0 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) }]; + } +} |