mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-09 06:53:59 +00:00
core[patch]: fix init of RunnableAssign (#26903)
Example in API ref currently raises ValidationError. Resolves https://github.com/langchain-ai/langchain/issues/26862
This commit is contained in:
@@ -63,6 +63,7 @@ from langchain_core.runnables import (
|
||||
ConfigurableFieldSingleOption,
|
||||
RouterRunnable,
|
||||
Runnable,
|
||||
RunnableAssign,
|
||||
RunnableBinding,
|
||||
RunnableBranch,
|
||||
RunnableConfig,
|
||||
@@ -5413,3 +5414,14 @@ def test_schema_for_prompt_and_chat_model() -> None:
|
||||
"title": "PromptInput",
|
||||
"type": "object",
|
||||
}
|
||||
|
||||
|
||||
def test_runnable_assign() -> None:
|
||||
def add_ten(x: dict[str, int]) -> dict[str, int]:
|
||||
return {"added": x["input"] + 10}
|
||||
|
||||
mapper = RunnableParallel({"add_step": RunnableLambda(add_ten)})
|
||||
runnable_assign = RunnableAssign(mapper)
|
||||
|
||||
result = runnable_assign.invoke({"input": 5})
|
||||
assert result == {"input": 5, "add_step": {"added": 15}}
|
||||
|
Reference in New Issue
Block a user