aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/chatbot/agentsystem/Agent.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/chatbot/agentsystem/Agent.ts')
-rw-r--r--src/client/views/nodes/chatbot/agentsystem/Agent.ts25
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');
+ }
+ }
}