Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit69a1c16

Browse files
authored
fix: serialize BaseModel subclasses and avoid calling methods on types (langflow-ai#4479)
Fix serialization for BaseModel subclasses by handling type objects separately
1 parent33a42bc commit69a1c16

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

‎src/backend/base/langflow/schema/serialize.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
defrecursive_serialize_or_str(obj):
1010
try:
11+
ifisinstance(obj,type)andissubclass(obj,BaseModel):
12+
# This a type BaseModel and not an instance of it
13+
returnrepr(obj)
1114
ifisinstance(obj,str):
1215
returnobj
1316
ifisinstance(obj,datetime):
@@ -30,13 +33,10 @@ def recursive_serialize_or_str(obj):
3033
# return f"{obj}" this generates '<generator object BaseChatModel.stream at 0x33e9ec770>'
3134
# it is not useful
3235
return"Unconsumed Stream"
33-
ifhasattr(obj,"dict"):
36+
ifhasattr(obj,"dict")andnotisinstance(obj,type):
3437
return {k:recursive_serialize_or_str(v)fork,vinobj.dict().items()}
35-
ifhasattr(obj,"model_dump"):
38+
ifhasattr(obj,"model_dump")andnotisinstance(obj,type):
3639
return {k:recursive_serialize_or_str(v)fork,vinobj.model_dump().items()}
37-
ifisinstance(obj,type)andissubclass(obj,BaseModel):
38-
# This a type BaseModel and not an instance of it
39-
returnrepr(obj)
4040
returnstr(obj)
4141
exceptException:# noqa: BLE001
4242
logger.debug(f"Cannot serialize object{obj}")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp