🐛 fix(chat.py): remove unnecessary try-except block for building the graph and handle any exceptions thrown by Graph.from_payload() method
🔧 refactor(chat.py): improve logging output for built node parameters in stream_build() method
This commit is contained in:
parent
d0aa3261f1
commit
ecf217dce8
1 changed files with 6 additions and 9 deletions
|
|
@ -104,14 +104,9 @@ async def stream_build(flow_id: str):
|
||||||
return
|
return
|
||||||
|
|
||||||
logger.debug("Building langchain object")
|
logger.debug("Building langchain object")
|
||||||
try:
|
|
||||||
# Some error could happen when building the graph
|
# Some error could happen when building the graph
|
||||||
graph = Graph.from_payload(graph_data)
|
graph = Graph.from_payload(graph_data)
|
||||||
except Exception as exc:
|
|
||||||
logger.exception(exc)
|
|
||||||
error_message = str(exc)
|
|
||||||
yield str(StreamData(event="error", data={"error": error_message}))
|
|
||||||
return
|
|
||||||
|
|
||||||
number_of_nodes = len(graph.nodes)
|
number_of_nodes = len(graph.nodes)
|
||||||
flow_data_store[flow_id]["status"] = BuildStatus.IN_PROGRESS
|
flow_data_store[flow_id]["status"] = BuildStatus.IN_PROGRESS
|
||||||
|
|
@ -126,7 +121,9 @@ async def stream_build(flow_id: str):
|
||||||
params = vertex._built_object_repr()
|
params = vertex._built_object_repr()
|
||||||
valid = True
|
valid = True
|
||||||
logger.debug(f"Building node {str(vertex.vertex_type)}")
|
logger.debug(f"Building node {str(vertex.vertex_type)}")
|
||||||
logger.debug(f"Output: {params}")
|
logger.debug(
|
||||||
|
f"Output: {params[:100]}{'...' if len(params) > 100 else ''}"
|
||||||
|
)
|
||||||
if vertex.artifacts:
|
if vertex.artifacts:
|
||||||
# The artifacts will be prompt variables
|
# The artifacts will be prompt variables
|
||||||
# passed to build_input_keys_response
|
# passed to build_input_keys_response
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue