Skip to content

Commit 4f84f98

Browse files
.
1 parent 2aa4b25 commit 4f84f98

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

sentry_sdk/integrations/openai.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,9 +473,6 @@ def _common_set_output_data(
473473
if hasattr(response, "model"):
474474
set_data_normalized(span, SPANDATA.GEN_AI_RESPONSE_MODEL, response.model)
475475

476-
if input is not None and isinstance(input, str):
477-
input = [input]
478-
479476
ttft: "Optional[float]" = None
480477

481478
if hasattr(response, "choices"):
@@ -723,6 +720,9 @@ def _set_completions_api_output_data(
723720
) -> None:
724721
messages = kwargs.get("messages")
725722

723+
if messages is not None and isinstance(messages, str):
724+
messages = [messages]
725+
726726
_common_set_output_data(
727727
span,
728728
response,
@@ -743,6 +743,9 @@ def _set_streaming_completions_api_output_data(
743743
) -> None:
744744
messages = kwargs.get("messages")
745745

746+
if messages is not None and isinstance(messages, str):
747+
messages = [messages]
748+
746749
_common_set_output_data(
747750
span,
748751
response,
@@ -763,6 +766,9 @@ def _set_responses_api_output_data(
763766
) -> None:
764767
input = kwargs.get("input")
765768

769+
if input is not None and isinstance(input, str):
770+
input = [input]
771+
766772
_common_set_output_data(
767773
span,
768774
response,
@@ -783,6 +789,9 @@ def _set_streaming_responses_api_output_data(
783789
) -> None:
784790
input = kwargs.get("input")
785791

792+
if input is not None and isinstance(input, str):
793+
input = [input]
794+
786795
_common_set_output_data(
787796
span,
788797
response,
@@ -803,6 +812,9 @@ def _set_embeddings_output_data(
803812
) -> None:
804813
input = kwargs.get("input")
805814

815+
if input is not None and isinstance(input, str):
816+
input = [input]
817+
806818
_common_set_output_data(
807819
span,
808820
response,

0 commit comments

Comments
 (0)