Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions sentry_sdk/integrations/huggingface_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ class HuggingfaceHubIntegration(Integration):
identifier = "huggingface_hub"
origin = f"auto.ai.{identifier}"

def __init__(
self: "HuggingfaceHubIntegration", include_prompts: bool = True
) -> None:
self.include_prompts = include_prompts

@staticmethod
def setup_once() -> None:
version = parse_version(HUGGINGFACE_HUB_VERSION)
Expand Down Expand Up @@ -131,7 +126,7 @@ def new_huggingface_task(*args: "Any", **kwargs: "Any") -> "Any":
set_data_normalized(
span, SPANDATA.GEN_AI_REQUEST_MESSAGES, prompt, unpack=False
)
elif should_send_default_pii() and integration.include_prompts:
elif should_send_default_pii():
set_data_normalized(
span, SPANDATA.GEN_AI_REQUEST_MESSAGES, prompt, unpack=False
)
Expand Down Expand Up @@ -219,7 +214,7 @@ def new_huggingface_task(*args: "Any", **kwargs: "Any") -> "Any":
tool_calls,
unpack=False,
)
elif should_send_default_pii() and integration.include_prompts:
elif should_send_default_pii():
set_data_normalized(
span,
SPANDATA.GEN_AI_RESPONSE_TOOL_CALLS,
Expand All @@ -237,7 +232,7 @@ def new_huggingface_task(*args: "Any", **kwargs: "Any") -> "Any":
SPANDATA.GEN_AI_RESPONSE_TEXT,
text_response,
)
elif should_send_default_pii() and integration.include_prompts:
elif should_send_default_pii():
set_data_normalized(
span,
SPANDATA.GEN_AI_RESPONSE_TEXT,
Expand Down Expand Up @@ -304,7 +299,7 @@ def new_details_iterator() -> "Iterable[Any]":
if has_data_collection_enabled(client.options):
if client.options["data_collection"]["gen_ai"]["outputs"]:
should_set_response_text = True
elif should_send_default_pii() and integration.include_prompts:
elif should_send_default_pii():
should_set_response_text = True

if should_set_response_text:
Expand Down Expand Up @@ -397,10 +392,7 @@ def new_iterator() -> "Iterable[ChatCompletionStreamOutput]":
tool_calls,
unpack=False,
)
elif (
should_send_default_pii()
and integration.include_prompts
):
elif should_send_default_pii():
set_data_normalized(
span,
SPANDATA.GEN_AI_RESPONSE_TOOL_CALLS,
Expand All @@ -420,10 +412,7 @@ def new_iterator() -> "Iterable[ChatCompletionStreamOutput]":
SPANDATA.GEN_AI_RESPONSE_TEXT,
text_response,
)
elif (
should_send_default_pii()
and integration.include_prompts
):
elif should_send_default_pii():
set_data_normalized(
span,
SPANDATA.GEN_AI_RESPONSE_TEXT,
Expand Down
Loading
Loading