discard old approach

This commit is contained in:
italojohnny 2024-06-21 08:20:30 -03:00 committed by Gabriel Luiz Freitas Almeida
commit 55806ed293
2 changed files with 3 additions and 20 deletions

View file

@ -1,10 +1,8 @@
import uuid
import asyncio
import warnings
from pathlib import Path
from typing import TYPE_CHECKING, Optional
from fastapi import HTTPException, Request
from fastapi import HTTPException
from platformdirs import user_cache_dir
from sqlmodel import Session
@ -327,9 +325,4 @@ def parse_exception(exc):
if hasattr(exc, "body"):
return exc.body["message"]
return str(exc)
async def check_client_disconnection(request: Request):
while not await request.is_disconnected():
await asyncio.sleep(1)
raise HTTPException(status_code=499, detail="Client disconnected")
return str(exc)

View file

@ -4,7 +4,7 @@ import uuid
from functools import partial
from typing import TYPE_CHECKING, Annotated, Optional
from fastapi import APIRouter, BackgroundTasks, Body, Depends, HTTPException, Request
from fastapi import APIRouter, BackgroundTasks, Body, Depends, HTTPException
from fastapi.responses import StreamingResponse
from loguru import logger
@ -15,7 +15,6 @@ from langflow.api.utils import (
format_exception_message,
get_top_level_vertices,
parse_exception,
check_client_disconnection,
)
from langflow.api.v1.schemas import (
FlowDataRequest,
@ -59,8 +58,6 @@ async def try_running_celery_task(vertex, user_id):
@router.post("/build/{flow_id}/vertices", response_model=VerticesOrderResponse)
async def retrieve_vertices_order(
flow_id: uuid.UUID,
background_tasks: BackgroundTasks,
request: Request,
data: Optional[Annotated[Optional[FlowDataRequest], Body(embed=True)]] = None,
stop_component_id: Optional[str] = None,
start_component_id: Optional[str] = None,
@ -84,7 +81,6 @@ async def retrieve_vertices_order(
Raises:
HTTPException: If there is an error checking the build status.
"""
background_tasks.add_task(check_client_disconnection, request)
try:
flow_id_str = str(flow_id)
# First, we need to check if the flow_id is in the cache
@ -130,7 +126,6 @@ async def build_vertex(
flow_id: uuid.UUID,
vertex_id: str,
background_tasks: BackgroundTasks,
request: Request,
inputs: Annotated[Optional[InputValueRequest], Body(embed=True)] = None,
files: Optional[list[str]] = None,
chat_service: "ChatService" = Depends(get_chat_service),
@ -153,8 +148,6 @@ async def build_vertex(
HTTPException: If there is an error building the vertex.
"""
background_tasks.add_task(check_client_disconnection, request)
flow_id_str = str(flow_id)
next_runnable_vertices = []
@ -272,8 +265,6 @@ async def build_vertex(
async def build_vertex_stream(
flow_id: uuid.UUID,
vertex_id: str,
background_tasks: BackgroundTasks,
request: Request,
session_id: Optional[str] = None,
chat_service: "ChatService" = Depends(get_chat_service),
session_service: "SessionService" = Depends(get_session_service),
@ -303,7 +294,6 @@ async def build_vertex_stream(
Raises:
HTTPException: If an error occurs while building the vertex.
"""
background_tasks.add_task(check_client_disconnection, request)
try:
flow_id_str = str(flow_id)