From 9092494778abd55b6aa299fe06b4f70e7c7a767f Mon Sep 17 00:00:00 2001 From: "A.J. Shulman" Date: Mon, 7 Jul 2025 14:39:06 -0400 Subject: changes (seeing if they work) --- .../nodes/chatbot/tools/dynamic/WordCountTool.ts | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/client/views/nodes/chatbot/tools/dynamic/WordCountTool.ts (limited to 'src/client/views/nodes/chatbot/tools/dynamic/WordCountTool.ts') diff --git a/src/client/views/nodes/chatbot/tools/dynamic/WordCountTool.ts b/src/client/views/nodes/chatbot/tools/dynamic/WordCountTool.ts new file mode 100644 index 000000000..5e15b4795 --- /dev/null +++ b/src/client/views/nodes/chatbot/tools/dynamic/WordCountTool.ts @@ -0,0 +1,33 @@ +import { Observation } from '../../types/types'; +import { ParametersType, ToolInfo } from '../../types/tool_types'; +import { BaseTool } from '../BaseTool'; + +const wordCountParams = [ + { + name: 'phrase', + type: 'string', + description: 'The phrase to count words in', + required: true + } + ] as const; + + type WordCountParamsType = typeof wordCountParams; + + const wordCountInfo: ToolInfo = { + name: 'wordcount', + description: 'Counts the number of words in a given phrase', + citationRules: 'No citation needed.', + parameterRules: wordCountParams + }; + + export class WordCountTool extends BaseTool { + constructor() { + super(wordCountInfo); + } + + async execute(args: ParametersType): Promise { + const { phrase } = args; + const wordCount = phrase ? phrase.trim().split(/\s+/).length : 0; + return [{ type: 'text', text: `Word count: ${wordCount}` }]; + } + } \ No newline at end of file -- cgit v1.2.3-70-g09d2