diff --git a/logfire/_internal/json_encoder.py b/logfire/_internal/json_encoder.py index 0db85a06..8a48518d 100644 --- a/logfire/_internal/json_encoder.py +++ b/logfire/_internal/json_encoder.py @@ -275,6 +275,13 @@ def to_json_value(o: Any, seen: set[int]) -> JsonValue: if isinstance(o, Sequence): return [to_json_value(item, seen) for item in o] # type: ignore + + try: + # Some VertexAI classes have this method. They have no common base class. + # Seems like a sensible thing to try in general. + return to_json_value(o.to_dict(), seen) + except Exception: # currently redundant, but future-proof + pass except Exception: # pragma: no cover pass