Skip to content

Commit 9cad000

Browse files
gustavocidornelasvikasnair
authored andcommitted
chore: completes OPEN-7314 Process input/output of root step of LangGraph graphs
1 parent ad4984b commit 9cad000

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/openlayer/lib/integrations/langchain_callback.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,11 @@ def _handle_chain_start(
562562
if tags and "langsmith:hidden" in tags:
563563
return
564564

565+
if chain_name == "LangGraph" and inputs.get("messages"):
566+
inputs = {
567+
"prompt": inputs.get("messages"),
568+
}
569+
565570
self._start_step(
566571
run_id=run_id,
567572
parent_run_id=parent_run_id,
@@ -571,7 +576,6 @@ def _handle_chain_start(
571576
metadata={
572577
"tags": tags,
573578
"serialized": serialized,
574-
"is_chain": True,
575579
**(metadata or {}),
576580
**kwargs,
577581
},
@@ -607,6 +611,15 @@ def _handle_chain_end(
607611
if current_trace:
608612
current_trace.update_metadata(context=context_list)
609613

614+
# Parse output for LangGraph
615+
step = self.steps[run_id]
616+
if step.name == "LangGraph" and outputs.get("messages"):
617+
if isinstance(outputs.get("messages"), list):
618+
if isinstance(
619+
outputs.get("messages")[-1], langchain_schema.BaseMessage
620+
):
621+
outputs = outputs.get("messages")[-1].content
622+
610623
self._end_step(
611624
run_id=run_id,
612625
parent_run_id=parent_run_id,

0 commit comments

Comments
 (0)