mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-13 05:07:51 +02:00
serde: Handle unicode issues when encoding
- any invalid utf-8 chars now removed on dumps - fix serialization of Send - remove serialization of NamedTuple, which doesn't work - add test for custom serde passed to memory saver - add test using Send and JsonPlus serde
This commit is contained in:
@@ -43,9 +43,12 @@ class MemorySaverAssertImmutable(MemorySaver):
|
||||
# assert checkpoint hasn't been modified since last written
|
||||
thread_id = config["configurable"]["thread_id"]
|
||||
if saved := super().get(config):
|
||||
assert self.storage_for_copies[thread_id][saved["id"]] == saved
|
||||
self.storage_for_copies[thread_id][checkpoint["id"]] = copy_checkpoint(
|
||||
checkpoint
|
||||
assert (
|
||||
self.serde.loads(self.storage_for_copies[thread_id][saved["id"]])
|
||||
== saved
|
||||
)
|
||||
self.storage_for_copies[thread_id][checkpoint["id"]] = self.serde.dumps(
|
||||
copy_checkpoint(checkpoint)
|
||||
)
|
||||
# call super to write checkpoint
|
||||
return super().put(config, checkpoint, metadata)
|
||||
|
||||
Reference in New Issue
Block a user