def _extract_content(value, content_keys=["content"]):
    """
    Extracts the 'content' from various data types commonly used by libraries
    like OpenAI, Canopy, LiteLLM, etc. This method navigates nested data
    structures (pydantic models, dictionaries, lists) to retrieve the
    'content' field. If 'content' is not directly available, it attempts to
    extract from known structures like 'choices' in a ChatResponse. This
    standardizes extracting relevant text or data from complex API responses
    or internal data representations.

    Args:
        value: The input data to extract content from. Can be a pydantic
                model, dictionary, list, or basic data type.

    Returns:
        The extracted content, which may be a single value, a list of values,
        or a nested structure with content extracted from all levels.
    """
    if isinstance(value, pydantic.BaseModel):
        content = getattr(value, "content", None)
        if content is not None:
            return content

        # If 'content' is not found, check for 'choices' attribute which indicates a ChatResponse
        choices = getattr(value, "choices", None)
        if choices is not None:
            # Extract 'content' from the 'message' attribute of each _Choice in 'choices'
            return [_extract_content(choice.message) for choice in choices]

        # Recursively extract content from nested pydantic models
        try:
            return {
                k: _extract_content(v)
                if isinstance(v, (pydantic.BaseModel, dict, list))
                else v
                for k, v in value.model_dump().items()
            }
        except Exception as e:
            logger.warning(
                "Failed to extract content from pydantic model: %s", e
            )
            # Unsure what is best to do here. Lets just return the exception
            # so that it might reach the user if nothing else gets picked up
            # as main input/output.
            return str(e)

    elif isinstance(value, dict):
        # Check for 'content' key in the dictionary
        for key in content_keys:
            content = value.get(key)
            if content is not None:
                return content

        # Recursively extract content from nested dictionaries
        return {
            k: _extract_content(v) if isinstance(v, (dict, list)) else v
            for k, v in value.items()
        }

    elif isinstance(value, list):
        # Handle lists by extracting content from each item
        return [_extract_content(item) for item in value]

    else:
        return value

    Extracts the 'content' from various data types commonly used by libraries
    like OpenAI, Canopy, LiteLLM, etc. This method navigates nested data
    structures (pydantic models, dictionaries, lists) to retrieve the
    'content' field. If 'content' is not directly available, it attempts to
    extract from known structures like 'choices' in a ChatResponse. This
    standardizes extracting relevant text or data from complex API responses
    or internal data representations.

    Args:
        value: The input data to extract content from. Can be a pydantic
                model, dictionary, list, or basic data type.

    Returns:
        The extracted content, which may be a single value, a list of values,
        or a nested structure with content extracted from all levels.
    
src/core/trulens/core/utils/signature.py