Skip to content

Commit ca57580

Browse files
Merge branch 'master' into webb/openai/split-up-openai
2 parents 0086b83 + 7ee6918 commit ca57580

2 files changed

Lines changed: 530 additions & 373 deletions

File tree

sentry_sdk/integrations/openai.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,6 @@ def _set_responses_api_input_data(
386386
if model is not None:
387387
span.set_data(SPANDATA.GEN_AI_REQUEST_MODEL, model)
388388

389-
stream = kwargs.get("stream")
390-
if stream is not None and _is_given(stream):
391-
span.set_data(SPANDATA.GEN_AI_RESPONSE_STREAMING, stream)
392-
393389
max_tokens = kwargs.get("max_output_tokens")
394390
if max_tokens is not None and _is_given(max_tokens):
395391
span.set_data(SPANDATA.GEN_AI_REQUEST_MAX_TOKENS, max_tokens)
@@ -1206,12 +1202,16 @@ def _new_responses_create_common(f: "Any", *args: "Any", **kwargs: "Any") -> "An
12061202
span.__enter__()
12071203

12081204
span.set_data(SPANDATA.GEN_AI_SYSTEM, "openai")
1205+
1206+
# Same bool handling as in https://github.com/openai/openai-python/blob/acd0c54d8a68efeedde0e5b4e6c310eef1ce7867/src/openai/resources/responses/responses.py#L940
1207+
is_streaming_response = kwargs.get("stream", False) or False
1208+
span.set_data(SPANDATA.GEN_AI_RESPONSE_STREAMING, is_streaming_response)
1209+
12091210
_set_responses_api_input_data(span, kwargs, integration)
12101211

12111212
start_time = time.perf_counter()
12121213
response = yield f, args, kwargs
12131214

1214-
is_streaming_response = kwargs.get("stream", False)
12151215
if is_streaming_response:
12161216
_set_streaming_responses_api_output_data(
12171217
span, response, kwargs, integration, start_time, finish_span=True

0 commit comments

Comments
 (0)