Skip to content

Commit b07d1df

Browse files
Merge branch 'webb/openai/add-response-model' into webb/openai/add-response-model-completions
2 parents f12cf5d + 4dade58 commit b07d1df

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

sentry_sdk/integrations/openai.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,6 @@ def _set_streaming_completions_api_output_data(
611611

612612
def new_iterator() -> "Iterator[ChatCompletionChunk]":
613613
nonlocal ttft
614-
count_tokens_manually = True
615614
for x in old_iterator:
616615
span.set_data(SPANDATA.GEN_AI_RESPONSE_MODEL, x.model)
617616

@@ -643,21 +642,12 @@ def new_iterator() -> "Iterator[ChatCompletionChunk]":
643642
set_data_normalized(
644643
span, SPANDATA.GEN_AI_RESPONSE_TEXT, all_responses
645644
)
646-
if count_tokens_manually:
647-
_calculate_token_usage(
648-
messages,
649-
response,
650-
span,
651-
all_responses,
652-
integration.count_tokens,
653-
)
654645

655646
if finish_span:
656647
span.__exit__(None, None, None)
657648

658649
async def new_iterator_async() -> "AsyncIterator[ChatCompletionChunk]":
659650
nonlocal ttft
660-
count_tokens_manually = True
661651
async for x in old_iterator:
662652
span.set_data(SPANDATA.GEN_AI_RESPONSE_MODEL, x.model)
663653

@@ -689,14 +679,7 @@ async def new_iterator_async() -> "AsyncIterator[ChatCompletionChunk]":
689679
set_data_normalized(
690680
span, SPANDATA.GEN_AI_RESPONSE_TEXT, all_responses
691681
)
692-
if count_tokens_manually:
693-
_calculate_token_usage(
694-
messages,
695-
response,
696-
span,
697-
all_responses,
698-
integration.count_tokens,
699-
)
682+
700683
if finish_span:
701684
span.__exit__(None, None, None)
702685

0 commit comments

Comments
 (0)