diff options
| author | A.J. Shulman <Shulman.aj@gmail.com> | 2025-07-07 14:39:06 -0400 |
|---|---|---|
| committer | A.J. Shulman <Shulman.aj@gmail.com> | 2025-07-07 14:39:06 -0400 |
| commit | 9092494778abd55b6aa299fe06b4f70e7c7a767f (patch) | |
| tree | 28aedb8db51224374e1a31d9557ffd28e1c7e8f9 /src/client/views/nodes/chatbot/tools/dynamic/CharacterCountTool.ts | |
| parent | 86c666427ff8b9d516450a150af641570e00f2d2 (diff) | |
changes (seeing if they work)
Diffstat (limited to 'src/client/views/nodes/chatbot/tools/dynamic/CharacterCountTool.ts')
| -rw-r--r-- | src/client/views/nodes/chatbot/tools/dynamic/CharacterCountTool.ts | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/client/views/nodes/chatbot/tools/dynamic/CharacterCountTool.ts b/src/client/views/nodes/chatbot/tools/dynamic/CharacterCountTool.ts new file mode 100644 index 000000000..38fed231c --- /dev/null +++ b/src/client/views/nodes/chatbot/tools/dynamic/CharacterCountTool.ts @@ -0,0 +1,33 @@ +import { Observation } from '../../types/types'; +import { ParametersType, ToolInfo } from '../../types/tool_types'; +import { BaseTool } from '../BaseTool'; + +const characterCountParams = [ + { + name: 'text', + type: 'string', + description: 'The text to count characters in', + required: true + } + ] as const; + + type CharacterCountParamsType = typeof characterCountParams; + + const characterCountInfo: ToolInfo<CharacterCountParamsType> = { + name: 'charactercount', + description: 'Counts characters in text, excluding spaces', + citationRules: 'No citation needed.', + parameterRules: characterCountParams + }; + + export class CharacterCountTool extends BaseTool<CharacterCountParamsType> { + constructor() { + super(characterCountInfo); + } + + async execute(args: ParametersType<CharacterCountParamsType>): Promise<Observation[]> { + const { text } = args; + const count = text ? text.replace(/\s/g, '').length : 0; + return [{ type: 'text', text: `Character count (excluding spaces): ${count}` }]; + } + }
\ No newline at end of file |
