diff --git a/src/backend/langflow/api/v1/endpoints.py b/src/backend/langflow/api/v1/endpoints.py index f03c4990a..e6bb08a12 100644 --- a/src/backend/langflow/api/v1/endpoints.py +++ b/src/backend/langflow/api/v1/endpoints.py @@ -3,7 +3,6 @@ from langflow.processing.process import process_graph_cached, process_tweaks from langflow.utils.logger import logger from fastapi import APIRouter, Depends, HTTPException -from fastapi.security import HTTPBearer from langflow.api.v1.schemas import ( PredictRequest, @@ -17,20 +16,6 @@ from sqlmodel import Session # build router router = APIRouter(tags=["Base"]) -security = HTTPBearer() - - -def get_flow_from_token( - bearer: HTTPBearer = Depends(security), session: Session = Depends(get_session) -) -> str: - # Extract the token, which is the flow_id in this case - flow_id = bearer.credentials - # Check if the flow_id exists in the database - flow = session.get(Flow, flow_id) - if flow is None: - raise HTTPException(status_code=401, detail="Invalid token") - return flow - @router.get("/all") def get_all(): @@ -51,6 +36,9 @@ async def predict_flow( flow = session.get(Flow, flow_id) if flow is None: raise ValueError(f"Flow {flow_id} not found") + + if flow.data is None: + raise ValueError(f"Flow {flow_id} has no data") graph_data = flow.data if predict_request.tweaks: graph_data = process_tweaks(graph_data, predict_request.tweaks) diff --git a/src/backend/langflow/processing/process.py b/src/backend/langflow/processing/process.py index ae0bf28b1..deabe34dc 100644 --- a/src/backend/langflow/processing/process.py +++ b/src/backend/langflow/processing/process.py @@ -172,7 +172,7 @@ def load_flow_from_json(path: str, build=True): return graph -def process_tweaks(graph_data: dict, tweaks: dict): +def process_tweaks(graph_data: Dict, tweaks: Dict): """This function is used to tweak the graph data using the node id and the tweaks dict""" # the tweaks dict is a dict of dicts # the key is the node id and the value is a dict of the tweaks