fixes workflow and chat object
This commit is contained in:
parent
90663963ff
commit
55fb23f7c0
5 changed files with 55 additions and 45 deletions
|
|
@ -730,6 +730,7 @@ class ActionplanMode(BaseMode):
|
||||||
def _updateWorkflowBeforeExecutingTask(self, taskNumber: int):
|
def _updateWorkflowBeforeExecutingTask(self, taskNumber: int):
|
||||||
"""Update workflow object before executing a task"""
|
"""Update workflow object before executing a task"""
|
||||||
try:
|
try:
|
||||||
|
workflow = self.services.workflow
|
||||||
updateData = {
|
updateData = {
|
||||||
"currentTask": taskNumber,
|
"currentTask": taskNumber,
|
||||||
"currentAction": 0,
|
"currentAction": 0,
|
||||||
|
|
@ -737,13 +738,13 @@ class ActionplanMode(BaseMode):
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update workflow object
|
# Update workflow object
|
||||||
self.workflow.currentTask = taskNumber
|
workflow.currentTask = taskNumber
|
||||||
self.workflow.currentAction = 0
|
workflow.currentAction = 0
|
||||||
self.workflow.totalActions = 0
|
workflow.totalActions = 0
|
||||||
|
|
||||||
# Update in database
|
# Update in database
|
||||||
self.services.interfaceDbChat.updateWorkflow(self.workflow.id, updateData)
|
self.services.interfaceDbChat.updateWorkflow(workflow.id, updateData)
|
||||||
logger.info(f"Updated workflow {self.workflow.id} before executing task {taskNumber}: {updateData}")
|
logger.info(f"Updated workflow {workflow.id} before executing task {taskNumber}: {updateData}")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error updating workflow before executing task: {str(e)}")
|
logger.error(f"Error updating workflow before executing task: {str(e)}")
|
||||||
|
|
@ -751,16 +752,17 @@ class ActionplanMode(BaseMode):
|
||||||
def _updateWorkflowAfterActionPlanning(self, totalActions: int):
|
def _updateWorkflowAfterActionPlanning(self, totalActions: int):
|
||||||
"""Update workflow object after action planning for current task"""
|
"""Update workflow object after action planning for current task"""
|
||||||
try:
|
try:
|
||||||
|
workflow = self.services.workflow
|
||||||
updateData = {
|
updateData = {
|
||||||
"totalActions": totalActions
|
"totalActions": totalActions
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update workflow object
|
# Update workflow object
|
||||||
self.workflow.totalActions = totalActions
|
workflow.totalActions = totalActions
|
||||||
|
|
||||||
# Update in database
|
# Update in database
|
||||||
self.services.interfaceDbChat.updateWorkflow(self.workflow.id, updateData)
|
self.services.interfaceDbChat.updateWorkflow(workflow.id, updateData)
|
||||||
logger.info(f"Updated workflow {self.workflow.id} after action planning: {updateData}")
|
logger.info(f"Updated workflow {workflow.id} after action planning: {updateData}")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error updating workflow after action planning: {str(e)}")
|
logger.error(f"Error updating workflow after action planning: {str(e)}")
|
||||||
|
|
@ -768,16 +770,17 @@ class ActionplanMode(BaseMode):
|
||||||
def _updateWorkflowBeforeExecutingAction(self, actionNumber: int):
|
def _updateWorkflowBeforeExecutingAction(self, actionNumber: int):
|
||||||
"""Update workflow object before executing an action"""
|
"""Update workflow object before executing an action"""
|
||||||
try:
|
try:
|
||||||
|
workflow = self.services.workflow
|
||||||
updateData = {
|
updateData = {
|
||||||
"currentAction": actionNumber
|
"currentAction": actionNumber
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update workflow object
|
# Update workflow object
|
||||||
self.workflow.currentAction = actionNumber
|
workflow.currentAction = actionNumber
|
||||||
|
|
||||||
# Update in database
|
# Update in database
|
||||||
self.services.interfaceDbChat.updateWorkflow(self.workflow.id, updateData)
|
self.services.interfaceDbChat.updateWorkflow(workflow.id, updateData)
|
||||||
logger.info(f"Updated workflow {self.workflow.id} before executing action {actionNumber}: {updateData}")
|
logger.info(f"Updated workflow {workflow.id} before executing action {actionNumber}: {updateData}")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error updating workflow before executing action: {str(e)}")
|
logger.error(f"Error updating workflow before executing action: {str(e)}")
|
||||||
|
|
@ -785,22 +788,23 @@ class ActionplanMode(BaseMode):
|
||||||
def _setWorkflowTotals(self, totalTasks: int = None, totalActions: int = None):
|
def _setWorkflowTotals(self, totalTasks: int = None, totalActions: int = None):
|
||||||
"""Set total counts for workflow progress tracking and update database"""
|
"""Set total counts for workflow progress tracking and update database"""
|
||||||
try:
|
try:
|
||||||
|
workflow = self.services.workflow
|
||||||
updateData = {}
|
updateData = {}
|
||||||
|
|
||||||
if totalTasks is not None:
|
if totalTasks is not None:
|
||||||
self.workflow.totalTasks = totalTasks
|
workflow.totalTasks = totalTasks
|
||||||
updateData["totalTasks"] = totalTasks
|
updateData["totalTasks"] = totalTasks
|
||||||
|
|
||||||
if totalActions is not None:
|
if totalActions is not None:
|
||||||
self.workflow.totalActions = totalActions
|
workflow.totalActions = totalActions
|
||||||
updateData["totalActions"] = totalActions
|
updateData["totalActions"] = totalActions
|
||||||
|
|
||||||
# Update workflow object in database if we have changes
|
# Update workflow object in database if we have changes
|
||||||
if updateData:
|
if updateData:
|
||||||
self.services.interfaceDbChat.updateWorkflow(self.workflow.id, updateData)
|
self.services.interfaceDbChat.updateWorkflow(workflow.id, updateData)
|
||||||
logger.info(f"Updated workflow {self.workflow.id} totals in database: {updateData}")
|
logger.info(f"Updated workflow {workflow.id} totals in database: {updateData}")
|
||||||
|
|
||||||
logger.debug(f"Updated workflow totals: Tasks {self.workflow.totalTasks if hasattr(self.workflow, 'totalTasks') else 'N/A'}, Actions {self.workflow.totalActions if hasattr(self.workflow, 'totalActions') else 'N/A'}")
|
logger.debug(f"Updated workflow totals: Tasks {workflow.totalTasks if hasattr(workflow, 'totalTasks') else 'N/A'}, Actions {workflow.totalActions if hasattr(workflow, 'totalActions') else 'N/A'}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error setting workflow totals: {str(e)}")
|
logger.error(f"Error setting workflow totals: {str(e)}")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -375,57 +375,61 @@ class AutomationMode(BaseMode):
|
||||||
def _updateWorkflowBeforeExecutingTask(self, taskNumber: int):
|
def _updateWorkflowBeforeExecutingTask(self, taskNumber: int):
|
||||||
"""Update workflow object before executing a task"""
|
"""Update workflow object before executing a task"""
|
||||||
try:
|
try:
|
||||||
|
workflow = self.services.workflow
|
||||||
updateData = {
|
updateData = {
|
||||||
"currentTask": taskNumber,
|
"currentTask": taskNumber,
|
||||||
"currentAction": 0,
|
"currentAction": 0,
|
||||||
"totalActions": 0
|
"totalActions": 0
|
||||||
}
|
}
|
||||||
|
|
||||||
self.workflow.currentTask = taskNumber
|
workflow.currentTask = taskNumber
|
||||||
self.workflow.currentAction = 0
|
workflow.currentAction = 0
|
||||||
self.workflow.totalActions = 0
|
workflow.totalActions = 0
|
||||||
|
|
||||||
self.services.interfaceDbChat.updateWorkflow(self.workflow.id, updateData)
|
self.services.interfaceDbChat.updateWorkflow(workflow.id, updateData)
|
||||||
logger.info(f"Updated workflow {self.workflow.id} before executing task {taskNumber}")
|
logger.info(f"Updated workflow {workflow.id} before executing task {taskNumber}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error updating workflow before executing task: {str(e)}")
|
logger.error(f"Error updating workflow before executing task: {str(e)}")
|
||||||
|
|
||||||
def _updateWorkflowAfterActionPlanning(self, totalActions: int):
|
def _updateWorkflowAfterActionPlanning(self, totalActions: int):
|
||||||
"""Update workflow object after action planning"""
|
"""Update workflow object after action planning"""
|
||||||
try:
|
try:
|
||||||
|
workflow = self.services.workflow
|
||||||
updateData = {"totalActions": totalActions}
|
updateData = {"totalActions": totalActions}
|
||||||
self.workflow.totalActions = totalActions
|
workflow.totalActions = totalActions
|
||||||
self.services.interfaceDbChat.updateWorkflow(self.workflow.id, updateData)
|
self.services.interfaceDbChat.updateWorkflow(workflow.id, updateData)
|
||||||
logger.info(f"Updated workflow {self.workflow.id} after action planning: {updateData}")
|
logger.info(f"Updated workflow {workflow.id} after action planning: {updateData}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error updating workflow after action planning: {str(e)}")
|
logger.error(f"Error updating workflow after action planning: {str(e)}")
|
||||||
|
|
||||||
def _updateWorkflowBeforeExecutingAction(self, actionNumber: int):
|
def _updateWorkflowBeforeExecutingAction(self, actionNumber: int):
|
||||||
"""Update workflow object before executing an action"""
|
"""Update workflow object before executing an action"""
|
||||||
try:
|
try:
|
||||||
|
workflow = self.services.workflow
|
||||||
updateData = {"currentAction": actionNumber}
|
updateData = {"currentAction": actionNumber}
|
||||||
self.workflow.currentAction = actionNumber
|
workflow.currentAction = actionNumber
|
||||||
self.services.interfaceDbChat.updateWorkflow(self.workflow.id, updateData)
|
self.services.interfaceDbChat.updateWorkflow(workflow.id, updateData)
|
||||||
logger.info(f"Updated workflow {self.workflow.id} before executing action {actionNumber}")
|
logger.info(f"Updated workflow {workflow.id} before executing action {actionNumber}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error updating workflow before executing action: {str(e)}")
|
logger.error(f"Error updating workflow before executing action: {str(e)}")
|
||||||
|
|
||||||
def _setWorkflowTotals(self, totalTasks: int = None, totalActions: int = None):
|
def _setWorkflowTotals(self, totalTasks: int = None, totalActions: int = None):
|
||||||
"""Set total counts for workflow progress tracking"""
|
"""Set total counts for workflow progress tracking"""
|
||||||
try:
|
try:
|
||||||
|
workflow = self.services.workflow
|
||||||
updateData = {}
|
updateData = {}
|
||||||
|
|
||||||
if totalTasks is not None:
|
if totalTasks is not None:
|
||||||
self.workflow.totalTasks = totalTasks
|
workflow.totalTasks = totalTasks
|
||||||
updateData["totalTasks"] = totalTasks
|
updateData["totalTasks"] = totalTasks
|
||||||
|
|
||||||
if totalActions is not None:
|
if totalActions is not None:
|
||||||
self.workflow.totalActions = totalActions
|
workflow.totalActions = totalActions
|
||||||
updateData["totalActions"] = totalActions
|
updateData["totalActions"] = totalActions
|
||||||
|
|
||||||
if updateData:
|
if updateData:
|
||||||
self.services.interfaceDbChat.updateWorkflow(self.workflow.id, updateData)
|
self.services.interfaceDbChat.updateWorkflow(workflow.id, updateData)
|
||||||
logger.info(f"Updated workflow {self.workflow.id} totals: {updateData}")
|
logger.info(f"Updated workflow {workflow.id} totals: {updateData}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error setting workflow totals: {str(e)}")
|
logger.error(f"Error setting workflow totals: {str(e)}")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -379,8 +379,8 @@ class DynamicMode(BaseMode):
|
||||||
}
|
}
|
||||||
|
|
||||||
# Build a synthetic ActionItem for execution routing and labels
|
# Build a synthetic ActionItem for execution routing and labels
|
||||||
currentRound = getattr(self.workflow, 'currentRound', 0)
|
currentRound = getattr(self.services.workflow, 'currentRound', 0)
|
||||||
currentTask = getattr(self.workflow, 'currentTask', 0)
|
currentTask = getattr(self.services.workflow, 'currentTask', 0)
|
||||||
resultLabel = f"round{currentRound}_task{currentTask}_action{stepIndex}_results"
|
resultLabel = f"round{currentRound}_task{currentTask}_action{stepIndex}_results"
|
||||||
|
|
||||||
taskAction = self._createActionItem({
|
taskAction = self._createActionItem({
|
||||||
|
|
@ -880,6 +880,7 @@ Return only the user-friendly message, no technical details."""
|
||||||
def _updateWorkflowBeforeExecutingTask(self, taskNumber: int):
|
def _updateWorkflowBeforeExecutingTask(self, taskNumber: int):
|
||||||
"""Update workflow object before executing a task"""
|
"""Update workflow object before executing a task"""
|
||||||
try:
|
try:
|
||||||
|
workflow = self.services.workflow
|
||||||
updateData = {
|
updateData = {
|
||||||
"currentTask": taskNumber,
|
"currentTask": taskNumber,
|
||||||
"currentAction": 0,
|
"currentAction": 0,
|
||||||
|
|
@ -887,13 +888,13 @@ Return only the user-friendly message, no technical details."""
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update workflow object
|
# Update workflow object
|
||||||
self.workflow.currentTask = taskNumber
|
workflow.currentTask = taskNumber
|
||||||
self.workflow.currentAction = 0
|
workflow.currentAction = 0
|
||||||
self.workflow.totalActions = 0
|
workflow.totalActions = 0
|
||||||
|
|
||||||
# Update in database
|
# Update in database
|
||||||
self.services.interfaceDbChat.updateWorkflow(self.workflow.id, updateData)
|
self.services.interfaceDbChat.updateWorkflow(workflow.id, updateData)
|
||||||
logger.info(f"Updated workflow {self.workflow.id} before executing task {taskNumber}: {updateData}")
|
logger.info(f"Updated workflow {workflow.id} before executing task {taskNumber}: {updateData}")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error updating workflow before executing task: {str(e)}")
|
logger.error(f"Error updating workflow before executing task: {str(e)}")
|
||||||
|
|
@ -901,16 +902,17 @@ Return only the user-friendly message, no technical details."""
|
||||||
def _updateWorkflowBeforeExecutingAction(self, actionNumber: int):
|
def _updateWorkflowBeforeExecutingAction(self, actionNumber: int):
|
||||||
"""Update workflow object before executing an action"""
|
"""Update workflow object before executing an action"""
|
||||||
try:
|
try:
|
||||||
|
workflow = self.services.workflow
|
||||||
updateData = {
|
updateData = {
|
||||||
"currentAction": actionNumber
|
"currentAction": actionNumber
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update workflow object
|
# Update workflow object
|
||||||
self.workflow.currentAction = actionNumber
|
workflow.currentAction = actionNumber
|
||||||
|
|
||||||
# Update in database
|
# Update in database
|
||||||
self.services.interfaceDbChat.updateWorkflow(self.workflow.id, updateData)
|
self.services.interfaceDbChat.updateWorkflow(workflow.id, updateData)
|
||||||
logger.info(f"Updated workflow {self.workflow.id} before executing action {actionNumber}: {updateData}")
|
logger.info(f"Updated workflow {workflow.id} before executing action {actionNumber}: {updateData}")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error updating workflow before executing action: {str(e)}")
|
logger.error(f"Error updating workflow before executing action: {str(e)}")
|
||||||
|
|
|
||||||
|
|
@ -469,7 +469,7 @@ def extractAvailableDocumentsIndex(service: Any, context: Any) -> str:
|
||||||
def extractAvailableConnectionsSummary(service: Any) -> str:
|
def extractAvailableConnectionsSummary(service: Any) -> str:
|
||||||
"""Summary of available connections (count only)."""
|
"""Summary of available connections (count only)."""
|
||||||
try:
|
try:
|
||||||
connections = service.workflow.getConnectionReferenceList()
|
connections = service.chat.getConnectionReferenceList()
|
||||||
if connections:
|
if connections:
|
||||||
return f"{len(connections)} connections available"
|
return f"{len(connections)} connections available"
|
||||||
return "No connections available"
|
return "No connections available"
|
||||||
|
|
@ -480,7 +480,7 @@ def extractAvailableConnectionsSummary(service: Any) -> str:
|
||||||
def extractAvailableConnectionsIndex(service: Any) -> str:
|
def extractAvailableConnectionsIndex(service: Any) -> str:
|
||||||
"""Index of available connections with detailed references for parameter generation."""
|
"""Index of available connections with detailed references for parameter generation."""
|
||||||
try:
|
try:
|
||||||
connections = service.workflow.getConnectionReferenceList()
|
connections = service.chat.getConnectionReferenceList()
|
||||||
if connections:
|
if connections:
|
||||||
return '\n'.join(f"- {conn}" for conn in connections)
|
return '\n'.join(f"- {conn}" for conn in connections)
|
||||||
return "No connections available"
|
return "No connections available"
|
||||||
|
|
|
||||||
|
|
@ -151,8 +151,8 @@ class WorkflowManager:
|
||||||
|
|
||||||
self.workflowProcessor = WorkflowProcessor(self.services)
|
self.workflowProcessor = WorkflowProcessor(self.services)
|
||||||
await self._sendFirstMessage(userInput)
|
await self._sendFirstMessage(userInput)
|
||||||
task_plan = await self._planTasks(userInput)
|
taskPlan = await self._planTasks(userInput)
|
||||||
await self._executeTasks(task_plan)
|
await self._executeTasks(taskPlan)
|
||||||
await self._processWorkflowResults()
|
await self._processWorkflowResults()
|
||||||
|
|
||||||
except WorkflowStoppedException:
|
except WorkflowStoppedException:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue