Skip to content

Commit 28bf287

Browse files
committed
fix: extract output from final chunk
1 parent 6136e03 commit 28bf287

File tree

4 files changed

+27
-13
lines changed

4 files changed

+27
-13
lines changed

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[project]
22
name = "uipath-langchain"
3-
version = "0.0.120"
3+
version = "0.0.121"
44
description = "UiPath Langchain"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.10"
77
dependencies = [
8-
"uipath>=2.1.0, <2.2.0",
9-
"langgraph>=0.2.70",
8+
"uipath>=2.1.9, <2.2.0",
9+
"langgraph>=0.5.0, <0.7.0",
1010
"langchain-core>=0.3.34",
1111
"langgraph-checkpoint-sqlite>=2.0.3",
1212
"langchain-community>=0.3.21",

src/uipath_langchain/_cli/_runtime/_runtime.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ async def execute(self) -> Optional[UiPathRuntimeResult]:
101101
graph_config["max_concurrency"] = int(max_concurrency)
102102

103103
# Stream the output at debug time
104-
if self.context.job_id is None:
104+
if self.is_debug_run():
105105
# Get final chunk while streaming
106106
final_chunk = None
107107
async for stream_chunk in graph.astream(
@@ -115,7 +115,7 @@ async def execute(self) -> Optional[UiPathRuntimeResult]:
115115

116116
self.context.output = self._extract_graph_result(final_chunk, graph)
117117
else:
118-
# Execute the graph normally at runtime
118+
# Execute the graph normally at runtime or eval
119119
self.context.output = await graph.ainvoke(
120120
processed_input, graph_config
121121
)
@@ -310,9 +310,23 @@ def _extract_graph_result(
310310
# Check which channels are present
311311
available_channels = [ch for ch in output_channels if ch in final_chunk]
312312

313+
# if no available channels, output may contain the last_node name as key
314+
unwrapped_final_chunk = {}
315+
if not available_channels:
316+
if len(final_chunk) == 1 and isinstance(
317+
unwrapped_final_chunk := next(iter(final_chunk.values())), dict
318+
):
319+
available_channels = [
320+
ch for ch in output_channels if ch in unwrapped_final_chunk
321+
]
322+
313323
if available_channels:
314324
# Create a dict with the available channels
315-
return {channel: final_chunk[channel] for channel in available_channels}
325+
return {
326+
channel: final_chunk.get(channel, None)
327+
or unwrapped_final_chunk[channel]
328+
for channel in available_channels
329+
}
316330

317331
# Fallback for any other case
318332
return final_chunk

src/uipath_langchain/_cli/cli_run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async def execute():
4242
context.logs_min_level = env.get("LOG_LEVEL", "INFO")
4343
context.job_id = env.get("UIPATH_JOB_KEY")
4444
context.trace_id = env.get("UIPATH_TRACE_ID")
45-
context.eval_run = kwargs.get("eval_run", False)
45+
context.is_eval_run = kwargs.get("is_eval_run", False)
4646
context.tracing_enabled = tracing
4747
context.input_file = kwargs.get("input_file", None)
4848
context.execution_output_file = kwargs.get("execution_output_file", None)

uv.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)