Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Commit

Permalink
chore: make vcr tests pretty-print JSON (block#146)
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Cole <[email protected]>
  • Loading branch information
codefromthecrypt authored Oct 15, 2024
1 parent e165981 commit e687b0b
Show file tree
Hide file tree
Showing 16 changed files with 756 additions and 184 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
interactions:
- request:
body: '{"messages": [{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello"}], "model": "gpt-4o-mini"}'
body: |-
{
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello"
}
],
"model": "gpt-4o-mini"
}
headers:
accept:
- '*/*'
Expand All @@ -23,35 +35,94 @@ interactions:
uri: https://test.openai.azure.com/openai/deployments/test-azure-deployment/chat/completions?api-version=2024-05-01-preview
response:
body:
string: '{"choices":[{"content_filter_results":{"hate":{"filtered":false,"severity":"safe"},"self_harm":{"filtered":false,"severity":"safe"},"sexual":{"filtered":false,"severity":"safe"},"violence":{"filtered":false,"severity":"safe"}},"finish_reason":"stop","index":0,"logprobs":null,"message":{"content":"Hello!
How can I assist you today?","role":"assistant"}}],"created":1727230065,"id":"chatcmpl-ABBjN3AoYlxkP7Vg2lBvUhYeA6j5K","model":"gpt-4-32k","object":"chat.completion","prompt_filter_results":[{"prompt_index":0,"content_filter_results":{"hate":{"filtered":false,"severity":"safe"},"self_harm":{"filtered":false,"severity":"safe"},"sexual":{"filtered":false,"severity":"safe"},"violence":{"filtered":false,"severity":"safe"}}}],"system_fingerprint":null,"usage":{"completion_tokens":9,"prompt_tokens":18,"total_tokens":27}}
'
string: |-
{
"choices": [
{
"content_filter_results": {
"hate": {
"filtered": false,
"severity": "safe"
},
"self_harm": {
"filtered": false,
"severity": "safe"
},
"sexual": {
"filtered": false,
"severity": "safe"
},
"violence": {
"filtered": false,
"severity": "safe"
}
},
"finish_reason": "stop",
"index": 0,
"logprobs": null,
"message": {
"content": "Hello! How can I assist you today?\n",
"role": "assistant"
}
}
],
"created": 1728788170,
"id": "chatcmpl-AHj469gGa9bQaCSikrZYDejfGDx2x",
"model": "gpt-4-32k",
"object": "chat.completion",
"prompt_filter_results": [
{
"prompt_index": 0,
"content_filter_results": {
"hate": {
"filtered": false,
"severity": "safe"
},
"self_harm": {
"filtered": false,
"severity": "safe"
},
"sexual": {
"filtered": false,
"severity": "safe"
},
"violence": {
"filtered": false,
"severity": "safe"
}
}
}
],
"system_fingerprint": null,
"usage": {
"completion_tokens": 9,
"prompt_tokens": 18,
"total_tokens": 27
}
}
headers:
Cache-Control:
- no-cache, must-revalidate
Content-Length:
- '825'
- '827'
Content-Type:
- application/json
Date:
- Wed, 25 Sep 2024 02:07:45 GMT
Set-Cookie: test_set_cookie
- Sun, 13 Oct 2024 02:56:10 GMT
Strict-Transport-Security:
- max-age=31536000; includeSubDomains; preload
access-control-allow-origin:
- '*'
apim-request-id:
- 82e66ef8-ac07-4a43-b60f-9aecec1d8c81
- b203f657-e7aa-40ea-8969-ba0b83dae854
azureml-model-session:
- d145-20240919052126
openai-organization: test_openai_org_key
- d156-20241010120317
x-accel-buffering:
- 'no'
x-content-type-options:
- nosniff
x-ms-client-request-id:
- 82e66ef8-ac07-4a43-b60f-9aecec1d8c81
- b203f657-e7aa-40ea-8969-ba0b83dae854
x-ms-rai-invoked:
- 'true'
x-ms-region:
Expand All @@ -61,7 +132,7 @@ interactions:
x-ratelimit-remaining-tokens:
- '79984'
x-request-id:
- 38db9001-8b16-4efe-84c9-620e10f18c3c
- 0c6dc92f-a017-4879-b82e-be937533c76e
status:
code: 200
message: OK
Expand Down
121 changes: 100 additions & 21 deletions packages/exchange/tests/providers/cassettes/test_azure_tools.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,40 @@
interactions:
- request:
body: '{"messages": [{"role": "system", "content": "You are a helpful assistant.
Expect to need to read a file using read_file."}, {"role": "user", "content":
"What are the contents of this file? test.txt"}], "model": "gpt-4o-mini", "tools":
[{"type": "function", "function": {"name": "read_file", "description": "Read
the contents of the file.", "parameters": {"type": "object", "properties": {"filename":
{"type": "string", "description": "The path to the file, which can be relative
or\nabsolute. If it is a plain filename, it is assumed to be in the\ncurrent
working directory."}}, "required": ["filename"]}}}]}'
body: |-
{
"messages": [
{
"role": "system",
"content": "You are a helpful assistant. Expect to need to read a file using read_file."
},
{
"role": "user",
"content": "What are the contents of this file? test.txt"
}
],
"model": "gpt-4o-mini",
"tools": [
{
"type": "function",
"function": {
"name": "read_file",
"description": "Read the contents of the file.",
"parameters": {
"type": "object",
"properties": {
"filename": {
"type": "string",
"description": "The path to the file, which can be relative or\nabsolute. If it is a plain filename, it is assumed to be in the\ncurrent working directory."
}
},
"required": [
"filename"
]
}
}
}
]
}
headers:
accept:
- '*/*'
Expand All @@ -29,10 +56,64 @@ interactions:
uri: https://test.openai.azure.com/openai/deployments/test-azure-deployment/chat/completions?api-version=2024-05-01-preview
response:
body:
string: '{"choices":[{"content_filter_results":{},"finish_reason":"tool_calls","index":0,"logprobs":null,"message":{"content":null,"role":"assistant","tool_calls":[{"function":{"arguments":"{\n \"filename\":
\"test.txt\"\n}","name":"read_file"},"id":"call_a47abadDxlGKIWjvYYvGVAHa","type":"function"}]}}],"created":1727256650,"id":"chatcmpl-ABIeABbq5WVCq0e0AriGFaYDSih3P","model":"gpt-4-32k","object":"chat.completion","prompt_filter_results":[{"prompt_index":0,"content_filter_results":{"hate":{"filtered":false,"severity":"safe"},"self_harm":{"filtered":false,"severity":"safe"},"sexual":{"filtered":false,"severity":"safe"},"violence":{"filtered":false,"severity":"safe"}}}],"system_fingerprint":null,"usage":{"completion_tokens":16,"prompt_tokens":109,"total_tokens":125}}
'
string: |-
{
"choices": [
{
"content_filter_results": {},
"finish_reason": "tool_calls",
"index": 0,
"logprobs": null,
"message": {
"content": null,
"role": "assistant",
"tool_calls": [
{
"function": {
"arguments": "{\n \"filename\": \"test.txt\"\n}",
"name": "read_file"
},
"id": "call_Dn0idyNSdmHSYpsql3EbFH9L",
"type": "function"
}
]
}
}
],
"created": 1728788173,
"id": "chatcmpl-AHj498XEBkixukw2lwNReXCIBStp0",
"model": "gpt-4-32k",
"object": "chat.completion",
"prompt_filter_results": [
{
"prompt_index": 0,
"content_filter_results": {
"hate": {
"filtered": false,
"severity": "safe"
},
"self_harm": {
"filtered": false,
"severity": "safe"
},
"sexual": {
"filtered": false,
"severity": "safe"
},
"violence": {
"filtered": false,
"severity": "safe"
}
}
}
],
"system_fingerprint": null,
"usage": {
"completion_tokens": 16,
"prompt_tokens": 109,
"total_tokens": 125
}
}
headers:
Cache-Control:
- no-cache, must-revalidate
Expand All @@ -41,33 +122,31 @@ interactions:
Content-Type:
- application/json
Date:
- Wed, 25 Sep 2024 09:30:50 GMT
Set-Cookie: test_set_cookie
- Sun, 13 Oct 2024 02:56:14 GMT
Strict-Transport-Security:
- max-age=31536000; includeSubDomains; preload
access-control-allow-origin:
- '*'
apim-request-id:
- 8c0e3372-8ffd-4ff5-a5d1-0b962c4ea339
- 0e0af575-5634-415c-88e3-a7bf68549ee5
azureml-model-session:
- d145-20240919052126
openai-organization: test_openai_org_key
- d159-20241010142543
x-accel-buffering:
- 'no'
x-content-type-options:
- nosniff
x-ms-client-request-id:
- 8c0e3372-8ffd-4ff5-a5d1-0b962c4ea339
- 0e0af575-5634-415c-88e3-a7bf68549ee5
x-ms-rai-invoked:
- 'true'
x-ms-region:
- Switzerland North
x-ratelimit-remaining-requests:
- '79'
- '77'
x-ratelimit-remaining-tokens:
- '79824'
- '79952'
x-request-id:
- 401bd803-b790-47b7-b098-98708d44f060
- e5012889-ef86-449a-908c-2065dbf0954e
status:
code: 200
message: OK
Expand Down
Loading

0 comments on commit e687b0b

Please sign in to comment.