Skip to content

Commit

Permalink
Adds tests for use_cases.py
Browse files Browse the repository at this point in the history
  • Loading branch information
amandasavluchinske committed Jun 19, 2024
1 parent 0567f96 commit e738808
Show file tree
Hide file tree
Showing 2 changed files with 502 additions and 0 deletions.
186 changes: 186 additions & 0 deletions tests/cassettes/test_use_cases/test_create_message.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
interactions:
- request:
body: '{"messages": [{"content": "You are a temperature bot. Today is 2024-06-09.",
"role": "system"}, {"content": "Hello, will I have to use my umbrella in Lisbon
tomorrow?", "role": "user"}], "model": "gpt-4o", "n": 1, "stream": true, "temperature":
1.0, "tools": [{"type": "function", "function": {"name": "fetch_current_temperature",
"description": "Fetch the current temperature data for a location", "parameters":
{"type": "object", "properties": {"location": {"type": "string"}}, "required":
["location"]}}}, {"type": "function", "function": {"name": "fetch_forecast_temperature",
"description": "Fetch the forecast temperature data for a location", "parameters":
{"type": "object", "properties": {"location": {"type": "string"}, "dt_str":
{"description": "Date in the format ''YYYY-MM-DD''", "type": "string"}}, "required":
["location", "dt_str"]}}}]}'
headers:
accept:
- application/json
accept-encoding:
- gzip, deflate
authorization:
- DUMMY
connection:
- keep-alive
content-length:
- '850'
content-type:
- application/json
host:
- api.openai.com
user-agent:
- OpenAI/Python
method: POST
uri: https://api.openai.com/v1/chat/completions
response:
body:
string: 'data: {"id":"chatcmpl-9bvL2OSkYxLeUXjmNVgWPgkaSjD1X","object":"chat.completion.chunk","created":1718825572,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_pPh34DYupF8tPgILgMxPHyBD","type":"function","function":{"name":"fetch_forecast_temperature","arguments":""}}]},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bvL2OSkYxLeUXjmNVgWPgkaSjD1X","object":"chat.completion.chunk","created":1718825572,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bvL2OSkYxLeUXjmNVgWPgkaSjD1X","object":"chat.completion.chunk","created":1718825572,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"location"}}]},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bvL2OSkYxLeUXjmNVgWPgkaSjD1X","object":"chat.completion.chunk","created":1718825572,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bvL2OSkYxLeUXjmNVgWPgkaSjD1X","object":"chat.completion.chunk","created":1718825572,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Lis"}}]},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bvL2OSkYxLeUXjmNVgWPgkaSjD1X","object":"chat.completion.chunk","created":1718825572,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"bon"}}]},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bvL2OSkYxLeUXjmNVgWPgkaSjD1X","object":"chat.completion.chunk","created":1718825572,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\",\""}}]},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bvL2OSkYxLeUXjmNVgWPgkaSjD1X","object":"chat.completion.chunk","created":1718825572,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"dt"}}]},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bvL2OSkYxLeUXjmNVgWPgkaSjD1X","object":"chat.completion.chunk","created":1718825572,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"_str"}}]},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bvL2OSkYxLeUXjmNVgWPgkaSjD1X","object":"chat.completion.chunk","created":1718825572,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bvL2OSkYxLeUXjmNVgWPgkaSjD1X","object":"chat.completion.chunk","created":1718825572,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"202"}}]},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bvL2OSkYxLeUXjmNVgWPgkaSjD1X","object":"chat.completion.chunk","created":1718825572,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"4"}}]},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bvL2OSkYxLeUXjmNVgWPgkaSjD1X","object":"chat.completion.chunk","created":1718825572,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"-"}}]},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bvL2OSkYxLeUXjmNVgWPgkaSjD1X","object":"chat.completion.chunk","created":1718825572,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"06"}}]},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bvL2OSkYxLeUXjmNVgWPgkaSjD1X","object":"chat.completion.chunk","created":1718825572,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"-"}}]},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bvL2OSkYxLeUXjmNVgWPgkaSjD1X","object":"chat.completion.chunk","created":1718825572,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"10"}}]},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bvL2OSkYxLeUXjmNVgWPgkaSjD1X","object":"chat.completion.chunk","created":1718825572,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"}"}}]},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bvL2OSkYxLeUXjmNVgWPgkaSjD1X","object":"chat.completion.chunk","created":1718825572,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"tool_calls"}]}
data: [DONE]
'
headers:
Connection:
- keep-alive
Content-Type:
- text/event-stream; charset=utf-8
Date: Sun, 09 Jun 2024 23:39:08 GMT
Server: DUMMY
Transfer-Encoding:
- chunked
status:
code: 200
message: OK
- request:
body: '{"messages": [{"content": "You are a temperature bot. Today is 2024-06-09.",
"role": "system"}, {"content": "Hello, will I have to use my umbrella in Lisbon
tomorrow?", "role": "user"}, {"content": null, "role": "assistant", "tool_calls":
[{"type": "function", "id": "call_pPh34DYupF8tPgILgMxPHyBD", "function": {"name":
"fetch_forecast_temperature", "arguments": "{\"location\": \"Lisbon\", \"dt_str\":
\"2024-06-10\"}"}}]}, {"content": "35 degrees Celsius", "role": "tool", "tool_call_id":
"call_pPh34DYupF8tPgILgMxPHyBD"}], "model": "gpt-4o", "n": 1, "stream": true,
"temperature": 1.0, "tools": [{"type": "function", "function": {"name": "fetch_current_temperature",
"description": "Fetch the current temperature data for a location", "parameters":
{"type": "object", "properties": {"location": {"type": "string"}}, "required":
["location"]}}}, {"type": "function", "function": {"name": "fetch_forecast_temperature",
"description": "Fetch the forecast temperature data for a location", "parameters":
{"type": "object", "properties": {"location": {"type": "string"}, "dt_str":
{"description": "Date in the format ''YYYY-MM-DD''", "type": "string"}}, "required":
["location", "dt_str"]}}}]}'
headers:
accept:
- application/json
accept-encoding:
- gzip, deflate
authorization:
- DUMMY
connection:
- keep-alive
content-length:
- '1190'
content-type:
- application/json
cookie:
- DUMMY
host:
- api.openai.com
user-agent:
- OpenAI/Python
method: POST
uri: https://api.openai.com/v1/chat/completions
response:
body:
string: "data: {\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata:
{\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"The\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata:
{\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"
forecast\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"
for\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"
Lisbon\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"
tomorrow\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"
is\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"
\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"35\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata:
{\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"\xB0C\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata:
{\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\",\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata:
{\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"
which\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"
is\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"
quite\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"
warm\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"
and\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"
unlikely\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"
to\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"
involve\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"
rain\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\".\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata:
{\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"
You\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"
probably\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"
won't\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"
need\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"
an\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"
umbrella\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\".\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata:
{\"id\":\"chatcmpl-9bvL3DxcSHycnnBHALYQ3TrpOahI6\",\"object\":\"chat.completion.chunk\",\"created\":1718825573,\"model\":\"gpt-4o-2024-05-13\",\"system_fingerprint\":\"fp_f4e629d0a5\",\"choices\":[{\"index\":0,\"delta\":{},\"logprobs\":null,\"finish_reason\":\"stop\"}]}\n\ndata:
[DONE]\n\n"
headers:
Connection:
- keep-alive
Content-Type:
- text/event-stream; charset=utf-8
Date: Sun, 09 Jun 2024 23:39:08 GMT
Server: DUMMY
Transfer-Encoding:
- chunked
status:
code: 200
message: OK
version: 1
Loading

0 comments on commit e738808

Please sign in to comment.