Skip to content

Commit 9d10151

Browse files
authored
core[patch]: fix init of RunnableAssign (#26903)
Example in API ref currently raises ValidationError. Resolves #26862
1 parent f758319 commit 9d10151

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

libs/core/langchain_core/runnables/passthrough.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ def add_ten(x: Dict[str, int]) -> Dict[str, int]:
389389
# returns {'input': 5, 'add_step': {'added': 15}}
390390
"""
391391

392-
mapper: RunnableParallel[dict[str, Any]]
392+
mapper: RunnableParallel
393393

394394
def __init__(self, mapper: RunnableParallel[dict[str, Any]], **kwargs: Any) -> None:
395395
super().__init__(mapper=mapper, **kwargs) # type: ignore[call-arg]

libs/core/tests/unit_tests/runnables/test_runnable.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
ConfigurableFieldSingleOption,
6464
RouterRunnable,
6565
Runnable,
66+
RunnableAssign,
6667
RunnableBinding,
6768
RunnableBranch,
6869
RunnableConfig,
@@ -5413,3 +5414,14 @@ def test_schema_for_prompt_and_chat_model() -> None:
54135414
"title": "PromptInput",
54145415
"type": "object",
54155416
}
5417+
5418+
5419+
def test_runnable_assign() -> None:
5420+
def add_ten(x: dict[str, int]) -> dict[str, int]:
5421+
return {"added": x["input"] + 10}
5422+
5423+
mapper = RunnableParallel({"add_step": RunnableLambda(add_ten)})
5424+
runnable_assign = RunnableAssign(mapper)
5425+
5426+
result = runnable_assign.invoke({"input": 5})
5427+
assert result == {"input": 5, "add_step": {"added": 15}}

0 commit comments

Comments
 (0)