Fix task status handling and update custom

component field
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-11-28 14:34:50 -03:00
commit e08843485f

View file

@ -160,6 +160,10 @@ async def get_task_status(task_id: str):
result = None
if task.ready():
result = task.result
# If result isinstance of Exception, can we get the traceback?
if isinstance(result, Exception):
logger.exception(task.traceback)
if isinstance(result, dict) and "result" in result:
result = result["result"]
elif hasattr(result, "result"):
@ -167,6 +171,10 @@ async def get_task_status(task_id: str):
if task is None:
raise HTTPException(status_code=404, detail="Task not found")
if task.status == "FAILURE":
result = str(task.result)
logger.error(f"Task {task_id} failed: {task.traceback}")
return TaskStatusResponse(status=task.status, result=result)
@ -237,3 +245,7 @@ async def custom_component_update(
component_node = build_langchain_template_custom_component(component, user_id=user.id, update_field=raw_code.field)
# Update the field
return component_node
# Update the field
return component_node
# Update the field
return component_node