Skip to content

Commit 586689f

Browse files
authored
fix: serialization of response schema in invocation parameters for google-adk (Arize-ai#2033)
1 parent 0167e2a commit 586689f

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

  • python/instrumentation/openinference-instrumentation-google-adk/src/openinference/instrumentation/google_adk

python/instrumentation/openinference-instrumentation-google-adk/src/openinference/instrumentation/google_adk/_wrappers.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,10 @@ def wrapper(*args: P.args, **kwargs: P.kwargs) -> Iterator[tuple[str, AttributeV
357357
def _get_attributes_from_generate_content_config(
358358
obj: types.GenerateContentConfig,
359359
) -> Iterator[tuple[str, AttributeValue]]:
360-
yield SpanAttributes.LLM_INVOCATION_PARAMETERS, obj.model_dump_json(exclude_none=True)
360+
yield (
361+
SpanAttributes.LLM_INVOCATION_PARAMETERS,
362+
obj.model_dump_json(exclude_none=True, fallback=_default),
363+
)
361364

362365

363366
@stop_on_exception
@@ -536,6 +539,8 @@ def _default(obj: Any) -> Any:
536539

537540
if isinstance(obj, BaseModel):
538541
return obj.model_dump(exclude_none=True)
542+
if inspect.isclass(obj) and issubclass(obj, BaseModel):
543+
return obj.model_json_schema()
539544
if isinstance(obj, bytes):
540545
return base64.b64encode(obj).decode()
541546
return str(obj)

0 commit comments

Comments
 (0)