Skip to content

Commit acdf2f2

Browse files
committed
add async tests
1 parent 1be4a6b commit acdf2f2

13 files changed

+2236
-1
lines changed

Diff for: instrumentation-genai/opentelemetry-instrumentation-openai-v2/test-requirements-0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ importlib-metadata==6.11.0
55
packaging==24.0
66
pytest==7.4.4
77
pytest-vcr==1.0.2
8+
pytest-asyncio==0.21.0
89
wrapt==1.16.0
910
opentelemetry-api==1.28 # when updating, also update in pyproject.toml
1011
opentelemetry-sdk==1.28 # when updating, also update in pyproject.toml

Diff for: instrumentation-genai/opentelemetry-instrumentation-openai-v2/test-requirements-1.txt

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ importlib-metadata==6.11.0
55
packaging==24.0
66
pytest==7.4.4
77
pytest-vcr==1.0.2
8+
pytest-asyncio==0.21.0
89
wrapt==1.16.0
910
# test with the latest version of opentelemetry-api, sdk, and semantic conventions
1011

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
interactions:
2+
- request:
3+
body: '{"messages": [{"role": "user", "content": "Say this is a test"}], "model":
4+
"this-model-does-not-exist"}'
5+
headers:
6+
accept:
7+
- application/json
8+
accept-encoding:
9+
- gzip, deflate
10+
connection:
11+
- keep-alive
12+
content-length:
13+
- '103'
14+
content-type:
15+
- application/json
16+
host:
17+
- api.openai.com
18+
user-agent:
19+
- AsyncOpenAI/Python 1.26.0
20+
x-stainless-arch:
21+
- arm64
22+
x-stainless-async:
23+
- async:asyncio
24+
x-stainless-lang:
25+
- python
26+
x-stainless-os:
27+
- MacOS
28+
x-stainless-package-version:
29+
- 1.26.0
30+
x-stainless-runtime:
31+
- CPython
32+
x-stainless-runtime-version:
33+
- 3.12.5
34+
method: POST
35+
uri: https://api.openai.com/v1/chat/completions
36+
response:
37+
body:
38+
string: "{\n \"error\": {\n \"message\": \"The model `this-model-does-not-exist`
39+
does not exist or you do not have access to it.\",\n \"type\": \"invalid_request_error\",\n
40+
\ \"param\": null,\n \"code\": \"model_not_found\"\n }\n}\n"
41+
headers:
42+
CF-Cache-Status:
43+
- DYNAMIC
44+
CF-RAY:
45+
- 8df5e31d6e45e284-MRS
46+
Connection:
47+
- keep-alive
48+
Content-Type:
49+
- application/json; charset=utf-8
50+
Date:
51+
- Fri, 08 Nov 2024 13:25:06 GMT
52+
Server:
53+
- cloudflare
54+
Set-Cookie: test_set_cookie
55+
Transfer-Encoding:
56+
- chunked
57+
X-Content-Type-Options:
58+
- nosniff
59+
alt-svc:
60+
- h3=":443"; ma=86400
61+
content-length:
62+
- '231'
63+
openai-organization: test_organization
64+
strict-transport-security:
65+
- max-age=31536000; includeSubDomains; preload
66+
vary:
67+
- Origin
68+
x-request-id:
69+
- req_82c60ab486740fa07db9b846df2d532b
70+
status:
71+
code: 404
72+
message: Not Found
73+
version: 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
interactions:
2+
- request:
3+
body: '{"messages": [{"role": "user", "content": "Say this is a test"}], "model":
4+
"gpt-4o-mini", "max_tokens": 50, "seed": 42, "stream": false, "temperature":
5+
0.5, "service_tier": "default"}'
6+
headers:
7+
accept:
8+
- application/json
9+
accept-encoding:
10+
- gzip, deflate
11+
connection:
12+
- keep-alive
13+
content-length:
14+
- '183'
15+
content-type:
16+
- application/json
17+
host:
18+
- api.openai.com
19+
user-agent:
20+
- AsyncOpenAI/Python 1.26.0
21+
x-stainless-arch:
22+
- arm64
23+
x-stainless-async:
24+
- async:asyncio
25+
x-stainless-lang:
26+
- python
27+
x-stainless-os:
28+
- MacOS
29+
x-stainless-package-version:
30+
- 1.26.0
31+
x-stainless-runtime:
32+
- CPython
33+
x-stainless-runtime-version:
34+
- 3.12.5
35+
method: POST
36+
uri: https://api.openai.com/v1/chat/completions
37+
response:
38+
body:
39+
string: "{\n \"id\": \"chatcmpl-ARJJHh1NYn4MAJ5vmO2u6MC0QWvS3\",\n \"object\":
40+
\"chat.completion\",\n \"created\": 1731072447,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n
41+
\ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\":
42+
\"assistant\",\n \"content\": \"This is a test. How can I assist you
43+
further?\",\n \"refusal\": null\n },\n \"logprobs\": null,\n
44+
\ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\":
45+
12,\n \"completion_tokens\": 12,\n \"total_tokens\": 24,\n \"prompt_tokens_details\":
46+
{\n \"cached_tokens\": 0,\n \"audio_tokens\": 0\n },\n \"completion_tokens_details\":
47+
{\n \"reasoning_tokens\": 0,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\":
48+
0,\n \"rejected_prediction_tokens\": 0\n }\n },\n \"service_tier\":
49+
\"default\",\n \"system_fingerprint\": \"fp_0ba0d124f1\"\n}\n"
50+
headers:
51+
CF-Cache-Status:
52+
- DYNAMIC
53+
CF-RAY:
54+
- 8df5e68e7df7e20d-MRS
55+
Connection:
56+
- keep-alive
57+
Content-Type:
58+
- application/json
59+
Date:
60+
- Fri, 08 Nov 2024 13:27:28 GMT
61+
Server:
62+
- cloudflare
63+
Set-Cookie: test_set_cookie
64+
Transfer-Encoding:
65+
- chunked
66+
X-Content-Type-Options:
67+
- nosniff
68+
access-control-expose-headers:
69+
- X-Request-ID
70+
alt-svc:
71+
- h3=":443"; ma=86400
72+
content-length:
73+
- '825'
74+
openai-organization: test_organization
75+
openai-processing-ms:
76+
- '373'
77+
openai-version:
78+
- '2020-10-01'
79+
strict-transport-security:
80+
- max-age=31536000; includeSubDomains; preload
81+
x-ratelimit-limit-requests:
82+
- '30000'
83+
x-ratelimit-limit-tokens:
84+
- '150000000'
85+
x-ratelimit-remaining-requests:
86+
- '29999'
87+
x-ratelimit-remaining-tokens:
88+
- '149999943'
89+
x-ratelimit-reset-requests:
90+
- 2ms
91+
x-ratelimit-reset-tokens:
92+
- 0s
93+
x-request-id:
94+
- req_bea7292421fe218c0a9e158dbb7699d7
95+
status:
96+
code: 200
97+
message: OK
98+
version: 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
interactions:
2+
- request:
3+
body: '{"messages": [{"role": "user", "content": "Say this is a test"}], "model":
4+
"gpt-4o-mini", "n": 2, "stream": false}'
5+
headers:
6+
accept:
7+
- application/json
8+
accept-encoding:
9+
- gzip, deflate
10+
connection:
11+
- keep-alive
12+
content-length:
13+
- '114'
14+
content-type:
15+
- application/json
16+
host:
17+
- api.openai.com
18+
user-agent:
19+
- AsyncOpenAI/Python 1.26.0
20+
x-stainless-arch:
21+
- arm64
22+
x-stainless-async:
23+
- async:asyncio
24+
x-stainless-lang:
25+
- python
26+
x-stainless-os:
27+
- MacOS
28+
x-stainless-package-version:
29+
- 1.26.0
30+
x-stainless-runtime:
31+
- CPython
32+
x-stainless-runtime-version:
33+
- 3.12.5
34+
method: POST
35+
uri: https://api.openai.com/v1/chat/completions
36+
response:
37+
body:
38+
string: "{\n \"id\": \"chatcmpl-ARJJITAE6LSpkhJ4F6Lkgx1hjMWce\",\n \"object\":
39+
\"chat.completion\",\n \"created\": 1731072448,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n
40+
\ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\":
41+
\"assistant\",\n \"content\": \"This is a test.\",\n \"refusal\":
42+
null\n },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n
43+
\ },\n {\n \"index\": 1,\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\": 17,\n \"total_tokens\": 29,\n \"prompt_tokens_details\":
48+
{\n \"cached_tokens\": 0,\n \"audio_tokens\": 0\n },\n \"completion_tokens_details\":
49+
{\n \"reasoning_tokens\": 0,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\":
50+
0,\n \"rejected_prediction_tokens\": 0\n }\n },\n \"system_fingerprint\":
51+
\"fp_9b78b61c52\"\n}\n"
52+
headers:
53+
CF-Cache-Status:
54+
- DYNAMIC
55+
CF-RAY:
56+
- 8df5e692e8c9129a-MRS
57+
Connection:
58+
- keep-alive
59+
Content-Type:
60+
- application/json
61+
Date:
62+
- Fri, 08 Nov 2024 13:27:29 GMT
63+
Server:
64+
- cloudflare
65+
Set-Cookie: test_set_cookie
66+
Transfer-Encoding:
67+
- chunked
68+
X-Content-Type-Options:
69+
- nosniff
70+
access-control-expose-headers:
71+
- X-Request-ID
72+
alt-svc:
73+
- h3=":443"; ma=86400
74+
content-length:
75+
- '1000'
76+
openai-organization: test_organization
77+
openai-processing-ms:
78+
- '404'
79+
openai-version:
80+
- '2020-10-01'
81+
strict-transport-security:
82+
- max-age=31536000; includeSubDomains; preload
83+
x-ratelimit-limit-requests:
84+
- '30000'
85+
x-ratelimit-limit-tokens:
86+
- '150000000'
87+
x-ratelimit-remaining-requests:
88+
- '29999'
89+
x-ratelimit-remaining-tokens:
90+
- '149999962'
91+
x-ratelimit-reset-requests:
92+
- 2ms
93+
x-ratelimit-reset-tokens:
94+
- 0s
95+
x-request-id:
96+
- req_7d77cf85328e6feb1d9c2d52f2a69cfb
97+
status:
98+
code: 200
99+
message: OK
100+
version: 1

0 commit comments

Comments
 (0)