diff options
Diffstat (limited to 'src/client/views/nodes/chatbot/tools/CreateCSVTool.ts')
-rw-r--r-- | src/client/views/nodes/chatbot/tools/CreateCSVTool.ts | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/client/views/nodes/chatbot/tools/CreateCSVTool.ts b/src/client/views/nodes/chatbot/tools/CreateCSVTool.ts index d3ded0de0..fff57c6d4 100644 --- a/src/client/views/nodes/chatbot/tools/CreateCSVTool.ts +++ b/src/client/views/nodes/chatbot/tools/CreateCSVTool.ts @@ -1,7 +1,8 @@ import { BaseTool } from './BaseTool'; import { Networking } from '../../../../Network'; +import { Observation } from '../types/types'; -export class CreateCSVTool extends BaseTool<{ csvData: string; filename: string }> { +export class CreateCSVTool extends BaseTool<{ csvData: { type: string; description: string; required: boolean }; filename: { type: string; description: string; required: boolean } }> { private _handleCSVResult: (url: string, filename: string, id: string, data: string) => void; constructor(handleCSVResult: (url: string, title: string, id: string, data: string) => void) { @@ -9,18 +10,16 @@ export class CreateCSVTool extends BaseTool<{ csvData: string; filename: string 'createCSV', 'Creates a CSV file from raw CSV data and saves it to the server', { - type: 'object', - properties: { - csvData: { - type: 'string', - description: 'A string of comma-separated values representing the CSV data.', - }, - filename: { - type: 'string', - description: 'The base name of the CSV file to be created. Should end in ".csv".', - }, + csvData: { + type: 'string', + description: 'A string of comma-separated values representing the CSV data.', + required: true, + }, + filename: { + type: 'string', + description: 'The base name of the CSV file to be created. Should end in ".csv".', + required: true, }, - required: ['csvData', 'filename'], }, 'Provide a CSV string and a filename to create a CSV file.', 'Creates a CSV file from the provided CSV string and saves it to the server with a unique identifier, returning the file URL and UUID.' @@ -28,13 +27,11 @@ export class CreateCSVTool extends BaseTool<{ csvData: string; filename: string this._handleCSVResult = handleCSVResult; } - async execute(args: { csvData: string; filename: string }): Promise<unknown> { + async execute(args: { csvData: string; filename: string }): Promise<Observation[]> { try { console.log('Creating CSV file:', args.filename, ' with data:', args.csvData); - // Post the raw CSV data to the createCSV endpoint on the server const { fileUrl, id } = await Networking.PostToServer('/createCSV', { filename: args.filename, data: args.csvData }); - // Handle the result by invoking the callback this._handleCSVResult(fileUrl, args.filename, id, args.csvData); return [ |