66
66
TEST_CHAT_MODEL = "gpt-4o-mini"
67
67
TEST_CHAT_RESPONSE_MODEL = "gpt-4o-mini-2024-07-18"
68
68
TEST_CHAT_INPUT = "Answer in up to 3 words: Which ocean contains Bouvet Island?"
69
+ HAS_BETA_CHAT_COMPLETIONS = (1 , 40 , 0 ) <= OPENAI_VERSION < (1 , 93 , 0 )
69
70
70
71
71
- @pytest .mark .skipif (OPENAI_VERSION < ( 1 , 40 , 0 ), reason = "beta completions added in 1.40.0" )
72
+ @pytest .mark .skipif (not HAS_BETA_CHAT_COMPLETIONS , reason = "beta completions added in 1.40.0, removed in 1.93 .0" )
72
73
@pytest .mark .vcr ()
73
74
def test_chat (default_openai_env , trace_exporter , metrics_reader , logs_exporter ):
74
75
client = openai .OpenAI ()
@@ -133,7 +134,7 @@ def test_chat(default_openai_env, trace_exporter, metrics_reader, logs_exporter)
133
134
)
134
135
135
136
136
- @pytest .mark .skipif (OPENAI_VERSION < ( 1 , 40 , 0 ), reason = "beta completions added in 1.40.0" )
137
+ @pytest .mark .skipif (not HAS_BETA_CHAT_COMPLETIONS , reason = "beta completions added in 1.40.0, removed in 1.93 .0" )
137
138
@pytest .mark .vcr ()
138
139
def test_chat_with_developer_role_message (default_openai_env , trace_exporter , metrics_reader , logs_exporter ):
139
140
client = openai .OpenAI ()
@@ -206,7 +207,7 @@ def test_chat_with_developer_role_message(default_openai_env, trace_exporter, me
206
207
)
207
208
208
209
209
- @pytest .mark .skipif (OPENAI_VERSION < ( 1 , 40 , 0 ), reason = "beta completions added in 1.40.0" )
210
+ @pytest .mark .skipif (not HAS_BETA_CHAT_COMPLETIONS , reason = "beta completions added in 1.40.0, removed in 1.93 .0" )
210
211
@pytest .mark .vcr ()
211
212
def test_chat_all_the_client_options (default_openai_env , trace_exporter , metrics_reader , logs_exporter ):
212
213
client = openai .OpenAI ()
@@ -295,7 +296,7 @@ def test_chat_all_the_client_options(default_openai_env, trace_exporter, metrics
295
296
)
296
297
297
298
298
- @pytest .mark .skipif (OPENAI_VERSION < ( 1 , 40 , 0 ), reason = "beta completions added in 1.40.0" )
299
+ @pytest .mark .skipif (not HAS_BETA_CHAT_COMPLETIONS , reason = "beta completions added in 1.40.0, removed in 1.93 .0" )
299
300
@pytest .mark .vcr ()
300
301
def test_chat_multiple_choices_with_capture_message_content (
301
302
default_openai_env , trace_exporter , metrics_reader , logs_exporter
@@ -370,7 +371,7 @@ def test_chat_multiple_choices_with_capture_message_content(
370
371
)
371
372
372
373
373
- @pytest .mark .skipif (OPENAI_VERSION < ( 1 , 40 , 0 ), reason = "beta completions added in 1.40.0" )
374
+ @pytest .mark .skipif (not HAS_BETA_CHAT_COMPLETIONS , reason = "beta completions added in 1.40.0, removed in 1.93 .0" )
374
375
@pytest .mark .vcr ()
375
376
def test_chat_function_calling_with_tools (default_openai_env , trace_exporter , metrics_reader , logs_exporter ):
376
377
client = openai .OpenAI ()
@@ -473,7 +474,7 @@ def test_chat_function_calling_with_tools(default_openai_env, trace_exporter, me
473
474
)
474
475
475
476
476
- @pytest .mark .skipif (OPENAI_VERSION < ( 1 , 40 , 0 ), reason = "beta completions added in 1.40.0" )
477
+ @pytest .mark .skipif (not HAS_BETA_CHAT_COMPLETIONS , reason = "beta completions added in 1.40.0, removed in 1.93 .0" )
477
478
@pytest .mark .vcr ()
478
479
def test_chat_tools_with_capture_message_content (default_openai_env , trace_exporter , logs_exporter , metrics_reader ):
479
480
# Redo the instrumentation dance to be affected by the environment variable
@@ -584,7 +585,7 @@ def test_chat_tools_with_capture_message_content(default_openai_env, trace_expor
584
585
)
585
586
586
587
587
- @pytest .mark .skipif (OPENAI_VERSION < ( 1 , 40 , 0 ), reason = "beta completions added in 1.40.0" )
588
+ @pytest .mark .skipif (not HAS_BETA_CHAT_COMPLETIONS , reason = "beta completions added in 1.40.0, removed in 1.93 .0" )
588
589
@pytest .mark .integration
589
590
def test_chat_tools_with_capture_message_content_integration (trace_exporter , logs_exporter , metrics_reader ):
590
591
client = get_integration_client ()
@@ -695,7 +696,7 @@ def test_chat_tools_with_capture_message_content_integration(trace_exporter, log
695
696
)
696
697
697
698
698
- @pytest .mark .skipif (OPENAI_VERSION < ( 1 , 40 , 0 ), reason = "beta completions added in 1.40.0" )
699
+ @pytest .mark .skipif (not HAS_BETA_CHAT_COMPLETIONS , reason = "beta completions added in 1.40.0, removed in 1.93 .0" )
699
700
def test_chat_connection_error (default_openai_env , trace_exporter , metrics_reader , logs_exporter ):
700
701
client = openai .Client (base_url = "http://localhost:9999/v5" , api_key = "not-read" , max_retries = 1 )
701
702
messages = [
@@ -746,7 +747,7 @@ def test_chat_connection_error(default_openai_env, trace_exporter, metrics_reade
746
747
)
747
748
748
749
749
- @pytest .mark .skipif (OPENAI_VERSION < ( 1 , 40 , 0 ), reason = "beta completions added in 1.40.0" )
750
+ @pytest .mark .skipif (not HAS_BETA_CHAT_COMPLETIONS , reason = "beta completions added in 1.40.0, removed in 1.93 .0" )
750
751
@pytest .mark .integration
751
752
def test_chat_with_capture_message_content_integration (trace_exporter , logs_exporter , metrics_reader ):
752
753
model = os .getenv ("TEST_CHAT_MODEL" , TEST_CHAT_MODEL )
@@ -822,7 +823,7 @@ def test_chat_with_capture_message_content_integration(trace_exporter, logs_expo
822
823
)
823
824
824
825
825
- @pytest .mark .skipif (OPENAI_VERSION < ( 1 , 40 , 0 ), reason = "beta completions added in 1.40.0" )
826
+ @pytest .mark .skipif (not HAS_BETA_CHAT_COMPLETIONS , reason = "beta completions added in 1.40.0, removed in 1.93 .0" )
826
827
@pytest .mark .vcr ()
827
828
def test_chat_with_capture_message_content (default_openai_env , trace_exporter , logs_exporter , metrics_reader ):
828
829
client = openai .OpenAI ()
@@ -893,7 +894,7 @@ def test_chat_with_capture_message_content(default_openai_env, trace_exporter, l
893
894
)
894
895
895
896
896
- @pytest .mark .skipif (OPENAI_VERSION < ( 1 , 40 , 0 ), reason = "beta completions added in 1.40.0" )
897
+ @pytest .mark .skipif (not HAS_BETA_CHAT_COMPLETIONS , reason = "beta completions added in 1.40.0, removed in 1.93 .0" )
897
898
@pytest .mark .vcr ()
898
899
def test_chat_tools_with_followup_and_capture_message_content (
899
900
default_openai_env , trace_exporter , metrics_reader , logs_exporter
@@ -1065,7 +1066,7 @@ def test_chat_tools_with_followup_and_capture_message_content(
1065
1066
)
1066
1067
1067
1068
1068
- @pytest .mark .skipif (OPENAI_VERSION < ( 1 , 40 , 0 ), reason = "beta completions added in 1.40.0" )
1069
+ @pytest .mark .skipif (not HAS_BETA_CHAT_COMPLETIONS , reason = "beta completions added in 1.40.0, removed in 1.93 .0" )
1069
1070
@pytest .mark .asyncio
1070
1071
@pytest .mark .vcr ()
1071
1072
async def test_chat_async (default_openai_env , trace_exporter , metrics_reader , logs_exporter ):
@@ -1131,7 +1132,7 @@ async def test_chat_async(default_openai_env, trace_exporter, metrics_reader, lo
1131
1132
)
1132
1133
1133
1134
1134
- @pytest .mark .skipif (OPENAI_VERSION < ( 1 , 40 , 0 ), reason = "beta completions added in 1.40.0" )
1135
+ @pytest .mark .skipif (not HAS_BETA_CHAT_COMPLETIONS , reason = "beta completions added in 1.40.0, removed in 1.93 .0" )
1135
1136
@pytest .mark .asyncio
1136
1137
@pytest .mark .vcr ()
1137
1138
async def test_chat_async_with_capture_message_content (
@@ -1205,7 +1206,7 @@ async def test_chat_async_with_capture_message_content(
1205
1206
)
1206
1207
1207
1208
1208
- @pytest .mark .skipif (OPENAI_VERSION < ( 1 , 40 , 0 ), reason = "beta completions added in 1.40.0" )
1209
+ @pytest .mark .skipif (not HAS_BETA_CHAT_COMPLETIONS , reason = "beta completions added in 1.40.0, removed in 1.93 .0" )
1209
1210
@pytest .mark .integration
1210
1211
@pytest .mark .asyncio
1211
1212
async def test_chat_async_with_capture_message_content_integration (trace_exporter , logs_exporter , metrics_reader ):
@@ -1279,7 +1280,7 @@ async def test_chat_async_with_capture_message_content_integration(trace_exporte
1279
1280
)
1280
1281
1281
1282
1282
- @pytest .mark .skipif (OPENAI_VERSION < ( 1 , 40 , 0 ), reason = "beta completions added in 1.40.0" )
1283
+ @pytest .mark .skipif (not HAS_BETA_CHAT_COMPLETIONS , reason = "beta completions added in 1.40.0, removed in 1.93 .0" )
1283
1284
@pytest .mark .vcr ()
1284
1285
@pytest .mark .asyncio
1285
1286
async def test_chat_async_tools_with_capture_message_content (
@@ -1393,7 +1394,7 @@ async def test_chat_async_tools_with_capture_message_content(
1393
1394
)
1394
1395
1395
1396
1396
- @pytest .mark .skipif (OPENAI_VERSION < ( 1 , 40 , 0 ), reason = "beta completions added in 1.40.0" )
1397
+ @pytest .mark .skipif (not HAS_BETA_CHAT_COMPLETIONS , reason = "beta completions added in 1.40.0, removed in 1.93 .0" )
1397
1398
@pytest .mark .vcr ()
1398
1399
def test_chat_without_model_parameter (default_openai_env , trace_exporter , metrics_reader ):
1399
1400
client = openai .OpenAI ()
@@ -1439,7 +1440,7 @@ def test_chat_without_model_parameter(default_openai_env, trace_exporter, metric
1439
1440
)
1440
1441
1441
1442
1442
- @pytest .mark .skipif (OPENAI_VERSION < ( 1 , 40 , 0 ), reason = "beta completions added in 1.40.0" )
1443
+ @pytest .mark .skipif (not HAS_BETA_CHAT_COMPLETIONS , reason = "beta completions added in 1.40.0, removed in 1.93 .0" )
1443
1444
@pytest .mark .vcr ()
1444
1445
def test_chat_with_model_not_found (default_openai_env , trace_exporter , metrics_reader ):
1445
1446
client = openai .OpenAI ()
@@ -1485,7 +1486,7 @@ def test_chat_with_model_not_found(default_openai_env, trace_exporter, metrics_r
1485
1486
)
1486
1487
1487
1488
1488
- @pytest .mark .skipif (OPENAI_VERSION < ( 1 , 40 , 0 ), reason = "beta completions added in 1.40.0" )
1489
+ @pytest .mark .skipif (not HAS_BETA_CHAT_COMPLETIONS , reason = "beta completions added in 1.40.0, removed in 1.93 .0" )
1489
1490
@pytest .mark .vcr ()
1490
1491
def test_chat_exported_schema_version (default_openai_env , trace_exporter , metrics_reader ):
1491
1492
client = openai .OpenAI ()
@@ -1511,7 +1512,7 @@ def test_chat_exported_schema_version(default_openai_env, trace_exporter, metric
1511
1512
assert scope_metrics .schema_url == "https://opentelemetry.io/schemas/1.31.0"
1512
1513
1513
1514
1514
- @pytest .mark .skipif (OPENAI_VERSION < ( 1 , 40 , 0 ), reason = "beta completions added in 1.40.0" )
1515
+ @pytest .mark .skipif (not HAS_BETA_CHAT_COMPLETIONS , reason = "beta completions added in 1.40.0, removed in 1.93 .0" )
1515
1516
@pytest .mark .vcr ()
1516
1517
def test_parse_response_format_json_object_with_capture_message_content (
1517
1518
default_openai_env , trace_exporter , metrics_reader , logs_exporter
@@ -1588,7 +1589,7 @@ class Reason(BaseModel):
1588
1589
reason : str
1589
1590
1590
1591
1591
- @pytest .mark .skipif (OPENAI_VERSION < ( 1 , 40 , 0 ), reason = "beta completions added in 1.40.0" )
1592
+ @pytest .mark .skipif (not HAS_BETA_CHAT_COMPLETIONS , reason = "beta completions added in 1.40.0, removed in 1.93 .0" )
1592
1593
@pytest .mark .vcr ()
1593
1594
def test_parse_response_format_structured_output_with_capture_message_content (
1594
1595
default_openai_env , trace_exporter , metrics_reader , logs_exporter
0 commit comments