Skip to content

Commit

Permalink
avoid copying
Browse files Browse the repository at this point in the history
  • Loading branch information
vbarda committed Aug 8, 2024
1 parent fa50e7a commit dd85ad8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions libs/langgraph/langgraph/pregel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,9 @@ def update_state(
# get last checkpoint
saved = self.checkpointer.get_tuple(config)
checkpoint = copy_checkpoint(saved.checkpoint) if saved else empty_checkpoint()
checkpoint_previous_versions = checkpoint["channel_versions"].copy()
checkpoint_previous_versions = (
saved.checkpoint["channel_versions"] if saved else {}
)
step = saved.metadata.get("step", -1) if saved else -1
# merge configurable fields with previous checkpoint config
checkpoint_config = {
Expand Down Expand Up @@ -634,7 +636,9 @@ async def aupdate_state(
# get last checkpoint
saved = await self.checkpointer.aget_tuple(config)
checkpoint = copy_checkpoint(saved.checkpoint) if saved else empty_checkpoint()
checkpoint_previous_versions = checkpoint["channel_versions"].copy()
checkpoint_previous_versions = (
saved.checkpoint["channel_versions"] if saved else {}
)
step = saved.metadata.get("step", -1) if saved else -1
# merge configurable fields with previous checkpoint config
checkpoint_config = {
Expand Down

0 comments on commit dd85ad8

Please sign in to comment.