🔊 chore(base.py): add logger to Graph class

🐛 fix(base.py): improve error message when invalid payload is received
The logger is added to the Graph class to improve debugging capabilities. The error message when an invalid payload is received is improved to include the keys that were found in the payload. This makes it easier to identify the issue and fix it.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-09 17:08:11 -03:00
commit bc07766575

View file

@ -10,6 +10,7 @@ from langflow.graph.vertex.types import (
)
from langflow.interface.tools.constants import FILE_TOOLS
from langflow.utils import payload
from langflow.utils.logger import logger
class Graph:
@ -43,7 +44,9 @@ class Graph:
edges = payload["edges"]
return cls(nodes, edges)
except KeyError as exc:
raise ValueError("Invalid payload") from exc
raise ValueError(
f"Invalid payload. Expected keys 'nodes' and 'edges'. Found {list(payload.keys())}"
) from exc
def _build_graph(self) -> None:
"""Builds the graph from the nodes and edges."""