🐛 fix(process.py): remove unnecessary session_id parameter in build_sorted_vertices function calls
🐛 fix(endpoints.py): remove unused import and type hinting to improve code readability and maintainability 🐛 fix(endpoints.py): fix incorrect import statement for TaskService 🐛 fix(endpoints.py): fix incorrect return value for get_task_status function ✨ feat(endpoints.py): add test case for async task processing to validate task completion and result
This commit is contained in:
parent
8d1bff38fe
commit
fa1ebea378
4 changed files with 63 additions and 10 deletions
|
|
@ -1,5 +1,5 @@
|
|||
from http import HTTPStatus
|
||||
from typing import TYPE_CHECKING, Annotated, Any, Optional, Union
|
||||
from typing import Annotated, Any, Optional, Union
|
||||
from langflow.services.auth.utils import api_key_security, get_current_active_user
|
||||
|
||||
|
||||
|
|
@ -33,8 +33,8 @@ from langflow.services.utils import get_session
|
|||
from langflow.worker import process_graph_cached_task
|
||||
from sqlmodel import Session
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langflow.services.task.manager import TaskService
|
||||
|
||||
from langflow.services.task.manager import TaskService
|
||||
|
||||
# build router
|
||||
router = APIRouter(tags=["Base"])
|
||||
|
|
@ -183,11 +183,17 @@ async def process_flow(
|
|||
async def get_task_status(task_id: str):
|
||||
task_service = get_task_service()
|
||||
task = task_service.get_task(task_id)
|
||||
result = None
|
||||
if task.ready():
|
||||
result = task.result
|
||||
if isinstance(result, dict) and "result" in result:
|
||||
result = result["result"]
|
||||
elif hasattr(result, "result"):
|
||||
result = result.result
|
||||
|
||||
if task is None:
|
||||
raise HTTPException(status_code=404, detail="Task not found")
|
||||
return TaskStatusResponse(
|
||||
status=task.status, result=task.result if task.ready() else None
|
||||
)
|
||||
return TaskStatusResponse(status=task.status, result=result)
|
||||
|
||||
|
||||
@router.post(
|
||||
|
|
|
|||
|
|
@ -94,13 +94,13 @@ def get_build_result(data_graph, session_id):
|
|||
# otherwise, build the graph and return the result
|
||||
if session_id:
|
||||
logger.debug(f"Loading LangChain object from session {session_id}")
|
||||
result = build_sorted_vertices(data_graph=data_graph, session_id=session_id)
|
||||
result = build_sorted_vertices(data_graph=data_graph)
|
||||
if result is not None:
|
||||
logger.debug("Loaded LangChain object")
|
||||
return result
|
||||
|
||||
logger.debug("Building langchain object")
|
||||
return build_sorted_vertices(data_graph, session_id)
|
||||
return build_sorted_vertices(data_graph)
|
||||
|
||||
|
||||
def load_langchain_object(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue