aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorA.J. Shulman <Shulman.aj@gmail.com>2025-01-23 11:54:04 -0500
committerA.J. Shulman <Shulman.aj@gmail.com>2025-01-23 11:54:04 -0500
commitb72d018698ad1d2e713f0fcbef392d23bf1cf545 (patch)
treef9081a449e916bfc3b8c649a0d282f6109f238eb /src
parent99ecd6259ad9aaf3ca7a64aadde42b6dc976e6a2 (diff)
Deleted dictionary tool
Diffstat (limited to 'src')
-rw-r--r--src/client/views/nodes/chatbot/tools/DictionaryTool.ts65
1 files changed, 0 insertions, 65 deletions
diff --git a/src/client/views/nodes/chatbot/tools/DictionaryTool.ts b/src/client/views/nodes/chatbot/tools/DictionaryTool.ts
deleted file mode 100644
index 3493f38d7..000000000
--- a/src/client/views/nodes/chatbot/tools/DictionaryTool.ts
+++ /dev/null
@@ -1,65 +0,0 @@
-import { Observation } from '../types/types';
-import { ParametersType, ToolInfo } from '../types/tool_types';
-import { BaseTool } from './BaseTool';
-
-const dictionaryToolParams = [
- {
- name: 'word',
- type: 'string',
- description: 'The word to look up in the dictionary.',
- required: true,
- },
-] as const;
-
-type DictionaryToolParamsType = typeof dictionaryToolParams;
-
-const dictionaryToolInfo: ToolInfo<DictionaryToolParamsType> = {
- name: 'dictionary',
- citationRules: 'No citation needed.',
- parameterRules: dictionaryToolParams,
- description: 'Fetches the definition of a given word using an open dictionary API.',
-};
-
-/**
- * DictionaryTool is a tool that fetches the definition of a given word using an open dictionary API.
- */
-export class DictionaryTool extends BaseTool<DictionaryToolParamsType> {
- constructor() {
- super(dictionaryToolInfo);
- }
-
- async execute(args: ParametersType<DictionaryToolParamsType>): Promise<Observation[]> {
- const url = `https://api.dictionaryapi.dev/api/v2/entries/en/${args.word}`;
-
- try {
- const response = await fetch(url);
- const data = await response.json();
-
- // Handle cases where the word is not found
- if (data.title === 'No Definitions Found') {
- return [
- {
- type: 'text',
- text: `Sorry, I couldn't find a definition for the word "${args.word}".`,
- },
- ];
- }
-
- // Extract the first definition
- const definition = data[0]?.meanings[0]?.definitions[0]?.definition;
- return [
- {
- type: 'text',
- text: `The definition of "${args.word}" is: ${definition}`,
- },
- ];
- } catch (error) {
- return [
- {
- type: 'text',
- text: `An error occurred while fetching the definition: ${error}`,
- },
- ];
- }
- }
-}