From a721a3f364eb7bbdc54c5e396bb15c051f4b83b7 Mon Sep 17 00:00:00 2001 From: ValueOn AG Date: Sat, 12 Jul 2025 22:59:53 +0200 Subject: [PATCH] chat system test --- modules/chat/managerChat.py | 20 ++++++++++---------- modules/chat/serviceCenter.py | 20 +++++++++++++++++++- notes/methodbased_specification.md | 4 ++-- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/modules/chat/managerChat.py b/modules/chat/managerChat.py index 1598c27a..32b48eb4 100644 --- a/modules/chat/managerChat.py +++ b/modules/chat/managerChat.py @@ -1828,14 +1828,14 @@ NOTE: Respond with ONLY the JSON object. Do not include any explanatory text.""" # Only consider empty results a problem if there are no documents produced has_empty_results = any( not result.data.get('result', '').strip() and - not result.documents and - not result.documents + not result.data.get('documents') and + not result.data.get('documents') for result in action_results if result.success ) has_incomplete_metadata = any( - any(doc.get('filename') == 'unknown' for doc in result.documents or []) + any(doc.get('filename') == 'unknown' for doc in result.data.get('documents', []) or []) for result in action_results if result.success ) @@ -2351,9 +2351,9 @@ Please review the task requirements and try again with different input or approa # Add action completion message with result documents documents_info = "" - if result.documents and len(result.documents) > 0: - doc_names = [doc.filename if hasattr(doc, 'filename') else f"Document {j+1}" - for j, doc in enumerate(result.documents)] + if result.data.get("documents") and len(result.data.get("documents", [])) > 0: + doc_names = [doc.get('filename', f"Document {j+1}") if isinstance(doc, dict) else (doc.filename if hasattr(doc, 'filename') else f"Document {j+1}") + for j, doc in enumerate(result.data.get("documents", []))] documents_info = f"\nšŸ“„ Generated documents: {', '.join(doc_names)}" # Create completion message @@ -2390,9 +2390,9 @@ Please review the task requirements and try again with different input or approa # Add retry success log retry_documents_info = "" - if retry_result.documents and len(retry_result.documents) > 0: - doc_names = [doc.filename if hasattr(doc, 'filename') else f"Document {j+1}" - for j, doc in enumerate(retry_result.documents)] + if retry_result.data.get("documents") and len(retry_result.data.get("documents", [])) > 0: + doc_names = [doc.get('filename', f"Document {j+1}") if isinstance(doc, dict) else (doc.filename if hasattr(doc, 'filename') else f"Document {j+1}") + for j, doc in enumerate(retry_result.data.get("documents", []))] retry_documents_info = f"\nšŸ“„ Generated documents: {', '.join(doc_names)}" self.chatInterface.createWorkflowLog({ @@ -2790,7 +2790,7 @@ NOTE: Respond with ONLY the JSON object. Do not include any explanatory text.""" logger.info(f"Action {action.execMethod}.{action.execAction} validated successfully") # Only create action message if documents were produced - if result.documents and len(result.documents) > 0: + if result.data.get("documents") and len(result.data.get("documents", [])) > 0: await self._createActionMessage(action, result, workflow, action.execResultLabel) else: # Add validation success log instead of message diff --git a/modules/chat/serviceCenter.py b/modules/chat/serviceCenter.py index 3f48cbce..ebbac586 100644 --- a/modules/chat/serviceCenter.py +++ b/modules/chat/serviceCenter.py @@ -388,8 +388,26 @@ class ServiceCenter: for doc_ref in documentList: # Parse reference format parts = doc_ref.split(':', 2) # Split into max 3 parts - if len(parts) < 3: + + # Handle simple label format (e.g., "task1_action2_webpage_content") + if len(parts) == 1: + # Simple label - try to find documents by label + label = parts[0] + found = False + for message in self.workflow.messages: + if message.documentsLabel == label and message.documents: + all_documents.extend(message.documents) + found = True + break + if not found: + logger.warning(f"No documents found for label: {label}") continue + + # Handle structured reference format + if len(parts) < 3: + logger.warning(f"Invalid document reference format: {doc_ref}") + continue + ref_type = parts[0] ref_id = parts[1] ref_label = parts[2] diff --git a/notes/methodbased_specification.md b/notes/methodbased_specification.md index dd2e590f..22c5ac89 100644 --- a/notes/methodbased_specification.md +++ b/notes/methodbased_specification.md @@ -862,7 +862,7 @@ gateway/ │ │ ā”œā”€ā”€ managerChat.py # Chat management and AI response validation │ │ ā”œā”€ā”€ managerPrompt.py # AI prompt generation and management │ │ ā”œā”€ā”€ methodBase.py # Base method class with result validation -│ │ └── processorDocument.py # Document content extraction +│ │ └── documentExtraction.py # Document content extraction │ │ │ ā”œā”€ā”€ agents/ # To be refactored into methods │ │ ā”œā”€ā”€ agentSharepoint.py → methods/methodSharepoint.py @@ -889,7 +889,7 @@ gateway/ #### Phase 1: Core Structure Setup 1. **File Renaming and Organization** - Rename manager files to follow `manager*.py` pattern - - Move document processor to `processorDocument.py` + - Move document processor to `documentExtraction.py` - Create new `methods` directory 2. **Model Updates**