mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-11 20:27:54 +02:00
Fixes
This commit is contained in:
@@ -83,7 +83,8 @@ def _coerce_state(schema: Type[Any], input: dict[str, Any]) -> dict[str, Any]:
|
||||
|
||||
|
||||
def _update_state(input: dict[str, Any], config: RunnableConfig):
|
||||
ChannelWrite.do_write(config, **input)
|
||||
if input is not None:
|
||||
ChannelWrite.do_write(config, **input)
|
||||
return input
|
||||
|
||||
|
||||
|
||||
@@ -563,7 +563,10 @@ def _read_channel(
|
||||
try:
|
||||
return channels[chan].get()
|
||||
except EmptyChannelError:
|
||||
return None
|
||||
if catch:
|
||||
return None
|
||||
else:
|
||||
raise
|
||||
|
||||
|
||||
def _apply_writes(
|
||||
@@ -604,7 +607,7 @@ def _apply_writes_from_view(
|
||||
checkpoint: Checkpoint, channels: Mapping[str, BaseChannel], values: dict[str, Any]
|
||||
) -> None:
|
||||
for chan, value in values.items():
|
||||
if value == channels[chan].get():
|
||||
if value == _read_channel(channels, chan):
|
||||
continue
|
||||
|
||||
assert isinstance(channels[chan], LastValue), (
|
||||
|
||||
@@ -51,6 +51,11 @@ class ChannelWrite(RunnablePassthrough):
|
||||
values = [
|
||||
(chan, r.invoke(input, config) if r else input) for chan, r in self.channels
|
||||
]
|
||||
values = [
|
||||
write
|
||||
for write, chan in zip(values, self.channels)
|
||||
if chan[1] is None or write[1] is not None
|
||||
]
|
||||
|
||||
self.do_write(config, **dict(values))
|
||||
|
||||
@@ -59,10 +64,15 @@ class ChannelWrite(RunnablePassthrough):
|
||||
(chan, await r.ainvoke(input, config) if r else input)
|
||||
for chan, r in self.channels
|
||||
]
|
||||
values = [
|
||||
write
|
||||
for write, chan in zip(values, self.channels)
|
||||
if chan[1] is None or write[1] is not None
|
||||
]
|
||||
|
||||
self.do_write(config, **dict(values))
|
||||
|
||||
@staticmethod
|
||||
def do_write(config: RunnableConfig, **values: Any) -> None:
|
||||
write: TYPE_SEND = config["configurable"][CONFIG_KEY_SEND]
|
||||
write([(chan, val) for chan, val in values.items() if val is not None])
|
||||
write([(chan, val) for chan, val in values.items()])
|
||||
|
||||
Reference in New Issue
Block a user