Add validate_is_component function to read_flows

This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-12-01 17:54:15 -03:00
commit e8830901ab

View file

@ -7,7 +7,7 @@ from fastapi import APIRouter, Depends, File, HTTPException, UploadFile
from fastapi.encoders import jsonable_encoder
from sqlmodel import Session
from langflow.api.utils import remove_api_keys
from langflow.api.utils import remove_api_keys, validate_is_component
from langflow.api.v1.schemas import FlowListCreate, FlowListRead
from langflow.services.auth.utils import get_current_active_user
from langflow.services.database.models.flow import Flow, FlowCreate, FlowRead, FlowUpdate
@ -46,6 +46,7 @@ def read_flows(
"""Read all flows."""
try:
flows = current_user.flows
flows = validate_is_component(flows)
except Exception as e:
raise HTTPException(status_code=500, detail=str(e)) from e
return [jsonable_encoder(flow) for flow in flows]