From aa854f27b734baf9390459a61fb21e5181c3d879 Mon Sep 17 00:00:00 2001 From: ValueOn AG Date: Tue, 8 Jul 2025 15:35:03 +0200 Subject: [PATCH] doc ref fixed --- modules/workflow/managerChat.py | 193 ++++++++++----------------- modules/workflow/serviceContainer.py | 31 +++-- 2 files changed, 90 insertions(+), 134 deletions(-) diff --git a/modules/workflow/managerChat.py b/modules/workflow/managerChat.py index a5e31b92..d8674429 100644 --- a/modules/workflow/managerChat.py +++ b/modules/workflow/managerChat.py @@ -433,8 +433,8 @@ class ChatManager: # Validate result label format result_label = action.get('resultLabel', '') - if not result_label.startswith('docList:'): - logger.error(f"Action {i} result label must start with 'docList:': {result_label}") + if not result_label.startswith('task'): + logger.error(f"Action {i} result label must start with 'task': {result_label}") return False # Validate parameters @@ -467,10 +467,10 @@ class ChatManager: "method": "document", "action": "analyze", "parameters": { - "fileId": doc, - "analysis": ["entities", "topics", "sentiment"] + "documentList": ["task1_previous_results"], + "aiPrompt": "Fallback document analysis for " + doc }, - "resultLabel": f"docList:fallback:{task_step.get('id', 'unknown')}:{i}:analysis", + "resultLabel": "task1_fallback:" + doc + ":analysis", "description": f"Fallback document analysis for {doc}" }) @@ -520,8 +520,14 @@ NOTE: Respond with ONLY the JSON object. Do not include any explanatory text.""" previous_results = context['previous_results'] improvements = context.get('improvements', '') - # Get available methods + # Get available methods and actions with signatures methodList = self.service.getMethodsList() + method_actions = {} + for sig in methodList: + if '.' in sig: + method, rest = sig.split('.', 1) + action = rest.split('(')[0] + method_actions.setdefault(method, []).append((action, sig)) # Get workflow history messageSummary = await self.service.summarizeChat(workflow.messages) @@ -529,127 +535,80 @@ NOTE: Respond with ONLY the JSON object. Do not include any explanatory text.""" # Get available documents and connections docRefs = self.service.getDocumentReferenceList() connRefs = self.service.getConnectionReferenceList() + all_doc_refs = docRefs.get('chat', []) + docRefs.get('history', []) - return f"""You are an action generation AI that creates specific actions to accomplish a task step. + # Build AVAILABLE METHODS section + available_methods_str = '' + for method, actions in method_actions.items(): + available_methods_str += f"- {method}:\n" + for action, sig in actions: + available_methods_str += f" - {action}: {sig}\n" + + return f""" +You are an action generation AI that creates specific actions to accomplish a task step. -TASK STEP: {task_step.get('description', 'Unknown')} -TASK ID: {task_step.get('id', 'Unknown')} +DOCUMENT REFERENCE TYPES: +- docItem: Reference to a single document. Format: "docItem::" +- docList: Reference to a group of documents under a label. Format: