mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-04-30 23:02:50 +00:00
fix: handle plain classes and callables in to_serializable
Add __dict__ handler for non-Pydantic classes so their attributes are serialized rather than falling through to repr(). Guard with a callable check so functions/lambdas still get repr().
This commit is contained in:
@@ -116,6 +116,23 @@ def to_serializable(
|
||||
}
|
||||
except Exception:
|
||||
return repr(obj)
|
||||
if callable(obj):
|
||||
return repr(obj)
|
||||
if hasattr(obj, "__dict__"):
|
||||
try:
|
||||
return {
|
||||
_to_serializable_key(k): to_serializable(
|
||||
v,
|
||||
max_depth=max_depth,
|
||||
_current_depth=_current_depth + 1,
|
||||
_ancestors=new_ancestors,
|
||||
context=context,
|
||||
)
|
||||
for k, v in obj.__dict__.items()
|
||||
if not k.startswith("_")
|
||||
}
|
||||
except Exception:
|
||||
return repr(obj)
|
||||
return repr(obj)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user