Skip to content

Commit 17de112

Browse files
opentelemetry-instrumentation-openai-v2: format test data for readability (open-telemetry#2945)
* opentelemetry-instrumentation-openai-v2: format test data as YAML literal block scalar for readability Signed-off-by: Adrian Cole <[email protected]> * ruff Signed-off-by: Adrian Cole <[email protected]> * Update instrumentation/opentelemetry-instrumentation-openai-v2/tests/conftest.py Co-authored-by: Riccardo Magliocchetti <[email protected]> --------- Signed-off-by: Adrian Cole <[email protected]> Co-authored-by: Riccardo Magliocchetti <[email protected]>
1 parent 461593c commit 17de112

13 files changed

+1052
-795
lines changed

Diff for: instrumentation-genai/opentelemetry-instrumentation-openai-v2/tests/cassettes/test_chat_completion_404.yaml

+27-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
interactions:
22
- request:
3-
body: '{"messages": [{"role": "user", "content": "Say this is a test"}], "model":
4-
"this-model-does-not-exist"}'
3+
body: |-
4+
{
5+
"messages": [
6+
{
7+
"role": "user",
8+
"content": "Say this is a test"
9+
}
10+
],
11+
"model": "this-model-does-not-exist"
12+
}
513
headers:
614
accept:
715
- application/json
@@ -16,41 +24,45 @@ interactions:
1624
host:
1725
- api.openai.com
1826
user-agent:
19-
- OpenAI/Python 1.52.2
27+
- OpenAI/Python 1.26.0
2028
x-stainless-arch:
21-
- other:amd64
29+
- arm64
2230
x-stainless-async:
2331
- 'false'
2432
x-stainless-lang:
2533
- python
2634
x-stainless-os:
27-
- Windows
35+
- MacOS
2836
x-stainless-package-version:
29-
- 1.52.2
30-
x-stainless-retry-count:
31-
- '2'
37+
- 1.26.0
3238
x-stainless-runtime:
3339
- CPython
3440
x-stainless-runtime-version:
35-
- 3.12.7
41+
- 3.12.6
3642
method: POST
3743
uri: https://api.openai.com/v1/chat/completions
3844
response:
3945
body:
40-
string: "{\n \"error\": {\n \"message\": \"The model `this-model-does-not-exist`
41-
does not exist or you do not have access to it.\",\n \"type\": \"invalid_request_error\",\n
42-
\ \"param\": null,\n \"code\": \"model_not_found\"\n }\n}\n"
46+
string: |-
47+
{
48+
"error": {
49+
"message": "The model `this-model-does-not-exist` does not exist or you do not have access to it.",
50+
"type": "invalid_request_error",
51+
"param": null,
52+
"code": "model_not_found"
53+
}
54+
}
4355
headers:
4456
CF-Cache-Status:
4557
- DYNAMIC
4658
CF-RAY:
47-
- 8d88b04c2c5db9eb-SEA
59+
- 8dd0709dffd19c8c-SIN
4860
Connection:
4961
- keep-alive
5062
Content-Type:
5163
- application/json; charset=utf-8
5264
Date:
53-
- Sat, 26 Oct 2024 07:21:17 GMT
65+
- Mon, 04 Nov 2024 00:20:44 GMT
5466
Server:
5567
- cloudflare
5668
Set-Cookie: test_set_cookie
@@ -68,7 +80,7 @@ interactions:
6880
vary:
6981
- Origin
7082
x-request-id:
71-
- req_8529656422f0360e8bcba8c2b8fe34e9
83+
- req_e08854c4f7d5104af6fdc755caed30fc
7284
status:
7385
code: 404
7486
message: Not Found

Diff for: instrumentation-genai/opentelemetry-instrumentation-openai-v2/tests/cassettes/test_chat_completion_extra_params.yaml

+63-31
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
interactions:
22
- request:
3-
body: '{"messages": [{"role": "user", "content": "Say this is a test"}], "model":
4-
"gpt-4o-mini", "max_tokens": 50, "seed": 42, "service_tier": "auto", "stream":
5-
false, "temperature": 0.5}'
3+
body: |-
4+
{
5+
"messages": [
6+
{
7+
"role": "user",
8+
"content": "Say this is a test"
9+
}
10+
],
11+
"model": "gpt-4o-mini",
12+
"max_tokens": 50,
13+
"seed": 42,
14+
"stream": false,
15+
"temperature": 0.5,
16+
"service_tier": "default"
17+
}
618
headers:
719
accept:
820
- application/json
@@ -11,54 +23,74 @@ interactions:
1123
connection:
1224
- keep-alive
1325
content-length:
14-
- '180'
26+
- '183'
1527
content-type:
1628
- application/json
1729
host:
1830
- api.openai.com
1931
user-agent:
20-
- OpenAI/Python 1.52.2
32+
- OpenAI/Python 1.26.0
2133
x-stainless-arch:
22-
- other:amd64
34+
- arm64
2335
x-stainless-async:
2436
- 'false'
2537
x-stainless-lang:
2638
- python
2739
x-stainless-os:
28-
- Windows
40+
- MacOS
2941
x-stainless-package-version:
30-
- 1.52.2
31-
x-stainless-retry-count:
32-
- '0'
42+
- 1.26.0
3343
x-stainless-runtime:
3444
- CPython
3545
x-stainless-runtime-version:
36-
- 3.12.7
46+
- 3.12.6
3747
method: POST
3848
uri: https://api.openai.com/v1/chat/completions
3949
response:
4050
body:
41-
string: "{\n \"id\": \"chatcmpl-AMTlCEj20ZcsgWKZt8EizFMDItWNf\",\n \"object\":
42-
\"chat.completion\",\n \"created\": 1729920978,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n
43-
\ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\":
44-
\"assistant\",\n \"content\": \"This is a test. How can I assist you
45-
further?\",\n \"refusal\": null\n },\n \"logprobs\": null,\n
46-
\ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\":
47-
12,\n \"completion_tokens\": 12,\n \"total_tokens\": 24,\n \"prompt_tokens_details\":
48-
{\n \"cached_tokens\": 0\n },\n \"completion_tokens_details\":
49-
{\n \"reasoning_tokens\": 0\n }\n },\n \"service_tier\": \"default\",\n
50-
\ \"system_fingerprint\": \"fp_f59a81427f\"\n}\n"
51+
string: |-
52+
{
53+
"id": "chatcmpl-APfFNvBVQx43PNOIf1dWnEUT5u5fA",
54+
"object": "chat.completion",
55+
"created": 1730680117,
56+
"model": "gpt-4o-mini-2024-07-18",
57+
"choices": [
58+
{
59+
"index": 0,
60+
"message": {
61+
"role": "assistant",
62+
"content": "This is a test. How can I assist you further?",
63+
"refusal": null
64+
},
65+
"logprobs": null,
66+
"finish_reason": "stop"
67+
}
68+
],
69+
"usage": {
70+
"prompt_tokens": 12,
71+
"completion_tokens": 12,
72+
"total_tokens": 24,
73+
"prompt_tokens_details": {
74+
"cached_tokens": 0
75+
},
76+
"completion_tokens_details": {
77+
"reasoning_tokens": 0
78+
}
79+
},
80+
"service_tier": "default",
81+
"system_fingerprint": "fp_0ba0d124f1"
82+
}
5183
headers:
5284
CF-Cache-Status:
5385
- DYNAMIC
5486
CF-RAY:
55-
- 8d881682197c7571-SEA
87+
- 8dd07c2d0a5a9f98-SIN
5688
Connection:
5789
- keep-alive
5890
Content-Type:
5991
- application/json
6092
Date:
61-
- Sat, 26 Oct 2024 05:36:18 GMT
93+
- Mon, 04 Nov 2024 00:28:37 GMT
6294
Server:
6395
- cloudflare
6496
Set-Cookie: test_set_cookie
@@ -74,25 +106,25 @@ interactions:
74106
- '697'
75107
openai-organization: test_organization
76108
openai-processing-ms:
77-
- '275'
109+
- '228'
78110
openai-version:
79111
- '2020-10-01'
80112
strict-transport-security:
81113
- max-age=31536000; includeSubDomains; preload
82114
x-ratelimit-limit-requests:
83-
- '200'
115+
- '10000'
84116
x-ratelimit-limit-tokens:
85-
- '60000'
117+
- '200000'
86118
x-ratelimit-remaining-requests:
87-
- '195'
119+
- '9998'
88120
x-ratelimit-remaining-tokens:
89-
- '59944'
121+
- '199943'
90122
x-ratelimit-reset-requests:
91-
- 32m17.492s
123+
- 13.724s
92124
x-ratelimit-reset-tokens:
93-
- 56ms
125+
- 16ms
94126
x-request-id:
95-
- req_181075e8f861d6685fe1ae5d4bfc9b25
127+
- req_0ded46a4535c24c36ef58363b7538421
96128
status:
97129
code: 200
98130
message: OK

Diff for: instrumentation-genai/opentelemetry-instrumentation-openai-v2/tests/cassettes/test_chat_completion_multiple_choices.yaml

+68-31
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
interactions:
22
- request:
3-
body: '{"messages": [{"role": "user", "content": "Say this is a test"}], "model":
4-
"gpt-4o-mini", "n": 2, "stream": false}'
3+
body: |-
4+
{
5+
"messages": [
6+
{
7+
"role": "user",
8+
"content": "Say this is a test"
9+
}
10+
],
11+
"model": "gpt-4o-mini",
12+
"n": 2,
13+
"stream": false
14+
}
515
headers:
616
accept:
717
- application/json
@@ -16,50 +26,77 @@ interactions:
1626
host:
1727
- api.openai.com
1828
user-agent:
19-
- OpenAI/Python 1.52.2
29+
- OpenAI/Python 1.26.0
2030
x-stainless-arch:
21-
- other:amd64
31+
- arm64
2232
x-stainless-async:
2333
- 'false'
2434
x-stainless-lang:
2535
- python
2636
x-stainless-os:
27-
- Windows
37+
- MacOS
2838
x-stainless-package-version:
29-
- 1.52.2
30-
x-stainless-retry-count:
31-
- '0'
39+
- 1.26.0
3240
x-stainless-runtime:
3341
- CPython
3442
x-stainless-runtime-version:
35-
- 3.12.7
43+
- 3.12.6
3644
method: POST
3745
uri: https://api.openai.com/v1/chat/completions
3846
response:
3947
body:
40-
string: "{\n \"id\": \"chatcmpl-AMT4dWD9gi2PyDcXBK10harskeREO\",\n \"object\":
41-
\"chat.completion\",\n \"created\": 1729918339,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n
42-
\ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\":
43-
\"assistant\",\n \"content\": \"This is a test.\",\n \"refusal\":
44-
null\n },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n
45-
\ },\n {\n \"index\": 1,\n \"message\": {\n \"role\":
46-
\"assistant\",\n \"content\": \"This is a test. How can I assist you
47-
further?\",\n \"refusal\": null\n },\n \"logprobs\": null,\n
48-
\ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\":
49-
12,\n \"completion_tokens\": 17,\n \"total_tokens\": 29,\n \"prompt_tokens_details\":
50-
{\n \"cached_tokens\": 0\n },\n \"completion_tokens_details\":
51-
{\n \"reasoning_tokens\": 0\n }\n },\n \"system_fingerprint\": \"fp_f59a81427f\"\n}\n"
48+
string: |-
49+
{
50+
"id": "chatcmpl-APfFO3w0cNVOphe5Lk9EaYyRaS2pm",
51+
"object": "chat.completion",
52+
"created": 1730680118,
53+
"model": "gpt-4o-mini-2024-07-18",
54+
"choices": [
55+
{
56+
"index": 0,
57+
"message": {
58+
"role": "assistant",
59+
"content": "This is a test.",
60+
"refusal": null
61+
},
62+
"logprobs": null,
63+
"finish_reason": "stop"
64+
},
65+
{
66+
"index": 1,
67+
"message": {
68+
"role": "assistant",
69+
"content": "This is a test! How can I assist you further?",
70+
"refusal": null
71+
},
72+
"logprobs": null,
73+
"finish_reason": "stop"
74+
}
75+
],
76+
"usage": {
77+
"prompt_tokens": 12,
78+
"completion_tokens": 17,
79+
"total_tokens": 29,
80+
"prompt_tokens_details": {
81+
"cached_tokens": 0
82+
},
83+
"completion_tokens_details": {
84+
"reasoning_tokens": 0
85+
}
86+
},
87+
"system_fingerprint": "fp_0ba0d124f1"
88+
}
5289
headers:
5390
CF-Cache-Status:
5491
- DYNAMIC
5592
CF-RAY:
56-
- 8d87d6120a899357-SEA
93+
- 8dd07c30beda3dd4-SIN
5794
Connection:
5895
- keep-alive
5996
Content-Type:
6097
- application/json
6198
Date:
62-
- Sat, 26 Oct 2024 04:52:19 GMT
99+
- Mon, 04 Nov 2024 00:28:38 GMT
63100
Server:
64101
- cloudflare
65102
Set-Cookie: test_set_cookie
@@ -75,25 +112,25 @@ interactions:
75112
- '872'
76113
openai-organization: test_organization
77114
openai-processing-ms:
78-
- '664'
115+
- '261'
79116
openai-version:
80117
- '2020-10-01'
81118
strict-transport-security:
82119
- max-age=31536000; includeSubDomains; preload
83120
x-ratelimit-limit-requests:
84-
- '200'
121+
- '10000'
85122
x-ratelimit-limit-tokens:
86-
- '60000'
123+
- '200000'
87124
x-ratelimit-remaining-requests:
88-
- '199'
125+
- '9997'
89126
x-ratelimit-remaining-tokens:
90-
- '59962'
127+
- '199962'
91128
x-ratelimit-reset-requests:
92-
- 7m12s
129+
- 21.785s
93130
x-ratelimit-reset-tokens:
94-
- 38ms
131+
- 11ms
95132
x-request-id:
96-
- req_d8b7a2507994f22fe0d4511c7e0a3bdc
133+
- req_86ab6a7a85f95e2a001cfeb89e0827b1
97134
status:
98135
code: 200
99136
message: OK

0 commit comments

Comments
 (0)