def model_dump(obj: Union[pydantic.BaseModel, v1BaseModel]) -> dict:
    """
    Return the dict/model_dump of the given pydantic instance regardless of it
    being v2 or v1.
    """

    if isinstance(obj, pydantic.BaseModel):
        return obj.model_dump()
    elif isinstance(obj, v1BaseModel):
        return obj.dict()
    else:
        raise ValueError("Not a pydantic.BaseModel.")

    Return the dict/model_dump of the given pydantic instance regardless of it
    being v2 or v1.
    
src/core/trulens/core/utils/serial.py