mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-20 06:35:46 +02:00
checkpoint: Avoid changes to pydantic models breaking deserialization while still relying on pydantic's type coercion
This commit is contained in:
@@ -51,13 +51,9 @@ class JsonPlusSerializer(SerializerProtocol):
|
||||
if isinstance(obj, Serializable):
|
||||
return obj.to_json()
|
||||
elif hasattr(obj, "model_dump") and callable(obj.model_dump):
|
||||
return self._encode_constructor_args(
|
||||
obj.__class__, method="model_construct", kwargs=obj.model_dump()
|
||||
)
|
||||
return self._encode_constructor_args(obj.__class__, kwargs=obj.model_dump())
|
||||
elif hasattr(obj, "dict") and callable(obj.dict):
|
||||
return self._encode_constructor_args(
|
||||
obj.__class__, method="construct", kwargs=obj.dict()
|
||||
)
|
||||
return self._encode_constructor_args(obj.__class__, kwargs=obj.dict())
|
||||
elif isinstance(obj, pathlib.Path):
|
||||
return self._encode_constructor_args(pathlib.Path, args=obj.parts)
|
||||
elif isinstance(obj, re.Pattern):
|
||||
@@ -150,7 +146,7 @@ class JsonPlusSerializer(SerializerProtocol):
|
||||
return method(**value["kwargs"])
|
||||
else:
|
||||
return method()
|
||||
except (ImportError, AttributeError, TypeError):
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
return LC_REVIVER(value)
|
||||
|
||||
Reference in New Issue
Block a user