For the complete documentation index, see llms.txt. This page is also available as Markdown.

Media

Overview

Upload and resolve media references embedded in trace input/output data.


resolve_media_references (source)

Replace media reference strings in an object with base64 data URIs.

This method recursively traverses an object (up to max_depth) looking for media reference strings in the format "@@@interactiveaiMedia:...@@@". When found, it (synchronously) fetches the actual media content using the provided InteractiveAI client and replaces the reference string with a base64 data URI.

If fetching media content fails for a reference string, a warning is logged and the reference string is left unchanged.

resolve_media_references(
    *,
    obj: Any,
    resolve_with: Literal['base64_data_uri'],
    max_depth: int = 10,
    content_fetch_timeout_seconds: int = 5,
) -> Any

Parameters

  • obj — The object to process. Can be a primitive value, array, or nested object. If the object has a dict attribute, a dict will be returned instead of the original object type.

  • resolve_with — The representation of the media content to replace the media reference string with. Currently only "base64_data_uri" is supported.

  • max_depth — int: The maximum depth to traverse the object. Default is 10.

  • content_fetch_timeout_seconds — int: The timeout in seconds for fetching media content. Default is 5.

Returns

A deep copy of the input object with all media references replaced with base64 data URIs where possible. If the input object has a dict attribute, a dict will be returned instead of the original object type.

Example

Last updated

Was this helpful?