Skip to content

Commit

Permalink
Ensure configurable (#1912)
Browse files Browse the repository at this point in the history
  • Loading branch information
hinthornw authored Sep 30, 2024
1 parent f6f3f85 commit e332869
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libs/langgraph/langgraph/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
18 changes: 18 additions & 0 deletions libs/langgraph/tests/test_runnable.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,21 @@ async def afunc_with_writer(x: Any, writer: StreamWriter) -> str:
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"

0 comments on commit e332869

Please sign in to comment.