From 7ca37afc74095c86ad0e86f36ce948d0ed7e33b7 Mon Sep 17 00:00:00 2001 From: Nuno Campos Date: Fri, 16 Aug 2024 16:03:51 -0700 Subject: [PATCH] Fix --- libs/langgraph/langgraph/graph/state.py | 2 +- libs/langgraph/langgraph/managed/scoped_value.py | 6 +++--- libs/langgraph/langgraph/pregel/algo.py | 2 +- libs/langgraph/tests/test_pregel.py | 10 +++++----- libs/langgraph/tests/test_pregel_async.py | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libs/langgraph/langgraph/graph/state.py b/libs/langgraph/langgraph/graph/state.py index cda357607..1c9242ea1 100644 --- a/libs/langgraph/langgraph/graph/state.py +++ b/libs/langgraph/langgraph/graph/state.py @@ -695,7 +695,7 @@ def _get_channels( schema: Type[dict], ) -> tuple[dict[str, BaseChannel], dict[str, Type[ManagedValue]]]: if not hasattr(schema, "__annotations__"): - return {"__root__": _get_channel(schema, allow_managed=False)}, {} + return {"__root__": _get_channel("__root__", schema, allow_managed=False)}, {} all_keys = { name: _get_channel(name, typ) diff --git a/libs/langgraph/langgraph/managed/scoped_value.py b/libs/langgraph/langgraph/managed/scoped_value.py index 997bc9469..38a666163 100644 --- a/libs/langgraph/langgraph/managed/scoped_value.py +++ b/libs/langgraph/langgraph/managed/scoped_value.py @@ -26,11 +26,11 @@ Value = dict[str, V] Update = dict[str, Optional[V]] -class ScopedValue(WritableManagedValue[Value, Update]): +class SharedValue(WritableManagedValue[Value, Update]): @staticmethod - def configure(scope: str) -> ConfiguredManagedValue: + def on(scope: str) -> ConfiguredManagedValue: return ConfiguredManagedValue( - ScopedValue, {"scope": scope, "key": ChannelKeyPlaceholder} + SharedValue, {"scope": scope, "key": ChannelKeyPlaceholder} ) @classmethod diff --git a/libs/langgraph/langgraph/pregel/algo.py b/libs/langgraph/langgraph/pregel/algo.py index a52d15f4d..37f168bf7 100644 --- a/libs/langgraph/langgraph/pregel/algo.py +++ b/libs/langgraph/langgraph/pregel/algo.py @@ -121,8 +121,8 @@ def local_write( commit: Callable[[Sequence[tuple[str, Any]]], None], processes: Mapping[str, PregelNode], channels: Mapping[str, BaseChannel], - writes: Sequence[tuple[str, Any]], managed: ManagedValueMapping, + writes: Sequence[tuple[str, Any]], ) -> None: for chan, value in writes: if chan == TASKS: diff --git a/libs/langgraph/tests/test_pregel.py b/libs/langgraph/tests/test_pregel.py index 3cc1c4d23..4bcce7ccd 100644 --- a/libs/langgraph/tests/test_pregel.py +++ b/libs/langgraph/tests/test_pregel.py @@ -59,7 +59,7 @@ from langgraph.graph.graph import START from langgraph.graph.message import MessageGraph, add_messages from langgraph.graph.state import StateGraph from langgraph.kv.memory import MemoryKV -from langgraph.managed.scoped_value import ScopedValue +from langgraph.managed.scoped_value import SharedValue from langgraph.prebuilt.chat_agent_executor import ( create_tool_calling_executor, ) @@ -167,7 +167,9 @@ def test_graph_validation() -> None: class State(TypedDict): hello: str - shared_things: Annotated[dict[str, dict[str, Any]], ScopedValue("assistant_id")] + shared_things: Annotated[ + dict[str, dict[str, Any]], SharedValue.on("assistant_id") + ] def node_a(state: State) -> State: # typo @@ -6205,9 +6207,7 @@ def test_start_branch_then(snapshot: SnapshotAssertion) -> None: class State(TypedDict): my_key: Annotated[str, operator.add] market: str - shared: Annotated[ - dict[str, dict[str, Any]], ScopedValue.configure("assistant_id") - ] + shared: Annotated[dict[str, dict[str, Any]], SharedValue.on("assistant_id")] def assert_shared_value(data: State, config: RunnableConfig) -> State: assert "shared" in data diff --git a/libs/langgraph/tests/test_pregel_async.py b/libs/langgraph/tests/test_pregel_async.py index 7c5742aa0..3048ddbb4 100644 --- a/libs/langgraph/tests/test_pregel_async.py +++ b/libs/langgraph/tests/test_pregel_async.py @@ -563,7 +563,7 @@ async def test_invoke_single_process_in_out(mocker: MockerFixture) -> None: assert app.input_schema.schema() == {"title": "LangGraphInput", "type": "integer"} assert app.output_schema.schema() == {"title": "LangGraphOutput", "type": "integer"} - assert await app.ainvoke(2) == 3 + assert await app.ainvoke(2, debug=True) == 3 assert await app.ainvoke(2, output_keys=["output"]) == {"output": 3} assert await gapp.ainvoke(2) == 3