Skip to content

Commit dfe602d

Browse files
committed
relax changelog & adjust conftest
1 parent 2037ecc commit dfe602d

12 files changed

+850
-651
lines changed

instrumentation-genai/opentelemetry-instrumentation-openai-v2/CHANGELOG.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10-
- Added a wrapper for `AsyncCompletions.create` inside `src/opentelemetry/instrumentation/openai_v2/__init__.py` to instrument async chat completions
11-
- Created a new patch function for async chat completions
12-
- Abstracted handling span exceptions into it's own function as it was getting used in multiple places
13-
- Adjusted `StreamWrapper` to include async methods for supporting async streaming
14-
- Added Tests using `pytest-asyncio` fixtures
10+
- Support for `AsyncOpenAI/AsyncCompletions`
1511

1612
## Version 2.0b0 (2024-11-08)
1713

instrumentation-genai/opentelemetry-instrumentation-openai-v2/tests/cassettes/test_async_chat_completion_404.yaml

Lines changed: 22 additions & 8 deletions
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
@@ -35,20 +43,26 @@ interactions:
3543
uri: https://api.openai.com/v1/chat/completions
3644
response:
3745
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"
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+
}
4155
headers:
4256
CF-Cache-Status:
4357
- DYNAMIC
4458
CF-RAY:
45-
- 8df5e31d6e45e284-MRS
59+
- 8e0e20160ec6e17f-MRS
4660
Connection:
4761
- keep-alive
4862
Content-Type:
4963
- application/json; charset=utf-8
5064
Date:
51-
- Fri, 08 Nov 2024 13:25:06 GMT
65+
- Mon, 11 Nov 2024 12:01:02 GMT
5266
Server:
5367
- cloudflare
5468
Set-Cookie: test_set_cookie
@@ -66,7 +80,7 @@ interactions:
6680
vary:
6781
- Origin
6882
x-request-id:
69-
- req_82c60ab486740fa07db9b846df2d532b
83+
- req_93d359c0eeba1f2be7308d9132e82bf5
7084
status:
7185
code: 404
7286
message: Not Found

instrumentation-genai/opentelemetry-instrumentation-openai-v2/tests/cassettes/test_async_chat_completion_extra_params.yaml

Lines changed: 55 additions & 18 deletions
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, "stream": false, "temperature":
5-
0.5, "service_tier": "default"}'
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
@@ -36,28 +48,53 @@ interactions:
3648
uri: https://api.openai.com/v1/chat/completions
3749
response:
3850
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"
51+
string: |-
52+
{
53+
"id": "chatcmpl-ASNOJZk6WBJTYWmACy5zBiYnkvXAw",
54+
"object": "chat.completion",
55+
"created": 1731326463,
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+
"audio_tokens": 0
76+
},
77+
"completion_tokens_details": {
78+
"reasoning_tokens": 0,
79+
"audio_tokens": 0,
80+
"accepted_prediction_tokens": 0,
81+
"rejected_prediction_tokens": 0
82+
}
83+
},
84+
"service_tier": "default",
85+
"system_fingerprint": "fp_0ba0d124f1"
86+
}
5087
headers:
5188
CF-Cache-Status:
5289
- DYNAMIC
5390
CF-RAY:
54-
- 8df5e68e7df7e20d-MRS
91+
- 8e0e20191e7670e7-MRS
5592
Connection:
5693
- keep-alive
5794
Content-Type:
5895
- application/json
5996
Date:
60-
- Fri, 08 Nov 2024 13:27:28 GMT
97+
- Mon, 11 Nov 2024 12:01:03 GMT
6198
Server:
6299
- cloudflare
63100
Set-Cookie: test_set_cookie
@@ -73,7 +110,7 @@ interactions:
73110
- '825'
74111
openai-organization: test_organization
75112
openai-processing-ms:
76-
- '373'
113+
- '483'
77114
openai-version:
78115
- '2020-10-01'
79116
strict-transport-security:
@@ -91,7 +128,7 @@ interactions:
91128
x-ratelimit-reset-tokens:
92129
- 0s
93130
x-request-id:
94-
- req_bea7292421fe218c0a9e158dbb7699d7
131+
- req_bbcd55fb3044f058ea9f9ae8a388698d
95132
status:
96133
code: 200
97134
message: OK

instrumentation-genai/opentelemetry-instrumentation-openai-v2/tests/cassettes/test_async_chat_completion_multiple_choices.yaml

Lines changed: 62 additions & 21 deletions
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
@@ -35,31 +45,62 @@ interactions:
3545
uri: https://api.openai.com/v1/chat/completions
3646
response:
3747
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"
48+
string: |-
49+
{
50+
"id": "chatcmpl-ASNOJmzXWHqTArL7xMAtIJhIuu46p",
51+
"object": "chat.completion",
52+
"created": 1731326463,
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! How can I assist you further?",
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": 24,
79+
"total_tokens": 36,
80+
"prompt_tokens_details": {
81+
"cached_tokens": 0,
82+
"audio_tokens": 0
83+
},
84+
"completion_tokens_details": {
85+
"reasoning_tokens": 0,
86+
"audio_tokens": 0,
87+
"accepted_prediction_tokens": 0,
88+
"rejected_prediction_tokens": 0
89+
}
90+
},
91+
"system_fingerprint": "fp_0ba0d124f1"
92+
}
5293
headers:
5394
CF-Cache-Status:
5495
- DYNAMIC
5596
CF-RAY:
56-
- 8df5e692e8c9129a-MRS
97+
- 8e0e201e3de30771-MRS
5798
Connection:
5899
- keep-alive
59100
Content-Type:
60101
- application/json
61102
Date:
62-
- Fri, 08 Nov 2024 13:27:29 GMT
103+
- Mon, 11 Nov 2024 12:01:04 GMT
63104
Server:
64105
- cloudflare
65106
Set-Cookie: test_set_cookie
@@ -72,10 +113,10 @@ interactions:
72113
alt-svc:
73114
- h3=":443"; ma=86400
74115
content-length:
75-
- '1000'
116+
- '1030'
76117
openai-organization: test_organization
77118
openai-processing-ms:
78-
- '404'
119+
- '373'
79120
openai-version:
80121
- '2020-10-01'
81122
strict-transport-security:
@@ -93,7 +134,7 @@ interactions:
93134
x-ratelimit-reset-tokens:
94135
- 0s
95136
x-request-id:
96-
- req_7d77cf85328e6feb1d9c2d52f2a69cfb
137+
- req_d1f29830c9ae2a48e896be67a1edcfd6
97138
status:
98139
code: 200
99140
message: OK

0 commit comments

Comments
 (0)