Skip to content

Commit

Permalink
Merge branch 'main' into feat/custom-config-ninja-api
Browse files Browse the repository at this point in the history
  • Loading branch information
pamella committed Jun 19, 2024
2 parents 1943544 + 3a62db6 commit 0fcd5b4
Show file tree
Hide file tree
Showing 6 changed files with 515 additions and 8 deletions.
2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
"""
Use this manage.py for generate the OpenAPI schema. NOT for examples.
Use this manage.py to generate the OpenAPI schema. NOT for examples.
For tests, use pytest directly.
"""
import os
Expand Down
20 changes: 19 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pymdown-extensions = "^10.8.1"
markdown = "^3.6"
pygments = "^2.18.0"
model-bakery = "^1.18.1"
pytest-cov = "^5.0.0"

[tool.poetry.group.example.dependencies]
django-webpack-loader = "^3.1.0"
Expand Down
196 changes: 196 additions & 0 deletions tests/cassettes/test_views/test_create_thread_message.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
interactions:
- request:
body: '{"messages": [{"content": "You are a temperature bot. Today is 2024-06-09.",
"role": "system"}, {"content": "Hello, what is the temperature in SF right now?",
"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:
- '840'
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-9bp0n4JXzttxBAJOECR6Rcmb2ZrFe","object":"chat.completion.chunk","created":1718801253,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_f4e629d0a5","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_DSkKzAmCkD4pfwMPxeDZbXmN","type":"function","function":{"name":"fetch_current_temperature","arguments":""}}]},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bp0n4JXzttxBAJOECR6Rcmb2ZrFe","object":"chat.completion.chunk","created":1718801253,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_f4e629d0a5","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bp0n4JXzttxBAJOECR6Rcmb2ZrFe","object":"chat.completion.chunk","created":1718801253,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_f4e629d0a5","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"location"}}]},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bp0n4JXzttxBAJOECR6Rcmb2ZrFe","object":"chat.completion.chunk","created":1718801253,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_f4e629d0a5","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bp0n4JXzttxBAJOECR6Rcmb2ZrFe","object":"chat.completion.chunk","created":1718801253,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_f4e629d0a5","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"San"}}]},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bp0n4JXzttxBAJOECR6Rcmb2ZrFe","object":"chat.completion.chunk","created":1718801253,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_f4e629d0a5","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"
Francisco"}}]},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bp0n4JXzttxBAJOECR6Rcmb2ZrFe","object":"chat.completion.chunk","created":1718801253,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_f4e629d0a5","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":","}}]},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bp0n4JXzttxBAJOECR6Rcmb2ZrFe","object":"chat.completion.chunk","created":1718801253,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_f4e629d0a5","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"
CA"}}]},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bp0n4JXzttxBAJOECR6Rcmb2ZrFe","object":"chat.completion.chunk","created":1718801253,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_f4e629d0a5","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"}"}}]},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bp0n4JXzttxBAJOECR6Rcmb2ZrFe","object":"chat.completion.chunk","created":1718801253,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_f4e629d0a5","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, what is the temperature in SF right now?",
"role": "user"}, {"content": null, "role": "assistant", "tool_calls": [{"type":
"function", "id": "call_DSkKzAmCkD4pfwMPxeDZbXmN", "function": {"name": "fetch_current_temperature",
"arguments": "{\"location\": \"San Francisco, CA\"}"}}]}, {"content": "32 degrees
Celsius", "role": "tool", "tool_call_id": "call_DSkKzAmCkD4pfwMPxeDZbXmN"}],
"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:
- '1162'
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-9bp0oyb19UTjSTZGIZ9S9iH1Tedxm","object":"chat.completion.chunk","created":1718801254,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"role":"assistant","content":""},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bp0oyb19UTjSTZGIZ9S9iH1Tedxm","object":"chat.completion.chunk","created":1718801254,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"content":"The"},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bp0oyb19UTjSTZGIZ9S9iH1Tedxm","object":"chat.completion.chunk","created":1718801254,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"content":"
current"},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bp0oyb19UTjSTZGIZ9S9iH1Tedxm","object":"chat.completion.chunk","created":1718801254,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"content":"
temperature"},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bp0oyb19UTjSTZGIZ9S9iH1Tedxm","object":"chat.completion.chunk","created":1718801254,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"content":"
in"},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bp0oyb19UTjSTZGIZ9S9iH1Tedxm","object":"chat.completion.chunk","created":1718801254,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"content":"
San"},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bp0oyb19UTjSTZGIZ9S9iH1Tedxm","object":"chat.completion.chunk","created":1718801254,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"content":"
Francisco"},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bp0oyb19UTjSTZGIZ9S9iH1Tedxm","object":"chat.completion.chunk","created":1718801254,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"content":","},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bp0oyb19UTjSTZGIZ9S9iH1Tedxm","object":"chat.completion.chunk","created":1718801254,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"content":"
CA"},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bp0oyb19UTjSTZGIZ9S9iH1Tedxm","object":"chat.completion.chunk","created":1718801254,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"content":"
is"},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bp0oyb19UTjSTZGIZ9S9iH1Tedxm","object":"chat.completion.chunk","created":1718801254,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"content":"
"},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bp0oyb19UTjSTZGIZ9S9iH1Tedxm","object":"chat.completion.chunk","created":1718801254,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"content":"32"},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bp0oyb19UTjSTZGIZ9S9iH1Tedxm","object":"chat.completion.chunk","created":1718801254,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"content":"
degrees"},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bp0oyb19UTjSTZGIZ9S9iH1Tedxm","object":"chat.completion.chunk","created":1718801254,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"content":"
Celsius"},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bp0oyb19UTjSTZGIZ9S9iH1Tedxm","object":"chat.completion.chunk","created":1718801254,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{"content":"."},"logprobs":null,"finish_reason":null}]}
data: {"id":"chatcmpl-9bp0oyb19UTjSTZGIZ9S9iH1Tedxm","object":"chat.completion.chunk","created":1718801254,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_9cb5d38cf7","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]}
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
version: 1
Loading

0 comments on commit 0fcd5b4

Please sign in to comment.