Skip to content

Commit f2cab2d

Browse files
Apply suggestions from code review
Co-authored-by: Ivana Kellyer <[email protected]>
1 parent d76a563 commit f2cab2d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sentry_sdk/integrations/openai.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def new_iterator():
270270
data_buf[0].append(x.delta or "")
271271

272272
# OpenAI responses API end of streaming response
273-
if x.__class__.__name__ == "ResponseCompletedEvent":
273+
if isinstance(x, ResponseCompletedEvent):
274274
_calculate_token_usage(
275275
messages,
276276
x.response,
@@ -283,7 +283,7 @@ def new_iterator():
283283
yield x
284284

285285
if len(data_buf) > 0:
286-
all_responses = list(map(lambda chunk: "".join(chunk), data_buf))
286+
all_responses = ["".join(chunk) for chunk in data_buf]
287287
if should_send_default_pii() and integration.include_prompts:
288288
set_data_normalized(
289289
span, SPANDATA.GEN_AI_RESPONSE_TEXT, all_responses
@@ -338,7 +338,7 @@ async def new_iterator_async():
338338
yield x
339339

340340
if len(data_buf) > 0:
341-
all_responses = list(map(lambda chunk: "".join(chunk), data_buf))
341+
all_responses = ["".join(chunk) for chunk in data_buf]
342342
if should_send_default_pii() and integration.include_prompts:
343343
set_data_normalized(
344344
span, SPANDATA.GEN_AI_RESPONSE_TEXT, all_responses

0 commit comments

Comments
 (0)