mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-17 21:25:46 +02:00
Ensure configurable (#1912)
This commit is contained in:
@@ -120,6 +120,8 @@ def merge_configs(*configs: Optional[RunnableConfig]) -> RunnableConfig:
|
||||
base["recursion_limit"] = config["recursion_limit"]
|
||||
else:
|
||||
base[key] = config[key] # type: ignore[literal-required]
|
||||
if CONF not in base:
|
||||
base[CONF] = {}
|
||||
return base
|
||||
|
||||
|
||||
|
||||
@@ -41,3 +41,21 @@ def test_runnable_callable_func_accepts():
|
||||
for name, runnable in runnables.items():
|
||||
assert runnable.func_accepts["writer"] == expected_writer.get(name, False)
|
||||
assert runnable.func_accepts["store"] == expected_store.get(name, False)
|
||||
|
||||
|
||||
async def test_runnable_callable_basic():
|
||||
def sync_func(x: Any) -> str:
|
||||
return f"{x}"
|
||||
|
||||
async def async_func(x: Any) -> str:
|
||||
return f"{x}"
|
||||
|
||||
runnable_sync = RunnableCallable(sync_func)
|
||||
runnable_async = RunnableCallable(func=None, afunc=async_func)
|
||||
|
||||
result_sync = runnable_sync.invoke("test")
|
||||
assert result_sync == "test"
|
||||
|
||||
# Test asynchronous ainvoke
|
||||
result_async = await runnable_async.ainvoke("test")
|
||||
assert result_async == "test"
|
||||
|
||||
Reference in New Issue
Block a user