diff --git a/phi/playground/router.py b/phi/playground/router.py index 75ae001706..211115279c 100644 --- a/phi/playground/router.py +++ b/phi/playground/router.py @@ -554,8 +554,13 @@ async def run_workflow(workflow_id: str, body: WorkflowRunRequest): if workflow is None: raise HTTPException(status_code=404, detail="Workflow not found") + if body.session_id is not None: + logger.debug(f"Continuing session: {body.session_id}") + else: + logger.debug("Creating new session") + # Create a new instance of this workflow - new_workflow_instance = workflow.deep_copy(update={"workflow_id": workflow_id}) + new_workflow_instance = workflow.deep_copy(update={"workflow_id": workflow_id, "session_id": body.session_id}) new_workflow_instance.user_id = body.user_id # Return based on the response type diff --git a/phi/playground/schemas.py b/phi/playground/schemas.py index 7eb470ea41..660e210a1a 100644 --- a/phi/playground/schemas.py +++ b/phi/playground/schemas.py @@ -68,3 +68,4 @@ class WorkflowRenameRequest(BaseModel): class WorkflowRunRequest(BaseModel): input: Dict[str, Any] user_id: Optional[str] = None + session_id: Optional[str] = None diff --git a/phi/workflow/workflow.py b/phi/workflow/workflow.py index 668930813b..dccab8dac9 100644 --- a/phi/workflow/workflow.py +++ b/phi/workflow/workflow.py @@ -321,7 +321,9 @@ def __init__(self, **data): self._run_parameters = { name: { "name": name, - "default": param.default if param.default is not inspect.Parameter.empty else None, + "default": param.default.default + if hasattr(param.default, "__class__") and param.default.__class__.__name__ == "FieldInfo" + else (param.default if param.default is not inspect.Parameter.empty else None), "annotation": ( param.annotation.__name__ if hasattr(param.annotation, "__name__")