🐛 fix(chat.py): add exception handling to post_build endpoint
✨ feat(cache/__init__.py): add InMemoryCache to exported modules 🔖 refactor(endpoints.py): remove unused import statement The post_build endpoint in chat.py now has exception handling to catch any errors that may occur during the build process. InMemoryCache is now exported as part of the cache module. The endpoints.py file has been refactored to remove an unused import statement.
This commit is contained in:
parent
efbdd6fee7
commit
bdbc46f01d
3 changed files with 19 additions and 2 deletions
|
|
@ -1,5 +1,6 @@
|
|||
from fastapi import (
|
||||
APIRouter,
|
||||
HTTPException,
|
||||
WebSocket,
|
||||
WebSocketDisconnect,
|
||||
WebSocketException,
|
||||
|
|
@ -24,3 +25,14 @@ async def websocket_endpoint(client_id: str, websocket: WebSocket):
|
|||
except WebSocketDisconnect as exc:
|
||||
logger.error(exc)
|
||||
await websocket.close(code=status.WS_1000_NORMAL_CLOSURE, reason=str(exc))
|
||||
|
||||
|
||||
@router.post("/build/{client_id}")
|
||||
async def post_build(client_id: str, graph_data: dict):
|
||||
"""Build langchain object from data_graph."""
|
||||
try:
|
||||
if chat_manager.build(client_id, graph_data.get("data")):
|
||||
return {"message": "Build successful"}
|
||||
except Exception as exc:
|
||||
logger.exception(exc)
|
||||
raise HTTPException(status_code=500, detail=str(exc)) from exc
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import logging
|
||||
from importlib.metadata import version
|
||||
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
|
|
|
|||
8
src/backend/langflow/cache/__init__.py
vendored
8
src/backend/langflow/cache/__init__.py
vendored
|
|
@ -1 +1,7 @@
|
|||
from langflow.cache.manager import cache_manager # noqa
|
||||
from langflow.cache.manager import cache_manager
|
||||
from langflow.cache.flow import InMemoryCache
|
||||
|
||||
__all__ = [
|
||||
"cache_manager",
|
||||
"InMemoryCache",
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue