mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-10 19:57:52 +02:00
pydantic v1
This commit is contained in:
@@ -694,11 +694,16 @@ class CompiledStateGraph(CompiledGraph):
|
||||
# if input is a Pydantic model, only update values
|
||||
# for the keys that have been explicitly set by the users
|
||||
# (this is needed to avoid sending updates for fields with None defaults)
|
||||
output_keys_ = (
|
||||
[k for k in output_keys if k in input.model_fields_set]
|
||||
if hasattr(input, "model_fields_set")
|
||||
else output_keys
|
||||
)
|
||||
output_keys_ = output_keys
|
||||
# Pydantic v2
|
||||
if hasattr(input, "model_fields_set"):
|
||||
output_keys_ = [
|
||||
k for k in output_keys if k in input.model_fields_set
|
||||
]
|
||||
# Pydantic v1
|
||||
elif hasattr(input, "__fields_set__"):
|
||||
output_keys_ = [k for k in output_keys if k in input.__fields_set__]
|
||||
|
||||
return [
|
||||
(k, getattr(input, k))
|
||||
for k in output_keys_
|
||||
|
||||
Reference in New Issue
Block a user