Fix import and error handling in get_vertices function
This commit is contained in:
parent
9cd43802cb
commit
db9665f01a
1 changed files with 5 additions and 4 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException, Query, WebSocket, WebSocketException, status, Body
|
from fastapi import APIRouter, Body, Depends, HTTPException, Query, WebSocket, WebSocketException, status
|
||||||
from fastapi.responses import StreamingResponse
|
from fastapi.responses import StreamingResponse
|
||||||
from langflow.api.utils import build_input_keys_response, format_elapsed_time
|
from langflow.api.utils import build_input_keys_response, format_elapsed_time
|
||||||
from langflow.api.v1.schemas import (
|
from langflow.api.v1.schemas import (
|
||||||
|
|
@ -12,14 +12,14 @@ from langflow.api.v1.schemas import (
|
||||||
VertexBuildResponse,
|
VertexBuildResponse,
|
||||||
VerticesOrderResponse,
|
VerticesOrderResponse,
|
||||||
)
|
)
|
||||||
|
from langflow.graph.graph.base import Graph
|
||||||
from langflow.graph.vertex.base import StatelessVertex
|
from langflow.graph.vertex.base import StatelessVertex
|
||||||
from langflow.processing.process import process_tweaks_on_graph
|
from langflow.processing.process import process_tweaks_on_graph
|
||||||
from langflow.services.database.models.flow import Flow
|
|
||||||
from langflow.graph.graph.base import Graph
|
|
||||||
from langflow.services.auth.utils import get_current_active_user, get_current_user_by_jwt
|
from langflow.services.auth.utils import get_current_active_user, get_current_user_by_jwt
|
||||||
from langflow.services.cache.service import BaseCacheService
|
from langflow.services.cache.service import BaseCacheService
|
||||||
from langflow.services.cache.utils import update_build_status
|
from langflow.services.cache.utils import update_build_status
|
||||||
from langflow.services.chat.service import ChatService
|
from langflow.services.chat.service import ChatService
|
||||||
|
from langflow.services.database.models.flow import Flow
|
||||||
from langflow.services.deps import get_cache_service, get_chat_service, get_session
|
from langflow.services.deps import get_cache_service, get_chat_service, get_session
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from sqlmodel import Session
|
from sqlmodel import Session
|
||||||
|
|
@ -255,7 +255,7 @@ async def get_vertices(
|
||||||
"""Check the flow_id is in the flow_data_store."""
|
"""Check the flow_id is in the flow_data_store."""
|
||||||
try:
|
try:
|
||||||
flow: Flow = session.get(Flow, flow_id)
|
flow: Flow = session.get(Flow, flow_id)
|
||||||
if not flow:
|
if not flow or not flow.data:
|
||||||
raise ValueError("Invalid flow ID")
|
raise ValueError("Invalid flow ID")
|
||||||
graph = Graph.from_payload(flow.data)
|
graph = Graph.from_payload(flow.data)
|
||||||
chat_service.set_cache(flow_id, graph)
|
chat_service.set_cache(flow_id, graph)
|
||||||
|
|
@ -267,6 +267,7 @@ async def get_vertices(
|
||||||
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.error(f"Error checking build status: {exc}")
|
logger.error(f"Error checking build status: {exc}")
|
||||||
|
logger.exception(exc)
|
||||||
raise HTTPException(status_code=500, detail=str(exc)) from exc
|
raise HTTPException(status_code=500, detail=str(exc)) from exc
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue