Skip to content

Commit ca4df94

Browse files
fix(openai): Use non-deprecated Pydantic method to extract response text (#4942)
Switch to Pydantic v2's `model_dump()` instead of `dict()` for serialization. The change avoids deprecation warnings during OpenAI response parsing that created issues in Sentry.
1 parent d21fabd commit ca4df94

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sentry_sdk/integrations/openai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def _set_output_data(span, response, kwargs, integration, finish_span=True):
237237

238238
if hasattr(response, "choices"):
239239
if should_send_default_pii() and integration.include_prompts:
240-
response_text = [choice.message.dict() for choice in response.choices]
240+
response_text = [choice.message.model_dump() for choice in response.choices]
241241
if len(response_text) > 0:
242242
set_data_normalized(span, SPANDATA.GEN_AI_RESPONSE_TEXT, response_text)
243243

0 commit comments

Comments
 (0)