diff options
Diffstat (limited to 'src/client/views/nodes/chatbot/tools/CalculateTool.ts')
-rw-r--r-- | src/client/views/nodes/chatbot/tools/CalculateTool.ts | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/client/views/nodes/chatbot/tools/CalculateTool.ts b/src/client/views/nodes/chatbot/tools/CalculateTool.ts index 77ab1b39b..050e6f708 100644 --- a/src/client/views/nodes/chatbot/tools/CalculateTool.ts +++ b/src/client/views/nodes/chatbot/tools/CalculateTool.ts @@ -1,26 +1,28 @@ +import { Observation, ParametersType } from '../types/types'; import { BaseTool } from './BaseTool'; -export class CalculateTool extends BaseTool<{ expression: string }> { +export class CalculateTool extends BaseTool { constructor() { super( 'calculate', 'Perform a calculation', - { - expression: { + [ + { + name: 'expression', type: 'string', description: 'The mathematical expression to evaluate', - required: 'true', - max_inputs: '1', + required: true, }, - }, + ], 'Provide a mathematical expression to calculate that would work with JavaScript eval().', 'Runs a calculation and returns the number - uses JavaScript so be sure to use floating point syntax if necessary' ); } - async execute(args: { expression: string }): Promise<unknown> { - // Note: Using eval() can be dangerous. Consider using a safer alternative. - const result = eval(args.expression); + async execute(args: { expression: string }): Promise<Observation[]> { + // Since the 'expression' parameter is typed as 'string', TypeScript will ensure 'args.expression' is a string + const result = eval(args.expression); // Be cautious with eval(), as it can be dangerous. Consider using a safer alternative if possible. + return [{ type: 'text', text: result.toString() }]; } } |