This commit is contained in:
Nuno Campos
2024-08-21 09:30:22 -07:00
parent 9b90a24d94
commit 656f89e16a
2 changed files with 11 additions and 1 deletions
+3
View File
@@ -43,6 +43,7 @@ from langgraph.graph.graph import (
from langgraph.kv.base import BaseKV
from langgraph.managed.base import (
ChannelKeyPlaceholder,
ChannelTypePlaceholder,
ConfiguredManagedValue,
ManagedValue,
is_managed_value,
@@ -760,6 +761,8 @@ def _is_field_managed_value(name: str, typ: Type[Any]) -> Optional[Type[ManagedV
for k, v in decoration.kwargs.items():
if v is ChannelKeyPlaceholder:
decoration.kwargs[k] = name
if v is ChannelTypePlaceholder:
decoration.kwargs[k] = typ.__origin__
return decoration
return None
@@ -17,6 +17,7 @@ from langgraph.errors import InvalidUpdateError
from langgraph.kv.base import BaseKV
from langgraph.managed.base import (
ChannelKeyPlaceholder,
ChannelTypePlaceholder,
ConfiguredManagedValue,
WritableManagedValue,
)
@@ -43,7 +44,12 @@ class SharedValue(WritableManagedValue[Value, Update]):
@staticmethod
def on(scope: str) -> ConfiguredManagedValue:
return ConfiguredManagedValue(
SharedValue, {"scope": scope, "key": ChannelKeyPlaceholder}
SharedValue,
{
"scope": scope,
"key": ChannelKeyPlaceholder,
"typ": ChannelTypePlaceholder,
},
)
@classmethod
@@ -68,6 +74,7 @@ class SharedValue(WritableManagedValue[Value, Update]):
self, config: RunnableConfig, *, typ: Type[Any], scope: str, key: str
) -> None:
if typ := _strip_extras(typ):
print(typ)
if typ not in (
dict,
collections.abc.Mapping,