Skip to content

Commit cb2e803

Browse files
committed
dont truncate in huggingface hub
1 parent 8046c1b commit cb2e803

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

sentry_sdk/integrations/huggingface_hub.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import sentry_sdk
55
from sentry_sdk.ai.monitoring import record_token_usage
6-
from sentry_sdk.ai.utils import set_data_normalized, truncate_and_serialize_messages
6+
from sentry_sdk.ai.utils import set_data_normalized
77
from sentry_sdk.consts import OP, SPANDATA
88
from sentry_sdk.integrations import DidNotEnable, Integration
99
from sentry_sdk.scope import should_send_default_pii
@@ -103,11 +103,9 @@ def new_huggingface_task(*args, **kwargs):
103103

104104
# Input attributes
105105
if should_send_default_pii() and integration.include_prompts:
106-
# Convert prompt to message format if it's a string
107-
messages = [prompt] if isinstance(prompt, str) else prompt
108-
messages_data = truncate_and_serialize_messages(messages)
109-
if messages_data is not None:
110-
span.set_data(SPANDATA.GEN_AI_REQUEST_MESSAGES, messages_data)
106+
set_data_normalized(
107+
span, SPANDATA.GEN_AI_REQUEST_MESSAGES, prompt, unpack=False
108+
)
111109

112110
attribute_mapping = {
113111
"tools": SPANDATA.GEN_AI_REQUEST_AVAILABLE_TOOLS,

tests/integrations/huggingface_hub/test_huggingface_hub.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
import re
2-
from typing import TYPE_CHECKING
31
from unittest import mock
4-
5-
import httpx
62
import pytest
3+
import re
74
import responses
5+
import httpx
6+
87
from huggingface_hub import InferenceClient
98

109
import sentry_sdk
11-
from sentry_sdk._types import AnnotatedValue
12-
from sentry_sdk.ai.utils import MAX_GEN_AI_MESSAGE_BYTES
13-
from sentry_sdk.integrations.huggingface_hub import HuggingfaceHubIntegration
14-
from sentry_sdk.serializer import serialize
1510
from sentry_sdk.utils import package_version
11+
from sentry_sdk.integrations.huggingface_hub import HuggingfaceHubIntegration
12+
13+
from typing import TYPE_CHECKING
1614

1715
try:
1816
from huggingface_hub.utils._errors import HfHubHTTPError

0 commit comments

Comments
 (0)