aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/chatbot/agentsystem
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/chatbot/agentsystem')
-rw-r--r--src/client/views/nodes/chatbot/agentsystem/Agent.ts25
-rw-r--r--src/client/views/nodes/chatbot/agentsystem/prompts.ts4
2 files changed, 27 insertions, 2 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');
+ }
+ }
}
diff --git a/src/client/views/nodes/chatbot/agentsystem/prompts.ts b/src/client/views/nodes/chatbot/agentsystem/prompts.ts
index dda6d44ef..e551ef830 100644
--- a/src/client/views/nodes/chatbot/agentsystem/prompts.ts
+++ b/src/client/views/nodes/chatbot/agentsystem/prompts.ts
@@ -210,7 +210,7 @@ export function getReactPrompt(tools: BaseTool<ReadonlyArray<Parameter>>[], summ
<answer>
<grounded_text citation_index="1">**The 2022 World Cup** saw Argentina crowned champions, with **Lionel Messi** leading his team to victory, marking a historic moment in sports.</grounded_text>
<grounded_text citation_index="2">**Qatar** experienced a **40% increase in tourism** during the World Cup, welcoming over **1.5 million visitors**, significantly boosting its economy.</grounded_text>
- <normal_text>Moments like **Messi’s triumph** often become ingrained in the legacy of World Cups, immortalizing these tournaments in both sports and cultural memory. The **long-term implications** of the World Cup on Qatar's **economy, tourism**, and **global image** remain important areas of interest as the country continues to build on the momentum generated by hosting this prestigious event.</normal_text>
+ <normal_text>Moments like **Messi's triumph** often become ingrained in the legacy of World Cups, immortalizing these tournaments in both sports and cultural memory. The **long-term implications** of the World Cup on Qatar's **economy, tourism**, and **global image** remain important areas of interest as the country continues to build on the momentum generated by hosting this prestigious event.</normal_text>
<citations>
<citation index="1" chunk_id="1234" type="text">Key moments from the 2022 World Cup.</citation>
<citation index="2" chunk_id="5678" type="url"></citation>
@@ -218,7 +218,7 @@ export function getReactPrompt(tools: BaseTool<ReadonlyArray<Parameter>>[], summ
<follow_up_questions>
<question>What long-term effects has the World Cup had on Qatar's economy and infrastructure?</question>
<question>Can you compare Qatar's tourism numbers with previous World Cup hosts?</question>
- <question>How has Qatar’s image on the global stage evolved post-World Cup?</question>
+ <question>How has Qatar's image on the global stage evolved post-World Cup?</question>
</follow_up_questions>
<loop_summary>
The assistant first used the RAG tool to extract key moments from the user documents about the 2022 World Cup. Then, the assistant utilized the website scraping tool to gather data on Qatar's tourism impact. Both tools provided valuable information, and no additional tools were needed.