From 67f826b43f2d0fe31cb3a0154168e18b71aa50ff Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 20 Feb 2024 14:32:34 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20chore(chat.py):=20remove=20unuse?= =?UTF-8?q?d=20imports=20and=20variables=20to=20improve=20code=20readabili?= =?UTF-8?q?ty=20and=20maintainability=20=F0=9F=90=9B=20fix(chat.py):=20fix?= =?UTF-8?q?=20error=20handling=20in=20build=5Fvertex=20function=20to=20cor?= =?UTF-8?q?rectly=20handle=20exceptions=20and=20improve=20error=20reportin?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/api/v1/chat.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/langflow/api/v1/chat.py b/src/backend/langflow/api/v1/chat.py index d49f4dc4a..d226df9bd 100644 --- a/src/backend/langflow/api/v1/chat.py +++ b/src/backend/langflow/api/v1/chat.py @@ -3,7 +3,6 @@ from typing import Optional from fastapi import ( APIRouter, - Body, Depends, HTTPException, WebSocket, @@ -26,7 +25,6 @@ from langflow.api.v1.schemas import ( VerticesOrderResponse, ) from langflow.graph.graph.base import Graph -from langflow.processing.process import process_tweaks_on_graph from langflow.services.auth.utils import ( get_current_active_user, get_current_user_for_websocket, @@ -318,11 +316,10 @@ async def build_vertex( vertex_id: str, chat_service: "ChatService" = Depends(get_chat_service), current_user=Depends(get_current_active_user), - tweaks: dict = Body(None), - inputs: dict = Body(None), ): """Build a vertex instead of the entire graph.""" try: + start_time = time.perf_counter() cache = chat_service.get_cache(flow_id) if not cache: # If there's no cache @@ -336,11 +333,8 @@ async def build_vertex( graph = cache.get("result") result_dict = {} duration = "" - start_time = time.perf_counter() - if tweaks: - graph = process_tweaks_on_graph(graph, tweaks) - if not (vertex := graph.get_vertex(vertex_id)): - raise ValueError(f"Invalid vertex {vertex_id}") + + vertex = graph.get_vertex(vertex_id) try: if not vertex.pinned or not vertex._built: await vertex.build(user_id=current_user.id) @@ -368,7 +362,7 @@ async def build_vertex( raise ValueError(f"No result found for vertex {vertex_id}") chat_service.set_cache(flow_id, graph) except Exception as exc: - params = str(exc) + params = repr(exc) valid = False result_dict = ResultDict(results={}) artifacts = {}