diff options
Diffstat (limited to 'src/client/views/nodes/chatbot/tools/CreateCSVTool.ts')
-rw-r--r-- | src/client/views/nodes/chatbot/tools/CreateCSVTool.ts | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/client/views/nodes/chatbot/tools/CreateCSVTool.ts b/src/client/views/nodes/chatbot/tools/CreateCSVTool.ts index b321d98ba..290c48d6c 100644 --- a/src/client/views/nodes/chatbot/tools/CreateCSVTool.ts +++ b/src/client/views/nodes/chatbot/tools/CreateCSVTool.ts @@ -1,7 +1,7 @@ import { BaseTool } from './BaseTool'; import { Networking } from '../../../../Network'; import { Observation } from '../types/types'; -import { ParametersType } from './ToolTypes'; +import { ParametersType, ToolInfo } from '../types/tool_types'; const createCSVToolParams = [ { @@ -20,27 +20,28 @@ const createCSVToolParams = [ type CreateCSVToolParamsType = typeof createCSVToolParams; +const createCSVToolInfo: ToolInfo<CreateCSVToolParamsType> = { + name: 'createCSV', + description: '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.', + citationRules: 'No citation needed.', + parameterRules: createCSVToolParams, +}; + export class CreateCSVTool extends BaseTool<CreateCSVToolParamsType> { private _handleCSVResult: (url: string, filename: string, id: string, data: string) => void; constructor(handleCSVResult: (url: string, title: string, id: string, data: string) => void) { - super( - 'createCSV', - 'Creates a CSV file from raw CSV data and saves it to the server', - createCSVToolParams, - '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.' - ); + super(createCSVToolInfo); this._handleCSVResult = handleCSVResult; } async execute(args: ParametersType<CreateCSVToolParamsType>): Promise<Observation[]> { try { console.log('Creating CSV file:', args.filename, ' with data:', args.csvData); - const { fileUrl, id } = await Networking.PostToServer('/createCSV', { + const { fileUrl, id } = (await Networking.PostToServer('/createCSV', { filename: args.filename, data: args.csvData, - }); + })) as { fileUrl: string; id: string }; this._handleCSVResult(fileUrl, args.filename, id, args.csvData); |