11import functools
2+ import warnings
23
34from sentry_sdk .integrations import DidNotEnable , Integration
45from sentry_sdk .utils import parse_version
2122from .spans .ai_client import ai_client_span , update_ai_client_span
2223
2324if TYPE_CHECKING :
24- from typing import Any
25+ from typing import Any , Optional
2526
2627 from pydantic_ai import ModelRequestContext , RunContext
2728 from pydantic_ai .capabilities import Hooks , WrapModelRequestHandler
@@ -84,7 +85,9 @@ class PydanticAIIntegration(Integration):
8485 origin = f"auto.ai.{ identifier } "
8586
8687 def __init__ (
87- self , include_prompts : bool = True , handled_tool_call_exceptions : bool = True
88+ self ,
89+ include_prompts : Optional [bool ] = None ,
90+ handled_tool_call_exceptions : bool = True ,
8891 ) -> None :
8992 """
9093 Initialize the Pydantic AI integration.
@@ -95,7 +98,17 @@ def __init__(
9598 handled_tool_exceptions: Capture tool call exceptions that Pydantic AI
9699 internally prevents from bubbling up.
97100 """
98- self .include_prompts = include_prompts
101+ if include_prompts is not None :
102+ warnings .warn (
103+ "`PydanticAIIntegration.include_prompts` is deprecated and will be removed in version 3.0. "
104+ "To disable capture of GenAI attributes, pass "
105+ "`data_collection={'gen_ai': {'inputs': False, 'outputs': False}}` "
106+ "to `sentry_sdk.init`." ,
107+ DeprecationWarning ,
108+ stacklevel = 2 ,
109+ )
110+
111+ self .include_prompts = True if include_prompts is None else include_prompts
99112 self .handled_tool_call_exceptions = handled_tool_call_exceptions
100113
101114 @staticmethod
0 commit comments