chat round counting per workflow
This commit is contained in:
parent
efd5736910
commit
acb866163c
2 changed files with 38 additions and 23 deletions
|
|
@ -65,8 +65,14 @@ class HandlingTasks:
|
|||
logger.info(f"User Input: {userInput}")
|
||||
available_docs = self.service.getAvailableDocuments(workflow)
|
||||
|
||||
# Set initial workflow context
|
||||
self.service.setWorkflowContext(round_number=1, task_number=0, action_number=0)
|
||||
# Set initial workflow context - increment round if this is a new workflow
|
||||
current_round = getattr(workflow, 'currentRound', 0)
|
||||
if current_round == 0:
|
||||
# First time workflow, start with round 1
|
||||
self.service.setWorkflowContext(round_number=1, task_number=0, action_number=0)
|
||||
else:
|
||||
# Existing workflow, increment to next round
|
||||
self.service.incrementWorkflowContext('round')
|
||||
|
||||
# Check workflow status before calling AI service
|
||||
self._checkWorkflowStopped()
|
||||
|
|
|
|||
|
|
@ -148,6 +148,11 @@ Previous review feedback:
|
|||
# Get user language from service - this is the correct way
|
||||
user_language = service.user.language if service and service.user else 'en'
|
||||
|
||||
# Get current workflow context for dynamic examples
|
||||
workflow_context = service.getWorkflowContext()
|
||||
current_round = workflow_context.get('currentRound', 1)
|
||||
current_task = workflow_context.get('currentTask', 1)
|
||||
|
||||
prompt = f"""
|
||||
You are an action generation AI that creates specific actions to accomplish a task step with user-friendly messages.
|
||||
|
||||
|
|
@ -159,13 +164,18 @@ DOCUMENT REFERENCE TYPES:
|
|||
USAGE GUIDE:
|
||||
- Use docItem when you need a specific document: "docItem:doc_123:component_diagram.pdf"
|
||||
- Use docList when you need all documents in a group: "docList:msg_456:AnalysisResults"
|
||||
- Use round/task/action format when referencing outputs from previous actions: "round1_task1_action2_AnalysisResults"
|
||||
- Use round/task/action format when referencing outputs from previous actions: "round{current_round}_task{current_task}_action2_AnalysisResults"
|
||||
|
||||
CRITICAL DOCUMENT REFERENCE RULES:
|
||||
- ONLY use the exact labels listed in AVAILABLE DOCUMENTS below, or result labels from previous actions
|
||||
- When generating multiple actions, you may only use as input documents those that are already present in AVAILABLE DOCUMENTS or produced by actions that come earlier in the list. Do NOT use as input any document label that will be produced by a later action.
|
||||
- If AVAILABLE DOCUMENTS shows "NO DOCUMENTS AVAILABLE", you CANNOT create document extraction actions. Instead, create actions that generate new content or inform the user that documents are needed, if you miss something.
|
||||
|
||||
CURRENT WORKFLOW CONTEXT:
|
||||
- Current Round: {current_round}
|
||||
- Current Task: {current_task}
|
||||
- Use these values when creating resultLabel references
|
||||
|
||||
TASK STEP: {context.task_step.objective if context.task_step else 'No task step specified'} (ID: {context.task_step.id if context.task_step else 'unknown'})
|
||||
|
||||
SUCCESS CRITERIA: {success_criteria_str}
|
||||
|
|
@ -179,7 +189,6 @@ The following summarizes key information from previous workflow interactions to
|
|||
- Key decisions and findings from earlier tasks
|
||||
- Document processing results and insights
|
||||
- User preferences and requirements established
|
||||
- Any constraints or limitations identified
|
||||
|
||||
This context helps ensure your actions build upon previous work and maintain consistency with the overall workflow objectives.
|
||||
|
||||
|
|
@ -196,7 +205,7 @@ DOCUMENT REFERENCE EXAMPLES:
|
|||
✅ CORRECT: Use exact references from AVAILABLE DOCUMENTS above or result labels from previous actions
|
||||
- "docList:msg_456:diagram_analysis_results" (access all documents in a list)
|
||||
- "docItem:doc_123:component_diagram.pdf" (access specific document)
|
||||
- "round1_task2_action3_contextinfo" (document list from previous action)
|
||||
- "round{current_round}_task{current_task}_action3_contextinfo" (document list from previous action)
|
||||
|
||||
❌ INCORRECT: These will cause errors
|
||||
- "msg_xxx:documents" (invalid format - missing docList/docItem prefix)
|
||||
|
|
@ -229,7 +238,7 @@ USER LANGUAGE: {user_language} - All user messages must be generated in this lan
|
|||
|
||||
DOCUMENT ROUTING GUIDANCE:
|
||||
- Each action should produce documents with a clear resultLabel for routing
|
||||
- Use consistent naming: "round{{round_number}}_task{{task_id}}_action{{action_number}}_{{descriptive_label}}"
|
||||
- Use consistent naming: "round{current_round}_task{{task_id}}_action{{action_number}}_{{descriptive_label}}"
|
||||
- Ensure document flow: Action A produces documents that Action B can consume
|
||||
- Document labels should be descriptive of content, not just "results" or "output"
|
||||
- Consider what subsequent actions will need and structure outputs accordingly
|
||||
|
|
@ -240,12 +249,12 @@ INSTRUCTIONS:
|
|||
- If AVAILABLE DOCUMENTS shows "NO DOCUMENTS AVAILABLE", you cannot create document extraction actions. Instead, create actions that generate new content or inform the user that documents are needed.
|
||||
- Always pass documentList as a LIST of references (docItem and/or docList) - this list CANNOT be empty for document extraction actions
|
||||
- For referencing documents from previous actions, use the format "round{{round_number}}_task{{task_number}}_action{{action_number}}_{{context}}"
|
||||
- For resultLabel, use the format: "round{{round_number}}_task{{task_id}}_action{{action_number}}_{{short_label}}" where:
|
||||
- {{round_number}} = the current round number (e.g., 1)
|
||||
- {{task_id}} = the current task's id (e.g., 1)
|
||||
- {{action_number}} = the sequence number of the action within the task (e.g., 2)
|
||||
- For resultLabel, use the format: "round{current_round}_task{{task_id}}_action{{action_number}}_{{short_label}}" where:
|
||||
- {{round_number}} = the current round number ({current_round})
|
||||
- {{task_id}} = the current task's id ({current_task})
|
||||
- {{action_number}} = the sequence number of the action within the task (e.g., 1, 2, 3)
|
||||
- {{short_label}} = a short, descriptive label for the output (e.g., "AnalysisResults")
|
||||
Example: "round1_task1_action2_AnalysisResults"
|
||||
Example: "round{current_round}_task{current_task}_action1_AnalysisResults"
|
||||
- If this is a retry, ensure the new actions address the specific issues from previous attempts
|
||||
- Follow the JSON structure below. All fields are required.
|
||||
|
||||
|
|
@ -256,10 +265,10 @@ REQUIRED JSON STRUCTURE:
|
|||
"method": "method_name", // Use only the method name (e.g., "document")
|
||||
"action": "action_name", // Use only the action name (e.g., "extract")
|
||||
"parameters": {{
|
||||
"documentList": ["docItem:doc_abc:round1_task1_action2_AnalysisResults", "round1_task1_action1_input"],
|
||||
"documentList": ["docItem:doc_abc:round{current_round}_task{current_task}_action1_AnalysisResults", "round{current_round}_task{current_task}_action1_input"],
|
||||
"aiPrompt": "Comprehensive AI prompt describing what to accomplish"
|
||||
}},
|
||||
"resultLabel": "round1_task1_action3_AnalysisResults",
|
||||
"resultLabel": "round{current_round}_task{current_task}_action2_AnalysisResults",
|
||||
"expectedDocumentFormats": [ // OPTIONAL: Specify expected document formats when needed
|
||||
{{
|
||||
"extension": ".txt",
|
||||
|
|
@ -277,7 +286,7 @@ FIELD REQUIREMENTS:
|
|||
- "method": Must be from AVAILABLE METHODS
|
||||
- "action": Must be valid for the method
|
||||
- "parameters": Method-specific, must include documentList as a list if required by the signature
|
||||
- "resultLabel": Must follow the format above (e.g., "round1_task1_action3_AnalysisResults")
|
||||
- "resultLabel": Must follow the format above (e.g., "round{current_round}_task{current_task}_action3_AnalysisResults")
|
||||
- "expectedDocumentFormats": OPTIONAL - Only specify when you need to control output format
|
||||
- Use when you need specific file types (e.g., CSV for data, JSON for structured output)
|
||||
- Omit when format is flexible (e.g., folder queries with mixed file types)
|
||||
|
|
@ -296,7 +305,7 @@ EXAMPLES OF GOOD ACTIONS:
|
|||
"documentList": ["docItem:doc_57520394-6b6d-41c2-b641-bab3fc6d7f4b:candidate_profile.txt"],
|
||||
"aiPrompt": "Extract and analyze the candidate's qualifications, experience, skills, and suitability for the product designer position. Identify key strengths, relevant experience, technical skills, and any areas of concern. Provide a comprehensive assessment that can be used for evaluation."
|
||||
}},
|
||||
"resultLabel": "round1_task1_action2_candidate_analysis",
|
||||
"resultLabel": "round{current_round}_task{current_task}_action2_candidate_analysis",
|
||||
"expectedDocumentFormats": [
|
||||
{{
|
||||
"extension": ".json",
|
||||
|
|
@ -316,7 +325,7 @@ EXAMPLES OF GOOD ACTIONS:
|
|||
"documentList": ["docList:msg_456:candidate_analysis_results"],
|
||||
"aiPrompt": "Compare all candidate profiles and create an evaluation matrix. Rate each candidate on technical skills, experience level, cultural fit, portfolio quality, and communication skills. Provide clear rankings and recommendations for the product designer position."
|
||||
}},
|
||||
"resultLabel": "round1_task1_action5_evaluation_matrix",
|
||||
"resultLabel": "round{current_round}_task{current_task}_action5_evaluation_matrix",
|
||||
"description": "Create comprehensive evaluation matrix comparing all candidates",
|
||||
"userMessage": "Ich vergleiche alle Kandidatenprofile und erstelle eine umfassende Bewertungsmatrix mit klaren Empfehlungen."
|
||||
}}
|
||||
|
|
@ -329,7 +338,7 @@ EXAMPLES OF GOOD ACTIONS:
|
|||
"documentList": ["docItem:doc_abc:table_data.pdf"],
|
||||
"aiPrompt": "Extract all table data and convert to structured CSV format with proper headers and data types. IMPORTANT: Deliver pure CSV data without any markdown formatting, code blocks, or additional text. Output only the CSV content with proper headers and data rows."
|
||||
}},
|
||||
"resultLabel": "round1_task1_action2_structured_data",
|
||||
"resultLabel": "round{current_round}_task{current_task}_action2_structured_data",
|
||||
"expectedDocumentFormats": [
|
||||
{{
|
||||
"extension": ".csv",
|
||||
|
|
@ -349,7 +358,7 @@ EXAMPLES OF GOOD ACTIONS:
|
|||
"documentList": ["docList:msg_456:candidate_analysis_results"],
|
||||
"title": "Comprehensive Candidate Evaluation Report"
|
||||
}},
|
||||
"resultLabel": "round1_task1_action6_summary_report",
|
||||
"resultLabel": "round{current_round}_task{current_task}_action6_summary_report",
|
||||
"description": "Generate a comprehensive, professional HTML report consolidating all candidate analyses and findings",
|
||||
"userMessage": "Ich erstelle einen umfassenden, professionellen Bericht, der alle Kandidatenanalysen und Erkenntnisse zusammenfasst."
|
||||
}}
|
||||
|
|
@ -361,10 +370,10 @@ EXAMPLES OF GOOD ACTIONS:
|
|||
"method": "document",
|
||||
"action": "extract",
|
||||
"parameters": {{
|
||||
"documentList": ["docItem:doc_abc:round1_task1_action1_file1.txt"],
|
||||
"documentList": ["docItem:doc_abc:round{current_round}_task{current_task}_action1_file1.txt"],
|
||||
"aiPrompt": "Extract data from file1."
|
||||
}},
|
||||
"resultLabel": "round1_task1_action1_extracted_data",
|
||||
"resultLabel": "round{current_round}_task{current_task}_action1_extracted_data",
|
||||
"description": "Extract data from file1.",
|
||||
"userMessage": "Ich extrahiere die Daten aus der Datei."
|
||||
}},
|
||||
|
|
@ -372,10 +381,10 @@ EXAMPLES OF GOOD ACTIONS:
|
|||
"method": "document",
|
||||
"action": "generateReport",
|
||||
"parameters": {{
|
||||
"documentList": ["round1_task1_action1_extracted_data"],
|
||||
"documentList": ["round{current_round}_task{current_task}_action1_extracted_data"],
|
||||
"title": "Report"
|
||||
}},
|
||||
"resultLabel": "round1_task1_action2_report",
|
||||
"resultLabel": "round{current_round}_task{current_task}_action2_report",
|
||||
"description": "Generate report from extracted data.",
|
||||
"userMessage": "Ich erstelle einen Bericht basierend auf den extrahierten Daten."
|
||||
}}
|
||||
|
|
@ -390,7 +399,7 @@ EXAMPLES OF GOOD ACTIONS:
|
|||
"documentList": [],
|
||||
"title": "Workflow Status Report"
|
||||
}},
|
||||
"resultLabel": "round1_task1_action1_status_report",
|
||||
"resultLabel": "round{current_round}_task{current_task}_action1_status_report",
|
||||
"description": "Generate a status report informing the user that no documents are available for processing and requesting document upload or alternative input.",
|
||||
"userMessage": "Ich erstelle einen Statusbericht, der Sie darüber informiert, dass keine Dokumente zur Verarbeitung verfügbar sind und um Dokumente oder alternative Eingaben bittet."
|
||||
}}
|
||||
|
|
|
|||
Loading…
Reference in a new issue