@@ -69,7 +69,8 @@ async def test_async_structured_output_with_content(
6969 if latest_experimental_enabled
7070 else GenAIAttributes .GEN_AI_OPENAI_REQUEST_RESPONSE_FORMAT
7171 )
72- assert spans [0 ].attributes [output_type_attr_key ] == "json_schema"
72+ expected_value = "json" if latest_experimental_enabled else "json_schema"
73+ assert spans [0 ].attributes [output_type_attr_key ] == expected_value
7374
7475 if latest_experimental_enabled :
7576 assert_messages_attribute (
@@ -78,18 +79,14 @@ async def test_async_structured_output_with_content(
7879 )
7980 assert_messages_attribute (
8081 spans [0 ].attributes ["gen_ai.output.messages" ],
81- format_simple_expected_output_message (
82- response .choices [0 ].message .content
83- ),
82+ format_simple_expected_output_message (response .choices [0 ].message .content ),
8483 )
8584 else :
8685 logs = log_exporter .get_finished_logs ()
8786 assert len (logs ) == 2
8887
8988 user_message = {"content" : STRUCTURED_OUTPUT_PROMPT [0 ]["content" ]}
90- assert_message_in_logs (
91- logs [0 ], "gen_ai.user.message" , user_message , spans [0 ]
92- )
89+ assert_message_in_logs (logs [0 ], "gen_ai.user.message" , user_message , spans [0 ])
9390
9491 choice_event = {
9592 "index" : 0 ,
@@ -99,9 +96,7 @@ async def test_async_structured_output_with_content(
9996 "content" : response .choices [0 ].message .content ,
10097 },
10198 }
102- assert_message_in_logs (
103- logs [1 ], "gen_ai.choice" , choice_event , spans [0 ]
104- )
99+ assert_message_in_logs (logs [1 ], "gen_ai.choice" , choice_event , spans [0 ])
105100
106101
107102@pytest .mark .asyncio ()
@@ -138,7 +133,8 @@ async def test_async_structured_output_no_content(
138133 if latest_experimental_enabled
139134 else GenAIAttributes .GEN_AI_OPENAI_REQUEST_RESPONSE_FORMAT
140135 )
141- assert spans [0 ].attributes [output_type_attr_key ] == "json_schema"
136+ expected_value = "json" if latest_experimental_enabled else "json_schema"
137+ assert spans [0 ].attributes [output_type_attr_key ] == expected_value
142138
143139 logs = log_exporter .get_finished_logs ()
144140 if latest_experimental_enabled :
@@ -155,6 +151,4 @@ async def test_async_structured_output_no_content(
155151 "finish_reason" : "stop" ,
156152 "message" : {"role" : "assistant" },
157153 }
158- assert_message_in_logs (
159- logs [1 ], "gen_ai.choice" , choice_event , spans [0 ]
160- )
154+ assert_message_in_logs (logs [1 ], "gen_ai.choice" , choice_event , spans [0 ])
0 commit comments