You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(core): serialize nested BaseModel instances in to_json_attr #80
to_json_attr in packages/genkit/src/genkit/_core/_telemetry/_instrumentation.py only checks isinstance(value, BaseModel) at the top level:
defto_json_attr(value: object) ->str:
"""Serialize an arbitrary object for an input/output span attribute."""ifisinstance(value, BaseModel):
returnvalue.model_dump_json(by_alias=True, exclude_none=True)
try:
returnjson.dumps(value)
except (TypeError, ValueError):
returnstr(value)
When an action or flow takes or returns a container holding BaseModel instances (e.g. list[Reservation] or dict[str, Reservation]), json.dumps(value) raises TypeError and to_json_attr falls back to str(value):
Pass a default handler to json.dumps that dumps BaseModel instances via model_dump(mode='json', by_alias=True, exclude_none=True) (matching _encode_json_value in genkit-otel from #39) before falling back to str.
Activity