Skip to content

Commit

Permalink
opentelemetry-instrumentation-openai-v2: format test data for readabi…
Browse files Browse the repository at this point in the history
…lity (#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]>
  • Loading branch information
codefromthecrypt and xrmx authored Nov 5, 2024
1 parent 155962b commit d6a59e4
Show file tree
Hide file tree
Showing 13 changed files with 1,052 additions and 795 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
interactions:
- request:
body: '{"messages": [{"role": "user", "content": "Say this is a test"}], "model":
"this-model-does-not-exist"}'
body: |-
{
"messages": [
{
"role": "user",
"content": "Say this is a test"
}
],
"model": "this-model-does-not-exist"
}
headers:
accept:
- application/json
Expand All @@ -16,41 +24,45 @@ interactions:
host:
- api.openai.com
user-agent:
- OpenAI/Python 1.52.2
- OpenAI/Python 1.26.0
x-stainless-arch:
- other:amd64
- arm64
x-stainless-async:
- 'false'
x-stainless-lang:
- python
x-stainless-os:
- Windows
- MacOS
x-stainless-package-version:
- 1.52.2
x-stainless-retry-count:
- '2'
- 1.26.0
x-stainless-runtime:
- CPython
x-stainless-runtime-version:
- 3.12.7
- 3.12.6
method: POST
uri: https://api.openai.com/v1/chat/completions
response:
body:
string: "{\n \"error\": {\n \"message\": \"The model `this-model-does-not-exist`
does not exist or you do not have access to it.\",\n \"type\": \"invalid_request_error\",\n
\ \"param\": null,\n \"code\": \"model_not_found\"\n }\n}\n"
string: |-
{
"error": {
"message": "The model `this-model-does-not-exist` does not exist or you do not have access to it.",
"type": "invalid_request_error",
"param": null,
"code": "model_not_found"
}
}
headers:
CF-Cache-Status:
- DYNAMIC
CF-RAY:
- 8d88b04c2c5db9eb-SEA
- 8dd0709dffd19c8c-SIN
Connection:
- keep-alive
Content-Type:
- application/json; charset=utf-8
Date:
- Sat, 26 Oct 2024 07:21:17 GMT
- Mon, 04 Nov 2024 00:20:44 GMT
Server:
- cloudflare
Set-Cookie: test_set_cookie
Expand All @@ -68,7 +80,7 @@ interactions:
vary:
- Origin
x-request-id:
- req_8529656422f0360e8bcba8c2b8fe34e9
- req_e08854c4f7d5104af6fdc755caed30fc
status:
code: 404
message: Not Found
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
interactions:
- request:
body: '{"messages": [{"role": "user", "content": "Say this is a test"}], "model":
"gpt-4o-mini", "max_tokens": 50, "seed": 42, "service_tier": "auto", "stream":
false, "temperature": 0.5}'
body: |-
{
"messages": [
{
"role": "user",
"content": "Say this is a test"
}
],
"model": "gpt-4o-mini",
"max_tokens": 50,
"seed": 42,
"stream": false,
"temperature": 0.5,
"service_tier": "default"
}
headers:
accept:
- application/json
Expand All @@ -11,54 +23,74 @@ interactions:
connection:
- keep-alive
content-length:
- '180'
- '183'
content-type:
- application/json
host:
- api.openai.com
user-agent:
- OpenAI/Python 1.52.2
- OpenAI/Python 1.26.0
x-stainless-arch:
- other:amd64
- arm64
x-stainless-async:
- 'false'
x-stainless-lang:
- python
x-stainless-os:
- Windows
- MacOS
x-stainless-package-version:
- 1.52.2
x-stainless-retry-count:
- '0'
- 1.26.0
x-stainless-runtime:
- CPython
x-stainless-runtime-version:
- 3.12.7
- 3.12.6
method: POST
uri: https://api.openai.com/v1/chat/completions
response:
body:
string: "{\n \"id\": \"chatcmpl-AMTlCEj20ZcsgWKZt8EizFMDItWNf\",\n \"object\":
\"chat.completion\",\n \"created\": 1729920978,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n
\ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\":
\"assistant\",\n \"content\": \"This is a test. How can I assist you
further?\",\n \"refusal\": null\n },\n \"logprobs\": null,\n
\ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\":
12,\n \"completion_tokens\": 12,\n \"total_tokens\": 24,\n \"prompt_tokens_details\":
{\n \"cached_tokens\": 0\n },\n \"completion_tokens_details\":
{\n \"reasoning_tokens\": 0\n }\n },\n \"service_tier\": \"default\",\n
\ \"system_fingerprint\": \"fp_f59a81427f\"\n}\n"
string: |-
{
"id": "chatcmpl-APfFNvBVQx43PNOIf1dWnEUT5u5fA",
"object": "chat.completion",
"created": 1730680117,
"model": "gpt-4o-mini-2024-07-18",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "This is a test. How can I assist you further?",
"refusal": null
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 12,
"total_tokens": 24,
"prompt_tokens_details": {
"cached_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 0
}
},
"service_tier": "default",
"system_fingerprint": "fp_0ba0d124f1"
}
headers:
CF-Cache-Status:
- DYNAMIC
CF-RAY:
- 8d881682197c7571-SEA
- 8dd07c2d0a5a9f98-SIN
Connection:
- keep-alive
Content-Type:
- application/json
Date:
- Sat, 26 Oct 2024 05:36:18 GMT
- Mon, 04 Nov 2024 00:28:37 GMT
Server:
- cloudflare
Set-Cookie: test_set_cookie
Expand All @@ -74,25 +106,25 @@ interactions:
- '697'
openai-organization: test_organization
openai-processing-ms:
- '275'
- '228'
openai-version:
- '2020-10-01'
strict-transport-security:
- max-age=31536000; includeSubDomains; preload
x-ratelimit-limit-requests:
- '200'
- '10000'
x-ratelimit-limit-tokens:
- '60000'
- '200000'
x-ratelimit-remaining-requests:
- '195'
- '9998'
x-ratelimit-remaining-tokens:
- '59944'
- '199943'
x-ratelimit-reset-requests:
- 32m17.492s
- 13.724s
x-ratelimit-reset-tokens:
- 56ms
- 16ms
x-request-id:
- req_181075e8f861d6685fe1ae5d4bfc9b25
- req_0ded46a4535c24c36ef58363b7538421
status:
code: 200
message: OK
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
interactions:
- request:
body: '{"messages": [{"role": "user", "content": "Say this is a test"}], "model":
"gpt-4o-mini", "n": 2, "stream": false}'
body: |-
{
"messages": [
{
"role": "user",
"content": "Say this is a test"
}
],
"model": "gpt-4o-mini",
"n": 2,
"stream": false
}
headers:
accept:
- application/json
Expand All @@ -16,50 +26,77 @@ interactions:
host:
- api.openai.com
user-agent:
- OpenAI/Python 1.52.2
- OpenAI/Python 1.26.0
x-stainless-arch:
- other:amd64
- arm64
x-stainless-async:
- 'false'
x-stainless-lang:
- python
x-stainless-os:
- Windows
- MacOS
x-stainless-package-version:
- 1.52.2
x-stainless-retry-count:
- '0'
- 1.26.0
x-stainless-runtime:
- CPython
x-stainless-runtime-version:
- 3.12.7
- 3.12.6
method: POST
uri: https://api.openai.com/v1/chat/completions
response:
body:
string: "{\n \"id\": \"chatcmpl-AMT4dWD9gi2PyDcXBK10harskeREO\",\n \"object\":
\"chat.completion\",\n \"created\": 1729918339,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n
\ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\":
\"assistant\",\n \"content\": \"This is a test.\",\n \"refusal\":
null\n },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n
\ },\n {\n \"index\": 1,\n \"message\": {\n \"role\":
\"assistant\",\n \"content\": \"This is a test. How can I assist you
further?\",\n \"refusal\": null\n },\n \"logprobs\": null,\n
\ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\":
12,\n \"completion_tokens\": 17,\n \"total_tokens\": 29,\n \"prompt_tokens_details\":
{\n \"cached_tokens\": 0\n },\n \"completion_tokens_details\":
{\n \"reasoning_tokens\": 0\n }\n },\n \"system_fingerprint\": \"fp_f59a81427f\"\n}\n"
string: |-
{
"id": "chatcmpl-APfFO3w0cNVOphe5Lk9EaYyRaS2pm",
"object": "chat.completion",
"created": 1730680118,
"model": "gpt-4o-mini-2024-07-18",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "This is a test.",
"refusal": null
},
"logprobs": null,
"finish_reason": "stop"
},
{
"index": 1,
"message": {
"role": "assistant",
"content": "This is a test! How can I assist you further?",
"refusal": null
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 17,
"total_tokens": 29,
"prompt_tokens_details": {
"cached_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 0
}
},
"system_fingerprint": "fp_0ba0d124f1"
}
headers:
CF-Cache-Status:
- DYNAMIC
CF-RAY:
- 8d87d6120a899357-SEA
- 8dd07c30beda3dd4-SIN
Connection:
- keep-alive
Content-Type:
- application/json
Date:
- Sat, 26 Oct 2024 04:52:19 GMT
- Mon, 04 Nov 2024 00:28:38 GMT
Server:
- cloudflare
Set-Cookie: test_set_cookie
Expand All @@ -75,25 +112,25 @@ interactions:
- '872'
openai-organization: test_organization
openai-processing-ms:
- '664'
- '261'
openai-version:
- '2020-10-01'
strict-transport-security:
- max-age=31536000; includeSubDomains; preload
x-ratelimit-limit-requests:
- '200'
- '10000'
x-ratelimit-limit-tokens:
- '60000'
- '200000'
x-ratelimit-remaining-requests:
- '199'
- '9997'
x-ratelimit-remaining-tokens:
- '59962'
- '199962'
x-ratelimit-reset-requests:
- 7m12s
- 21.785s
x-ratelimit-reset-tokens:
- 38ms
- 11ms
x-request-id:
- req_d8b7a2507994f22fe0d4511c7e0a3bdc
- req_86ab6a7a85f95e2a001cfeb89e0827b1
status:
code: 200
message: OK
Expand Down
Loading

0 comments on commit d6a59e4

Please sign in to comment.