Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

donotmerge #1865

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
90bd12a
Implement new Store interface
nfcampos Sep 25, 2024
a72afdc
Fix test
nfcampos Sep 25, 2024
595c5ea
Lint
nfcampos Sep 25, 2024
cab8a24
Spelling
hinthornw Sep 25, 2024
d449ab5
Support stringized annotations
hinthornw Sep 25, 2024
6b1bf06
String Match
hinthornw Sep 25, 2024
fd226c6
Merge pull request #1835 from langchain-ai/wfh/other_annos
nfcampos Sep 25, 2024
3bf4270
Inject store
nfcampos Sep 25, 2024
0a9cd3a
Merge BaseStore and Store
nfcampos Sep 25, 2024
4ab823f
Slots for MemoryStore
nfcampos Sep 25, 2024
ebdc989
Add tests for MemoryStore in graph
hinthornw Sep 26, 2024
6af537b
Fixes
nfcampos Sep 26, 2024
c056300
Remove unimplemented args
nfcampos Sep 26, 2024
3ee8758
Update test signature
hinthornw Sep 26, 2024
7225cc2
Lint
nfcampos Sep 26, 2024
615b06b
Remove
nfcampos Sep 26, 2024
22b7cf4
Merge branch 'wfh/add_test' of https://github.com/langchain-ai/langgr…
bracesproul Sep 26, 2024
f97db1b
Update etst
hinthornw Sep 26, 2024
2b05c41
Merge branch 'wfh/add_test' of https://github.com/langchain-ai/langgr…
bracesproul Sep 26, 2024
944676a
Update kafka test
hinthornw Sep 26, 2024
a6b4c0c
Mv to checkpoint lib
hinthornw Sep 26, 2024
ba7f706
Move to checkpoint package
hinthornw Sep 26, 2024
4664b59
Merge branch 'wfh/add_test' of https://github.com/langchain-ai/langgr…
bracesproul Sep 26, 2024
99a88eb
Lint fixes
hinthornw Sep 26, 2024
d309f58
py.typed
hinthornw Sep 26, 2024
3daae2d
Update
hinthornw Sep 26, 2024
b9cf088
doc
hinthornw Sep 26, 2024
5c07393
Merge branch 'wfh/add_test' of https://github.com/langchain-ai/langgr…
bracesproul Sep 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Support stringized annotations
  • Loading branch information
hinthornw committed Sep 25, 2024
commit d449ab533db557022bc75fe2470f97db31875650
5 changes: 4 additions & 1 deletion libs/langgraph/langgraph/utils/runnable.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ def __init__(
# check signature
if func is None and afunc is None:
raise ValueError("At least one of func or afunc must be provided.")
params = inspect.signature(cast(Callable, func or afunc)).parameters
params = inspect.signature(
cast(Callable, func or afunc), eval_str=True
).parameters

self.func_accepts_config = "config" in params
self.func_accepts: dict[str, bool] = {}
for kw, typ, _, _, _ in KWARGS_CONFIG_KEYS:
Expand Down
43 changes: 43 additions & 0 deletions libs/langgraph/tests/test_runnable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from __future__ import annotations

from typing import Any

from langgraph.store.store import Store
from langgraph.types import StreamWriter
from langgraph.utils.runnable import RunnableCallable


def test_runnable_callable_func_accepts():
def sync_func(x: Any) -> str:
return f"{x}"

async def async_func(x: Any) -> str:
return f"{x}"

def func_with_store(x: Any, store: Store) -> str:
return f"{x}"

def func_with_writer(x: Any, writer: StreamWriter) -> str:
return f"{x}"

async def afunc_with_store(x: Any, store: Store) -> str:
return f"{x}"

async def afunc_with_writer(x: Any, writer: StreamWriter) -> str:
return f"{x}"

runnables = {
"sync": RunnableCallable(sync_func),
"async": RunnableCallable(func=None, afunc=async_func),
"with_store": RunnableCallable(func_with_store),
"with_writer": RunnableCallable(func_with_writer),
"awith_store": RunnableCallable(afunc_with_store),
"awith_writer": RunnableCallable(afunc_with_writer),
}

expected_store = {"with_store": True, "awith_store": True}
expected_writer = {"with_writer": True, "awith_writer": True}

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)
Loading