SILENT KILLERPanel

Current Path: > > opt > > hc_python > > lib > python3.12 > site-packages > sentry_sdk > ai


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: //opt//hc_python//lib/python3.12/site-packages/sentry_sdk/ai

NameTypeSizeLast ModifiedActions
__pycache__ Directory - -
__init__.py File 0 bytes May 23 2025 10:34:44.
monitoring.py File 4506 bytes May 23 2025 10:34:44.
utils.py File 950 bytes May 23 2025 10:34:44.

Reading File: //opt//hc_python//lib/python3.12/site-packages/sentry_sdk/ai/utils.py

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from typing import Any

from sentry_sdk.tracing import Span
from sentry_sdk.utils import logger


def _normalize_data(data):
    # type: (Any) -> Any

    # convert pydantic data (e.g. OpenAI v1+) to json compatible format
    if hasattr(data, "model_dump"):
        try:
            return data.model_dump()
        except Exception as e:
            logger.warning("Could not convert pydantic data to JSON: %s", e)
            return data
    if isinstance(data, list):
        if len(data) == 1:
            return _normalize_data(data[0])  # remove empty dimensions
        return list(_normalize_data(x) for x in data)
    if isinstance(data, dict):
        return {k: _normalize_data(v) for (k, v) in data.items()}
    return data


def set_data_normalized(span, key, value):
    # type: (Span, str, Any) -> None
    normalized = _normalize_data(value)
    span.set_data(key, normalized)

SILENT KILLER Tool