diff options
author | A.J. Shulman <Shulman.aj@gmail.com> | 2025-04-03 11:45:02 -0400 |
---|---|---|
committer | A.J. Shulman <Shulman.aj@gmail.com> | 2025-04-03 11:45:02 -0400 |
commit | a99d8df26d331d87bae4f27cd52ce5ec4d97fa7a (patch) | |
tree | ad1df355214acd734ecf4b25fa1157f5b252f4f0 /src/client/views/nodes/chatbot/agentsystem/Agent.ts | |
parent | 45a9f5789fa6eaacca9a39cb96cc2a8e3ebe649c (diff) |
attempt
Diffstat (limited to 'src/client/views/nodes/chatbot/agentsystem/Agent.ts')
-rw-r--r-- | src/client/views/nodes/chatbot/agentsystem/Agent.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/client/views/nodes/chatbot/agentsystem/Agent.ts b/src/client/views/nodes/chatbot/agentsystem/Agent.ts index e93fb87db..b5cdb8cf1 100644 --- a/src/client/views/nodes/chatbot/agentsystem/Agent.ts +++ b/src/client/views/nodes/chatbot/agentsystem/Agent.ts @@ -10,6 +10,7 @@ import { CalculateTool } from '../tools/CalculateTool'; //import { CreateAnyDocumentTool } from '../tools/CreateAnyDocTool'; import { CreateDocTool } from '../tools/CreateDocumentTool'; import { DataAnalysisTool } from '../tools/DataAnalysisTool'; +import { DocumentMetadataTool } from '../tools/DocumentMetadataTool'; import { ImageCreationTool } from '../tools/ImageCreationTool'; import { NoTool } from '../tools/NoTool'; import { SearchTool } from '../tools/SearchTool'; @@ -89,6 +90,7 @@ export class Agent { createDoc: new CreateDocTool(addLinkedDoc), // createAnyDocument: new CreateAnyDocumentTool(addLinkedDoc), // dictionary: new DictionaryTool(), + documentMetadata: new DocumentMetadataTool(this), }; } @@ -459,6 +461,14 @@ export class Agent { } console.log(actionInput); + // Special handling for documentMetadata tool with numeric fieldValue + if (action === 'documentMetadata' && + 'fieldValue' in actionInput && + typeof actionInput.fieldValue === 'number') { + // Convert number to string to pass validation + actionInput.fieldValue = String(actionInput.fieldValue); + } + for (const param of this.tools[action].parameterRules) { // Check if the parameter is required and missing in the input if (param.required && !(param.name in actionInput) && !this.tools[action].inputValidator(actionInput)) { @@ -483,4 +493,19 @@ export class Agent { return await tool.execute(actionInput); } + + /** + * Reinitializes the DocumentMetadataTool with a direct reference to the ChatBox instance. + * This ensures that the tool can properly access the ChatBox document and find related documents. + * + * @param chatBox The ChatBox instance to pass to the DocumentMetadataTool + */ + public reinitializeDocumentMetadataTool(chatBox: any): void { + if (this.tools && this.tools.documentMetadata) { + this.tools.documentMetadata = new DocumentMetadataTool(chatBox); + console.log('Agent: Reinitialized DocumentMetadataTool with ChatBox instance'); + } else { + console.warn('Agent: Could not reinitialize DocumentMetadataTool - tool not found'); + } + } } |