diff --git a/.env.template b/.env.template new file mode 100644 index 00000000..5d3d862d --- /dev/null +++ b/.env.template @@ -0,0 +1,5 @@ +# To set API keys, copy this as .env and fill in the values +# API keys are required to rewrite the VCR cassettes for the tests +ANTHROPIC_API_KEY="anthropic_api_key" +MISTRAL_API_KEY="mistral_api_key" +OPENAI_API_KEY="openai_api_key" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 00334dd7..2cf05b07 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,6 +7,7 @@ on: - main workflow_dispatch: inputs: + # Options to test specific APIs ignoring the VCR cassettes anthropic: description: "Test using Anthropic API" type: boolean @@ -48,22 +49,22 @@ jobs: - if: inputs.anthropic env: ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} - run: uv run pytest -vv tests/ -m 'anthropic' + run: uv run pytest -vv tests/ -m 'anthropic' --record-mode=rewrite - if: inputs.litellm_anthropic env: ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} - run: uv run pytest -vv tests/ -m 'litellm_anthropic' + run: uv run pytest -vv tests/ -m 'litellm_anthropic' --record-mode=rewrite - if: inputs.litellm_openai env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} OPENAI_ORG_ID: ${{ secrets.OPENAI_ORG_ID }} - run: uv run pytest -vv tests/ -m 'litellm_openai' + run: uv run pytest -vv tests/ -m 'litellm_openai' --record-mode=rewrite - if: inputs.mistral env: MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }} - run: uv run pytest -vv tests/ -m 'mistral' + run: uv run pytest -vv tests/ -m 'mistral' --record-mode=rewrite - if: inputs.openai env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} OPENAI_ORG_ID: ${{ secrets.OPENAI_ORG_ID }} - run: uv run pytest -vv tests/ -m 'openai' + run: uv run pytest -vv tests/ -m 'openai' --record-mode=rewrite diff --git a/pyproject.toml b/pyproject.toml index 2e45e347..c67e5cf0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,6 +22,9 @@ build-backend = "hatchling.build" [dependency-groups] dev = [ + "anthropic", + "inline-snapshot>=0.14.0", + "litellm", "logfire>=0.46.1,<0.50.0", "mypy", "pytest>=7.0.0", @@ -30,9 +33,7 @@ dev = [ "pytest-cov>=4.0.0", "python-dotenv>=1.0.1", "ruff>=0.3", - # optional-dependencies - "anthropic", - "litellm", + "pytest-recording>=0.13.2", ] docs = [ "blacken-docs>=1.16.0", @@ -64,7 +65,9 @@ venvPath = "." venv = ".venv" [tool.pytest.ini_options] -addopts = "--cov=magentic --cov-report=term-missing -m 'not anthropic and not litellm_anthropic and not litellm_openai and not mistral and not litellm_ollama and not openai'" +addopts = "--cov=magentic --cov-report=term-missing --block-network" +asyncio_default_fixture_loop_scope = "function" +asyncio_mode = "auto" markers = [ "anthropic: Tests that query the Anthropic API. Requires the ANTHROPIC_API_KEY environment variable to be set.", "litellm_anthropic: Tests that query the Anthropic API via litellm. Requires the ANTHROPIC_API_KEY environment variable to be set.", diff --git a/tests/cassettes/test_backend/test_openai_chat_model_completion.yaml b/tests/cassettes/test_backend/test_openai_chat_model_completion.yaml new file mode 100644 index 00000000..48d285cd --- /dev/null +++ b/tests/cassettes/test_backend/test_openai_chat_model_completion.yaml @@ -0,0 +1,116 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Hello!"}], "model": "gpt-4o", + "max_tokens": 5, "stream": true, "stream_options": {"include_usage": true}, + "temperature": 0.5}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '168' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UN6hG54O1PXRTx1nqzPVuMCrza","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UN6hG54O1PXRTx1nqzPVuMCrza","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UN6hG54O1PXRTx1nqzPVuMCrza","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"!"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UN6hG54O1PXRTx1nqzPVuMCrza","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + How"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UN6hG54O1PXRTx1nqzPVuMCrza","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + can"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UN6hG54O1PXRTx1nqzPVuMCrza","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + I"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UN6hG54O1PXRTx1nqzPVuMCrza","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"length"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UN6hG54O1PXRTx1nqzPVuMCrza","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[],"usage":{"prompt_tokens":9,"completion_tokens":5,"total_tokens":14,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367c85fb61cf0e-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:39 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '130' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29992' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 16ms + x-request-id: + - req_6bcf128883d8d89f0477582d56a9a782 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_chat/test_chat_asubmit.yaml b/tests/cassettes/test_chat/test_chat_asubmit.yaml new file mode 100644 index 00000000..1e3cf728 --- /dev/null +++ b/tests/cassettes/test_chat/test_chat_asubmit.yaml @@ -0,0 +1,130 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Hello"}], "model": "gpt-4o", + "stream": true, "stream_options": {"include_usage": true}}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '130' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UNy1IrwaLjfjH3NZALLZFyDgO4","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UNy1IrwaLjfjH3NZALLZFyDgO4","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UNy1IrwaLjfjH3NZALLZFyDgO4","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":"!"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UNy1IrwaLjfjH3NZALLZFyDgO4","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":" + How"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UNy1IrwaLjfjH3NZALLZFyDgO4","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":" + can"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UNy1IrwaLjfjH3NZALLZFyDgO4","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":" + I"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UNy1IrwaLjfjH3NZALLZFyDgO4","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":" + assist"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UNy1IrwaLjfjH3NZALLZFyDgO4","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":" + you"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UNy1IrwaLjfjH3NZALLZFyDgO4","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":" + today"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UNy1IrwaLjfjH3NZALLZFyDgO4","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":"?"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UNy1IrwaLjfjH3NZALLZFyDgO4","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UNy1IrwaLjfjH3NZALLZFyDgO4","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[],"usage":{"prompt_tokens":8,"completion_tokens":9,"total_tokens":17,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367c8abcaced3c-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:40 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '223' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29981' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 38ms + x-request-id: + - req_15139d22fd6669e7b4f8198a4c83fa32 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_chat/test_chat_submit.yaml b/tests/cassettes/test_chat/test_chat_submit.yaml new file mode 100644 index 00000000..0b79a46a --- /dev/null +++ b/tests/cassettes/test_chat/test_chat_submit.yaml @@ -0,0 +1,130 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Hello"}], "model": "gpt-4o", + "stream": true, "stream_options": {"include_usage": true}}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '130' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UNZOecMq9pfgkVaSbKfcWpzis7","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UNZOecMq9pfgkVaSbKfcWpzis7","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UNZOecMq9pfgkVaSbKfcWpzis7","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":"!"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UNZOecMq9pfgkVaSbKfcWpzis7","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + How"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UNZOecMq9pfgkVaSbKfcWpzis7","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + can"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UNZOecMq9pfgkVaSbKfcWpzis7","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + I"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UNZOecMq9pfgkVaSbKfcWpzis7","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + assist"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UNZOecMq9pfgkVaSbKfcWpzis7","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + you"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UNZOecMq9pfgkVaSbKfcWpzis7","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + today"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UNZOecMq9pfgkVaSbKfcWpzis7","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":"?"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UNZOecMq9pfgkVaSbKfcWpzis7","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UNZOecMq9pfgkVaSbKfcWpzis7","object":"chat.completion.chunk","created":1731749679,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[],"usage":{"prompt_tokens":8,"completion_tokens":9,"total_tokens":17,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367c880c93234f-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:39 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '237' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29981' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 38ms + x-request-id: + - req_524dd9cc830f46849455c92df82c30c5 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_chatprompt/test_chatprompt_readme_example.yaml b/tests/cassettes/test_chatprompt/test_chatprompt_readme_example.yaml new file mode 100644 index 00000000..961a9307 --- /dev/null +++ b/tests/cassettes/test_chatprompt/test_chatprompt_readme_example.yaml @@ -0,0 +1,151 @@ +interactions: +- request: + body: '{"messages": [{"role": "system", "content": "You are a movie buff."}, {"role": + "user", "content": "What is your favorite quote from Harry Potter?"}, {"role": + "assistant", "content": null, "tool_calls": [{"id": "1d94b104e", "type": "function", + "function": {"name": "return_quote", "arguments": "{\"quote\":\"It does not + do to dwell on dreams and forget to live.\",\"character\":\"Albus Dumbledore\"}"}}]}, + {"role": "tool", "tool_call_id": "1d94b104e", "content": "null"}, {"role": "user", + "content": "What is your favorite quote from Iron Man?"}], "model": "gpt-4o", + "parallel_tool_calls": false, "stream": true, "stream_options": {"include_usage": + true}, "tool_choice": {"type": "function", "function": {"name": "return_quote"}}, + "tools": [{"type": "function", "function": {"name": "return_quote", "parameters": + {"properties": {"quote": {"title": "Quote", "type": "string"}, "character": + {"title": "Character", "type": "string"}}, "required": ["quote", "character"], + "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '988' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UOOffF9BuiCRa9GpNWuKkRWnXE","object":"chat.completion.chunk","created":1731749680,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_U59urGINsvMei3BfLqkKQGg2","type":"function","function":{"name":"return_quote","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UOOffF9BuiCRa9GpNWuKkRWnXE","object":"chat.completion.chunk","created":1731749680,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UOOffF9BuiCRa9GpNWuKkRWnXE","object":"chat.completion.chunk","created":1731749680,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"quote"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UOOffF9BuiCRa9GpNWuKkRWnXE","object":"chat.completion.chunk","created":1731749680,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UOOffF9BuiCRa9GpNWuKkRWnXE","object":"chat.completion.chunk","created":1731749680,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"I"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UOOffF9BuiCRa9GpNWuKkRWnXE","object":"chat.completion.chunk","created":1731749680,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":" + am"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UOOffF9BuiCRa9GpNWuKkRWnXE","object":"chat.completion.chunk","created":1731749680,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":" + Iron"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UOOffF9BuiCRa9GpNWuKkRWnXE","object":"chat.completion.chunk","created":1731749680,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":" + Man"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UOOffF9BuiCRa9GpNWuKkRWnXE","object":"chat.completion.chunk","created":1731749680,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":".\",\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UOOffF9BuiCRa9GpNWuKkRWnXE","object":"chat.completion.chunk","created":1731749680,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"character"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UOOffF9BuiCRa9GpNWuKkRWnXE","object":"chat.completion.chunk","created":1731749680,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UOOffF9BuiCRa9GpNWuKkRWnXE","object":"chat.completion.chunk","created":1731749680,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Tony"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UOOffF9BuiCRa9GpNWuKkRWnXE","object":"chat.completion.chunk","created":1731749680,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":" + Stark"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UOOffF9BuiCRa9GpNWuKkRWnXE","object":"chat.completion.chunk","created":1731749680,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"}"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UOOffF9BuiCRa9GpNWuKkRWnXE","object":"chat.completion.chunk","created":1731749680,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UOOffF9BuiCRa9GpNWuKkRWnXE","object":"chat.completion.chunk","created":1731749680,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[],"usage":{"prompt_tokens":125,"completion_tokens":13,"total_tokens":138,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367c8e1d7515b6-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:41 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '698' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29950' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 100ms + x-request-id: + - req_16334887e92182236cb21f512ee3a392 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_chatprompt/test_chatprompt_with_function_call_and_result.yaml b/tests/cassettes/test_chatprompt/test_chatprompt_with_function_call_and_result.yaml new file mode 100644 index 00000000..4e3d9b0d --- /dev/null +++ b/tests/cassettes/test_chatprompt/test_chatprompt_with_function_call_and_result.yaml @@ -0,0 +1,143 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Use the plus function to add + 1 and 2."}, {"role": "assistant", "content": null, "tool_calls": [{"id": "33ce2d6e8", + "type": "function", "function": {"name": "plus", "arguments": "{\"a\":1,\"b\":2}"}}]}, + {"role": "tool", "tool_call_id": "33ce2d6e8", "content": "{\"value\":3}"}], + "model": "gpt-4o", "stream": true, "stream_options": {"include_usage": true}}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '398' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UPp48dlC81f88s7vmllZkypXzd","object":"chat.completion.chunk","created":1731749681,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UPp48dlC81f88s7vmllZkypXzd","object":"chat.completion.chunk","created":1731749681,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"The"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UPp48dlC81f88s7vmllZkypXzd","object":"chat.completion.chunk","created":1731749681,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + sum"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UPp48dlC81f88s7vmllZkypXzd","object":"chat.completion.chunk","created":1731749681,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + of"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UPp48dlC81f88s7vmllZkypXzd","object":"chat.completion.chunk","created":1731749681,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + "},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UPp48dlC81f88s7vmllZkypXzd","object":"chat.completion.chunk","created":1731749681,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"1"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UPp48dlC81f88s7vmllZkypXzd","object":"chat.completion.chunk","created":1731749681,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + and"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UPp48dlC81f88s7vmllZkypXzd","object":"chat.completion.chunk","created":1731749681,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + "},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UPp48dlC81f88s7vmllZkypXzd","object":"chat.completion.chunk","created":1731749681,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"2"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UPp48dlC81f88s7vmllZkypXzd","object":"chat.completion.chunk","created":1731749681,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + is"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UPp48dlC81f88s7vmllZkypXzd","object":"chat.completion.chunk","created":1731749681,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + "},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UPp48dlC81f88s7vmllZkypXzd","object":"chat.completion.chunk","created":1731749681,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"3"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UPp48dlC81f88s7vmllZkypXzd","object":"chat.completion.chunk","created":1731749681,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"."},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UPp48dlC81f88s7vmllZkypXzd","object":"chat.completion.chunk","created":1731749681,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UPp48dlC81f88s7vmllZkypXzd","object":"chat.completion.chunk","created":1731749681,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[],"usage":{"prompt_tokens":48,"completion_tokens":12,"total_tokens":60,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367c941d1aed3e-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:41 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '134' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29939' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 121ms + x-request-id: + - req_5f10e6d7d739e38228f336a93d66e0a1 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_prompt_chain/test_async_prompt_chain.yaml b/tests/cassettes/test_prompt_chain/test_async_prompt_chain.yaml new file mode 100644 index 00000000..cca0fec4 --- /dev/null +++ b/tests/cassettes/test_prompt_chain/test_async_prompt_chain.yaml @@ -0,0 +1,240 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "What''s the weather like in + Boston?"}], "model": "gpt-4o", "parallel_tool_calls": false, "stream": true, + "stream_options": {"include_usage": true}, "tools": [{"type": "function", "function": + {"name": "get_current_weather", "parameters": {"properties": {"location": {"title": + "Location"}, "unit": {"default": "fahrenheit", "title": "Unit"}}, "required": + ["location"], "type": "object"}, "description": "Get the current weather in + a given location"}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '492' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9URm9DNRNB3LnVKHvoWHQZhrn7B","object":"chat.completion.chunk","created":1731749683,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_ULaotrC7ZFETD7X5V3LUoBVk","type":"function","function":{"name":"get_current_weather","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9URm9DNRNB3LnVKHvoWHQZhrn7B","object":"chat.completion.chunk","created":1731749683,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9URm9DNRNB3LnVKHvoWHQZhrn7B","object":"chat.completion.chunk","created":1731749683,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"location"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9URm9DNRNB3LnVKHvoWHQZhrn7B","object":"chat.completion.chunk","created":1731749683,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9URm9DNRNB3LnVKHvoWHQZhrn7B","object":"chat.completion.chunk","created":1731749683,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Boston"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9URm9DNRNB3LnVKHvoWHQZhrn7B","object":"chat.completion.chunk","created":1731749683,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"}"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9URm9DNRNB3LnVKHvoWHQZhrn7B","object":"chat.completion.chunk","created":1731749683,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"tool_calls"}],"usage":null} + + + data: {"id":"chatcmpl-AU9URm9DNRNB3LnVKHvoWHQZhrn7B","object":"chat.completion.chunk","created":1731749683,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[],"usage":{"prompt_tokens":70,"completion_tokens":15,"total_tokens":85,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367ca1cd36eb28-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:43 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '373' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29958' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 82ms + x-request-id: + - req_7ee339642dfee0a8e0444e4c5faa741c + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"role": "user", "content": "What''s the weather like in + Boston?"}, {"role": "assistant", "content": null, "tool_calls": [{"id": "7e972b89b", + "type": "function", "function": {"name": "get_current_weather", "arguments": + "{\"location\":\"Boston\"}"}}]}, {"role": "tool", "tool_call_id": "7e972b89b", + "content": "{\"location\":\"Boston\",\"temperature\":\"72\",\"unit\":\"fahrenheit\",\"forecast\":[\"sunny\",\"windy\"]}"}], + "model": "gpt-4o", "parallel_tool_calls": false, "stream": true, "stream_options": + {"include_usage": true}, "tools": [{"type": "function", "function": {"name": + "get_current_weather", "parameters": {"properties": {"location": {"title": "Location"}, + "unit": {"default": "fahrenheit", "title": "Unit"}}, "required": ["location"], + "type": "object"}, "description": "Get the current weather in a given location"}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '845' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: "data: {\"id\":\"chatcmpl-AU9USvxEyiTt8nsOJFgg36Te4g14D\",\"object\":\"chat.completion.chunk\",\"created\":1731749684,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_45cf54deae\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\",\"refusal\":null},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9USvxEyiTt8nsOJFgg36Te4g14D\",\"object\":\"chat.completion.chunk\",\"created\":1731749684,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_45cf54deae\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"The\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9USvxEyiTt8nsOJFgg36Te4g14D\",\"object\":\"chat.completion.chunk\",\"created\":1731749684,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_45cf54deae\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + current\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9USvxEyiTt8nsOJFgg36Te4g14D\",\"object\":\"chat.completion.chunk\",\"created\":1731749684,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_45cf54deae\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + weather\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9USvxEyiTt8nsOJFgg36Te4g14D\",\"object\":\"chat.completion.chunk\",\"created\":1731749684,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_45cf54deae\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + in\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9USvxEyiTt8nsOJFgg36Te4g14D\",\"object\":\"chat.completion.chunk\",\"created\":1731749684,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_45cf54deae\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + Boston\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9USvxEyiTt8nsOJFgg36Te4g14D\",\"object\":\"chat.completion.chunk\",\"created\":1731749684,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_45cf54deae\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + is\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9USvxEyiTt8nsOJFgg36Te4g14D\",\"object\":\"chat.completion.chunk\",\"created\":1731749684,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_45cf54deae\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + sunny\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9USvxEyiTt8nsOJFgg36Te4g14D\",\"object\":\"chat.completion.chunk\",\"created\":1731749684,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_45cf54deae\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + and\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9USvxEyiTt8nsOJFgg36Te4g14D\",\"object\":\"chat.completion.chunk\",\"created\":1731749684,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_45cf54deae\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + windy\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9USvxEyiTt8nsOJFgg36Te4g14D\",\"object\":\"chat.completion.chunk\",\"created\":1731749684,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_45cf54deae\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\",\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9USvxEyiTt8nsOJFgg36Te4g14D\",\"object\":\"chat.completion.chunk\",\"created\":1731749684,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_45cf54deae\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + with\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9USvxEyiTt8nsOJFgg36Te4g14D\",\"object\":\"chat.completion.chunk\",\"created\":1731749684,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_45cf54deae\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + a\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: {\"id\":\"chatcmpl-AU9USvxEyiTt8nsOJFgg36Te4g14D\",\"object\":\"chat.completion.chunk\",\"created\":1731749684,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_45cf54deae\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + temperature\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9USvxEyiTt8nsOJFgg36Te4g14D\",\"object\":\"chat.completion.chunk\",\"created\":1731749684,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_45cf54deae\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + of\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9USvxEyiTt8nsOJFgg36Te4g14D\",\"object\":\"chat.completion.chunk\",\"created\":1731749684,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_45cf54deae\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + \"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: {\"id\":\"chatcmpl-AU9USvxEyiTt8nsOJFgg36Te4g14D\",\"object\":\"chat.completion.chunk\",\"created\":1731749684,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_45cf54deae\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"72\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9USvxEyiTt8nsOJFgg36Te4g14D\",\"object\":\"chat.completion.chunk\",\"created\":1731749684,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_45cf54deae\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"\xB0F\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9USvxEyiTt8nsOJFgg36Te4g14D\",\"object\":\"chat.completion.chunk\",\"created\":1731749684,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_45cf54deae\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\".\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9USvxEyiTt8nsOJFgg36Te4g14D\",\"object\":\"chat.completion.chunk\",\"created\":1731749684,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_45cf54deae\",\"choices\":[{\"index\":0,\"delta\":{},\"logprobs\":null,\"finish_reason\":\"stop\"}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9USvxEyiTt8nsOJFgg36Te4g14D\",\"object\":\"chat.completion.chunk\",\"created\":1731749684,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_45cf54deae\",\"choices\":[],\"usage\":{\"prompt_tokens\":117,\"completion_tokens\":19,\"total_tokens\":136,\"prompt_tokens_details\":{\"cached_tokens\":0,\"audio_tokens\":0},\"completion_tokens_details\":{\"reasoning_tokens\":0,\"audio_tokens\":0,\"accepted_prediction_tokens\":0,\"rejected_prediction_tokens\":0}}}\n\ndata: + [DONE]\n\n" + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367ca58ca0f9fd-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:44 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '165' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29950' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 100ms + x-request-id: + - req_de2fe7e4ece1f22e71d14c69f36a38b7 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_prompt_chain/test_prompt_chain.yaml b/tests/cassettes/test_prompt_chain/test_prompt_chain.yaml new file mode 100644 index 00000000..edd7d713 --- /dev/null +++ b/tests/cassettes/test_prompt_chain/test_prompt_chain.yaml @@ -0,0 +1,237 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "What''s the weather like in + Boston?"}], "model": "gpt-4o", "parallel_tool_calls": false, "stream": true, + "stream_options": {"include_usage": true}, "tools": [{"type": "function", "function": + {"name": "get_current_weather", "parameters": {"properties": {"location": {"title": + "Location"}, "unit": {"default": "fahrenheit", "title": "Unit"}}, "required": + ["location"], "type": "object"}, "description": "Get the current weather in + a given location"}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '492' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UQNYUKfmmp1KFSs8KzJn3m2DOn","object":"chat.completion.chunk","created":1731749682,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_aFiZGBVOOwfq5WUaB8DV9GKz","type":"function","function":{"name":"get_current_weather","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UQNYUKfmmp1KFSs8KzJn3m2DOn","object":"chat.completion.chunk","created":1731749682,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UQNYUKfmmp1KFSs8KzJn3m2DOn","object":"chat.completion.chunk","created":1731749682,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"location"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UQNYUKfmmp1KFSs8KzJn3m2DOn","object":"chat.completion.chunk","created":1731749682,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UQNYUKfmmp1KFSs8KzJn3m2DOn","object":"chat.completion.chunk","created":1731749682,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Boston"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UQNYUKfmmp1KFSs8KzJn3m2DOn","object":"chat.completion.chunk","created":1731749682,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"}"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UQNYUKfmmp1KFSs8KzJn3m2DOn","object":"chat.completion.chunk","created":1731749682,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"tool_calls"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UQNYUKfmmp1KFSs8KzJn3m2DOn","object":"chat.completion.chunk","created":1731749682,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[],"usage":{"prompt_tokens":70,"completion_tokens":15,"total_tokens":85,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367c97da63cf27-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:42 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '881' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29974' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 52ms + x-request-id: + - req_80a307aafd94aa85c3bbc7c074ad77b6 + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"role": "user", "content": "What''s the weather like in + Boston?"}, {"role": "assistant", "content": null, "tool_calls": [{"id": "91d56c0c2", + "type": "function", "function": {"name": "get_current_weather", "arguments": + "{\"location\":\"Boston\"}"}}]}, {"role": "tool", "tool_call_id": "91d56c0c2", + "content": "{\"location\":\"Boston\",\"temperature\":\"72\",\"unit\":\"fahrenheit\",\"forecast\":[\"sunny\",\"windy\"]}"}], + "model": "gpt-4o", "parallel_tool_calls": false, "stream": true, "stream_options": + {"include_usage": true}, "tools": [{"type": "function", "function": {"name": + "get_current_weather", "parameters": {"properties": {"location": {"title": "Location"}, + "unit": {"default": "fahrenheit", "title": "Unit"}}, "required": ["location"], + "type": "object"}, "description": "Get the current weather in a given location"}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '845' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: "data: {\"id\":\"chatcmpl-AU9URPznPzrIl6KUR3zKMCC97vrbF\",\"object\":\"chat.completion.chunk\",\"created\":1731749683,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_7f6be3efb0\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\",\"refusal\":null},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9URPznPzrIl6KUR3zKMCC97vrbF\",\"object\":\"chat.completion.chunk\",\"created\":1731749683,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_7f6be3efb0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"The\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9URPznPzrIl6KUR3zKMCC97vrbF\",\"object\":\"chat.completion.chunk\",\"created\":1731749683,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_7f6be3efb0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + current\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9URPznPzrIl6KUR3zKMCC97vrbF\",\"object\":\"chat.completion.chunk\",\"created\":1731749683,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_7f6be3efb0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + weather\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9URPznPzrIl6KUR3zKMCC97vrbF\",\"object\":\"chat.completion.chunk\",\"created\":1731749683,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_7f6be3efb0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + in\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9URPznPzrIl6KUR3zKMCC97vrbF\",\"object\":\"chat.completion.chunk\",\"created\":1731749683,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_7f6be3efb0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + Boston\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9URPznPzrIl6KUR3zKMCC97vrbF\",\"object\":\"chat.completion.chunk\",\"created\":1731749683,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_7f6be3efb0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + is\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9URPznPzrIl6KUR3zKMCC97vrbF\",\"object\":\"chat.completion.chunk\",\"created\":1731749683,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_7f6be3efb0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + \"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: {\"id\":\"chatcmpl-AU9URPznPzrIl6KUR3zKMCC97vrbF\",\"object\":\"chat.completion.chunk\",\"created\":1731749683,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_7f6be3efb0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"72\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9URPznPzrIl6KUR3zKMCC97vrbF\",\"object\":\"chat.completion.chunk\",\"created\":1731749683,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_7f6be3efb0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"\xB0F\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9URPznPzrIl6KUR3zKMCC97vrbF\",\"object\":\"chat.completion.chunk\",\"created\":1731749683,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_7f6be3efb0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\",\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9URPznPzrIl6KUR3zKMCC97vrbF\",\"object\":\"chat.completion.chunk\",\"created\":1731749683,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_7f6be3efb0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + with\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9URPznPzrIl6KUR3zKMCC97vrbF\",\"object\":\"chat.completion.chunk\",\"created\":1731749683,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_7f6be3efb0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + sunny\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9URPznPzrIl6KUR3zKMCC97vrbF\",\"object\":\"chat.completion.chunk\",\"created\":1731749683,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_7f6be3efb0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + and\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9URPznPzrIl6KUR3zKMCC97vrbF\",\"object\":\"chat.completion.chunk\",\"created\":1731749683,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_7f6be3efb0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + windy\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9URPznPzrIl6KUR3zKMCC97vrbF\",\"object\":\"chat.completion.chunk\",\"created\":1731749683,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_7f6be3efb0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + conditions\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9URPznPzrIl6KUR3zKMCC97vrbF\",\"object\":\"chat.completion.chunk\",\"created\":1731749683,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_7f6be3efb0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\".\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9URPznPzrIl6KUR3zKMCC97vrbF\",\"object\":\"chat.completion.chunk\",\"created\":1731749683,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_7f6be3efb0\",\"choices\":[{\"index\":0,\"delta\":{},\"logprobs\":null,\"finish_reason\":\"stop\"}],\"usage\":null}\n\ndata: + {\"id\":\"chatcmpl-AU9URPznPzrIl6KUR3zKMCC97vrbF\",\"object\":\"chat.completion.chunk\",\"created\":1731749683,\"model\":\"gpt-4o-2024-08-06\",\"system_fingerprint\":\"fp_7f6be3efb0\",\"choices\":[],\"usage\":{\"prompt_tokens\":117,\"completion_tokens\":17,\"total_tokens\":134,\"prompt_tokens_details\":{\"cached_tokens\":0,\"audio_tokens\":0},\"completion_tokens_details\":{\"reasoning_tokens\":0,\"audio_tokens\":0,\"accepted_prediction_tokens\":0,\"rejected_prediction_tokens\":0}}}\n\ndata: + [DONE]\n\n" + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367c9e68496423-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:43 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '251' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29950' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 100ms + x-request-id: + - req_3243dd23fbc80ff2e68c77d7beff3d40 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_prompt_function/test_async_decorator_max_retries.yaml b/tests/cassettes/test_prompt_function/test_async_decorator_max_retries.yaml new file mode 100644 index 00000000..a20fa538 --- /dev/null +++ b/tests/cassettes/test_prompt_function/test_async_decorator_max_retries.yaml @@ -0,0 +1,239 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Return a country."}], "model": + "gpt-4o", "parallel_tool_calls": false, "stream": true, "stream_options": {"include_usage": + true}, "tool_choice": {"type": "function", "function": {"name": "return_country"}}, + "tools": [{"type": "function", "function": {"name": "return_country", "parameters": + {"properties": {"name": {"title": "Name", "type": "string"}}, "required": ["name"], + "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '439' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UbB4ld1146U4QhHhxP4F02h3eV","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_Uiz13O1iMw5tob2yIDXaRHDH","type":"function","function":{"name":"return_country","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UbB4ld1146U4QhHhxP4F02h3eV","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UbB4ld1146U4QhHhxP4F02h3eV","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"name"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UbB4ld1146U4QhHhxP4F02h3eV","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UbB4ld1146U4QhHhxP4F02h3eV","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Japan"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UbB4ld1146U4QhHhxP4F02h3eV","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"}"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UbB4ld1146U4QhHhxP4F02h3eV","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UbB4ld1146U4QhHhxP4F02h3eV","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[],"usage":{"prompt_tokens":53,"completion_tokens":5,"total_tokens":58,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367cdc792b2523-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:53 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '231' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29978' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 44ms + x-request-id: + - req_36b6885837304c95255dc0e243ddd0bc + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"role": "user", "content": "Return a country."}, {"role": + "assistant", "content": null, "tool_calls": [{"id": "call_Uiz13O1iMw5tob2yIDXaRHDH", + "type": "function", "function": {"name": "return_country", "arguments": "{\"name\":\"Japan\"}"}}]}, + {"role": "tool", "tool_call_id": "call_Uiz13O1iMw5tob2yIDXaRHDH", "content": + "1 validation error for Country\nname\n Value error, Country must be Ireland. + [type=value_error, input_value=''Japan'', input_type=str]\n For further information + visit https://errors.pydantic.dev/2.9/v/value_error"}], "model": "gpt-4o", "parallel_tool_calls": + false, "stream": true, "stream_options": {"include_usage": true}, "tool_choice": + {"type": "function", "function": {"name": "return_country"}}, "tools": [{"type": + "function", "function": {"name": "return_country", "parameters": {"properties": + {"name": {"title": "Name", "type": "string"}}, "required": ["name"], "type": + "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '929' + content-type: + - application/json + cookie: + - __cf_bm=wEsL6ULd.xp6gCoeJPmKaXwe3SOIEpJ2OD7N7AW5Uws-1731749693-1.0.1.1-ub_GAbKgRsGOITlv_88OsV4ivL8UZhOb2zb2IxLxtM4Z6zT3bROk5hV_1ZcPL.d.KcwDZg9Ns_qofiVGmrMiuQ; + _cfuvid=_7gaoOsQ2EivHbO2o7pDXxdovG6ZmrHdC3szn.mJVww-1731749693141-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UbpuvQHeG32Dr7WUawf4oshZpp","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_ifXs1dcqtJy3GNJ0UpW7AR8C","type":"function","function":{"name":"return_country","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UbpuvQHeG32Dr7WUawf4oshZpp","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UbpuvQHeG32Dr7WUawf4oshZpp","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"name"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UbpuvQHeG32Dr7WUawf4oshZpp","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UbpuvQHeG32Dr7WUawf4oshZpp","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Ireland"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UbpuvQHeG32Dr7WUawf4oshZpp","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"}"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UbpuvQHeG32Dr7WUawf4oshZpp","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UbpuvQHeG32Dr7WUawf4oshZpp","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[],"usage":{"prompt_tokens":125,"completion_tokens":5,"total_tokens":130,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367cdf0aa72523-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:53 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '209' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29923' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 152ms + x-request-id: + - req_dc27be5835d770a6829f394a4c68c56c + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_prompt_function/test_async_decorator_return_async_function_call.yaml b/tests/cassettes/test_prompt_function/test_async_decorator_return_async_function_call.yaml new file mode 100644 index 00000000..0d1b5fd2 --- /dev/null +++ b/tests/cassettes/test_prompt_function/test_async_decorator_return_async_function_call.yaml @@ -0,0 +1,128 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Sum 2 and 3"}], "model": "gpt-4o", + "parallel_tool_calls": false, "stream": true, "stream_options": {"include_usage": + true}, "tool_choice": {"type": "function", "function": {"name": "async_plus"}}, + "tools": [{"type": "function", "function": {"name": "async_plus", "parameters": + {"properties": {"a": {"title": "A", "type": "integer"}, "b": {"title": "B", + "type": "integer"}}, "required": ["a", "b"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '462' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UcA1zcMfuTZqNUuXtZwcMv9UsW","object":"chat.completion.chunk","created":1731749694,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_3bbqSnvivwilx7a6ockTH8VT","type":"function","function":{"name":"async_plus","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UcA1zcMfuTZqNUuXtZwcMv9UsW","object":"chat.completion.chunk","created":1731749694,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UcA1zcMfuTZqNUuXtZwcMv9UsW","object":"chat.completion.chunk","created":1731749694,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"a"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UcA1zcMfuTZqNUuXtZwcMv9UsW","object":"chat.completion.chunk","created":1731749694,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UcA1zcMfuTZqNUuXtZwcMv9UsW","object":"chat.completion.chunk","created":1731749694,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"2"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UcA1zcMfuTZqNUuXtZwcMv9UsW","object":"chat.completion.chunk","created":1731749694,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":",\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UcA1zcMfuTZqNUuXtZwcMv9UsW","object":"chat.completion.chunk","created":1731749694,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"b"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UcA1zcMfuTZqNUuXtZwcMv9UsW","object":"chat.completion.chunk","created":1731749694,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UcA1zcMfuTZqNUuXtZwcMv9UsW","object":"chat.completion.chunk","created":1731749694,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"3"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UcA1zcMfuTZqNUuXtZwcMv9UsW","object":"chat.completion.chunk","created":1731749694,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"}"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UcA1zcMfuTZqNUuXtZwcMv9UsW","object":"chat.completion.chunk","created":1731749694,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UcA1zcMfuTZqNUuXtZwcMv9UsW","object":"chat.completion.chunk","created":1731749694,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[],"usage":{"prompt_tokens":61,"completion_tokens":9,"total_tokens":70,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367ce4d8386896-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:54 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '264' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29980' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 40ms + x-request-id: + - req_24c5f050dc99e173ebe2cc45a65c5b2b + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_prompt_function/test_async_decorator_return_async_streamed_str.yaml b/tests/cassettes/test_prompt_function/test_async_decorator_return_async_streamed_str.yaml new file mode 100644 index 00000000..ec93d150 --- /dev/null +++ b/tests/cassettes/test_prompt_function/test_async_decorator_return_async_streamed_str.yaml @@ -0,0 +1,123 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "What is the capital of Ireland?"}], + "model": "gpt-4o", "stream": true, "stream_options": {"include_usage": true}}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '156' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UaQCaB8qSvkVMkdkvkUMpkPpdN","object":"chat.completion.chunk","created":1731749692,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UaQCaB8qSvkVMkdkvkUMpkPpdN","object":"chat.completion.chunk","created":1731749692,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":"The"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UaQCaB8qSvkVMkdkvkUMpkPpdN","object":"chat.completion.chunk","created":1731749692,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + capital"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UaQCaB8qSvkVMkdkvkUMpkPpdN","object":"chat.completion.chunk","created":1731749692,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + of"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UaQCaB8qSvkVMkdkvkUMpkPpdN","object":"chat.completion.chunk","created":1731749692,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + Ireland"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UaQCaB8qSvkVMkdkvkUMpkPpdN","object":"chat.completion.chunk","created":1731749692,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + is"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UaQCaB8qSvkVMkdkvkUMpkPpdN","object":"chat.completion.chunk","created":1731749692,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + Dublin"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UaQCaB8qSvkVMkdkvkUMpkPpdN","object":"chat.completion.chunk","created":1731749692,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":"."},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UaQCaB8qSvkVMkdkvkUMpkPpdN","object":"chat.completion.chunk","created":1731749692,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UaQCaB8qSvkVMkdkvkUMpkPpdN","object":"chat.completion.chunk","created":1731749692,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[],"usage":{"prompt_tokens":14,"completion_tokens":7,"total_tokens":21,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367cd969a9ebef-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:52 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '209' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29975' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 50ms + x-request-id: + - req_6e6946932d76b27316f222ec70209985 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_prompt_function/test_async_decorator_return_function_call.yaml b/tests/cassettes/test_prompt_function/test_async_decorator_return_function_call.yaml new file mode 100644 index 00000000..7328b962 --- /dev/null +++ b/tests/cassettes/test_prompt_function/test_async_decorator_return_function_call.yaml @@ -0,0 +1,128 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Sum 2 and 3"}], "model": "gpt-4o", + "parallel_tool_calls": false, "stream": true, "stream_options": {"include_usage": + true}, "tool_choice": {"type": "function", "function": {"name": "plus"}}, "tools": + [{"type": "function", "function": {"name": "plus", "parameters": {"properties": + {"a": {"title": "A", "type": "integer"}, "b": {"title": "B", "type": "integer"}}, + "required": ["a", "b"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '450' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9Ubv5jiL97r6MWbIVka60mR1Kso","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_wyeHjsRaZNq1x53G4GZoXykL","type":"function","function":{"name":"plus","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9Ubv5jiL97r6MWbIVka60mR1Kso","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9Ubv5jiL97r6MWbIVka60mR1Kso","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"a"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9Ubv5jiL97r6MWbIVka60mR1Kso","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9Ubv5jiL97r6MWbIVka60mR1Kso","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"2"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9Ubv5jiL97r6MWbIVka60mR1Kso","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":",\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9Ubv5jiL97r6MWbIVka60mR1Kso","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"b"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9Ubv5jiL97r6MWbIVka60mR1Kso","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9Ubv5jiL97r6MWbIVka60mR1Kso","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"3"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9Ubv5jiL97r6MWbIVka60mR1Kso","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"}"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9Ubv5jiL97r6MWbIVka60mR1Kso","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9Ubv5jiL97r6MWbIVka60mR1Kso","object":"chat.completion.chunk","created":1731749693,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[],"usage":{"prompt_tokens":59,"completion_tokens":9,"total_tokens":68,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367ce1c86a15da-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:53 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '229' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29980' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 40ms + x-request-id: + - req_43dbe565d54d4b643ec151eb1ae4c979 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_prompt_function/test_async_decorator_return_str.yaml b/tests/cassettes/test_prompt_function/test_async_decorator_return_str.yaml new file mode 100644 index 00000000..b3f263d9 --- /dev/null +++ b/tests/cassettes/test_prompt_function/test_async_decorator_return_str.yaml @@ -0,0 +1,104 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "What is the capital of Ireland? + Name only. No punctuation."}], "model": "gpt-4o", "stream": true, "stream_options": + {"include_usage": true}}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '183' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UaBwr5ohL9e5tinZ68sRJoICaH","object":"chat.completion.chunk","created":1731749692,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UaBwr5ohL9e5tinZ68sRJoICaH","object":"chat.completion.chunk","created":1731749692,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"D"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UaBwr5ohL9e5tinZ68sRJoICaH","object":"chat.completion.chunk","created":1731749692,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"ublin"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UaBwr5ohL9e5tinZ68sRJoICaH","object":"chat.completion.chunk","created":1731749692,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UaBwr5ohL9e5tinZ68sRJoICaH","object":"chat.completion.chunk","created":1731749692,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[],"usage":{"prompt_tokens":20,"completion_tokens":2,"total_tokens":22,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-RAY: + - 8e367cd699147ac7-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:52 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-processing-ms: + - '230' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29968' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 64ms + x-request-id: + - req_c205563ed93f589472a986b31de787df + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_prompt_function/test_decorator_ignore_multiple_tool_calls.yaml b/tests/cassettes/test_prompt_function/test_decorator_ignore_multiple_tool_calls.yaml new file mode 100644 index 00000000..be0068b8 --- /dev/null +++ b/tests/cassettes/test_prompt_function/test_decorator_ignore_multiple_tool_calls.yaml @@ -0,0 +1,143 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Return the numbers 1 to 5 in + the first tool call. And numbers 6 to 10 in the second."}], "model": "gpt-4-1106-preview", + "parallel_tool_calls": false, "stream": true, "stream_options": {"include_usage": + true}, "tool_choice": "required", "tools": [{"type": "function", "function": + {"name": "return_list_of_int", "parameters": {"properties": {"value": {"items": + {"type": "integer"}, "title": "Value", "type": "array"}}, "required": ["value"], + "type": "object"}}}, {"type": "function", "function": {"name": "return_bool", + "parameters": {"properties": {"value": {"title": "Value", "type": "boolean"}}, + "required": ["value"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '684' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UXC2bElcbzxG6QNjTfp6H9Lyy2","object":"chat.completion.chunk","created":1731749689,"model":"gpt-4-1106-preview","system_fingerprint":null,"choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_WJvRfWRTP9yGeWfjklGUIW53","type":"function","function":{"name":"return_list_of_int","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UXC2bElcbzxG6QNjTfp6H9Lyy2","object":"chat.completion.chunk","created":1731749689,"model":"gpt-4-1106-preview","system_fingerprint":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UXC2bElcbzxG6QNjTfp6H9Lyy2","object":"chat.completion.chunk","created":1731749689,"model":"gpt-4-1106-preview","system_fingerprint":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"value"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UXC2bElcbzxG6QNjTfp6H9Lyy2","object":"chat.completion.chunk","created":1731749689,"model":"gpt-4-1106-preview","system_fingerprint":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":["}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UXC2bElcbzxG6QNjTfp6H9Lyy2","object":"chat.completion.chunk","created":1731749689,"model":"gpt-4-1106-preview","system_fingerprint":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"1"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UXC2bElcbzxG6QNjTfp6H9Lyy2","object":"chat.completion.chunk","created":1731749689,"model":"gpt-4-1106-preview","system_fingerprint":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":","}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UXC2bElcbzxG6QNjTfp6H9Lyy2","object":"chat.completion.chunk","created":1731749689,"model":"gpt-4-1106-preview","system_fingerprint":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"2"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UXC2bElcbzxG6QNjTfp6H9Lyy2","object":"chat.completion.chunk","created":1731749689,"model":"gpt-4-1106-preview","system_fingerprint":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":","}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UXC2bElcbzxG6QNjTfp6H9Lyy2","object":"chat.completion.chunk","created":1731749689,"model":"gpt-4-1106-preview","system_fingerprint":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"3"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UXC2bElcbzxG6QNjTfp6H9Lyy2","object":"chat.completion.chunk","created":1731749689,"model":"gpt-4-1106-preview","system_fingerprint":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":","}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UXC2bElcbzxG6QNjTfp6H9Lyy2","object":"chat.completion.chunk","created":1731749689,"model":"gpt-4-1106-preview","system_fingerprint":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"4"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UXC2bElcbzxG6QNjTfp6H9Lyy2","object":"chat.completion.chunk","created":1731749689,"model":"gpt-4-1106-preview","system_fingerprint":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":","}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UXC2bElcbzxG6QNjTfp6H9Lyy2","object":"chat.completion.chunk","created":1731749689,"model":"gpt-4-1106-preview","system_fingerprint":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"5"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UXC2bElcbzxG6QNjTfp6H9Lyy2","object":"chat.completion.chunk","created":1731749689,"model":"gpt-4-1106-preview","system_fingerprint":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"]}"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UXC2bElcbzxG6QNjTfp6H9Lyy2","object":"chat.completion.chunk","created":1731749689,"model":"gpt-4-1106-preview","system_fingerprint":null,"choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"tool_calls"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UXC2bElcbzxG6QNjTfp6H9Lyy2","object":"chat.completion.chunk","created":1731749689,"model":"gpt-4-1106-preview","system_fingerprint":null,"choices":[],"usage":{"prompt_tokens":86,"completion_tokens":24,"total_tokens":110,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367cc43bb896a8-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:50 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '1135' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29962' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 76ms + x-request-id: + - req_8c0f5a141514df93c9fdbed5e1037391 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_prompt_function/test_decorator_input_pydantic_model.yaml b/tests/cassettes/test_prompt_function/test_decorator_input_pydantic_model.yaml new file mode 100644 index 00000000..e9a15ac5 --- /dev/null +++ b/tests/cassettes/test_prompt_function/test_decorator_input_pydantic_model.yaml @@ -0,0 +1,117 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Is this capital-country pair + correct? capital=''Dublin'' country=''Ireland'' Just answer True or False."}], + "model": "gpt-4o", "parallel_tool_calls": false, "stream": true, "stream_options": + {"include_usage": true}, "tool_choice": {"type": "function", "function": {"name": + "return_bool"}}, "tools": [{"type": "function", "function": {"name": "return_bool", + "parameters": {"properties": {"value": {"title": "Value", "type": "boolean"}}, + "required": ["value"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '519' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UV0HG18MmatHQkZMWKcyFHf6pg","object":"chat.completion.chunk","created":1731749687,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_kcFlzX8FiO7KVS2yYvDol8E6","type":"function","function":{"name":"return_bool","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UV0HG18MmatHQkZMWKcyFHf6pg","object":"chat.completion.chunk","created":1731749687,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UV0HG18MmatHQkZMWKcyFHf6pg","object":"chat.completion.chunk","created":1731749687,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"value"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UV0HG18MmatHQkZMWKcyFHf6pg","object":"chat.completion.chunk","created":1731749687,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UV0HG18MmatHQkZMWKcyFHf6pg","object":"chat.completion.chunk","created":1731749687,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"true"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UV0HG18MmatHQkZMWKcyFHf6pg","object":"chat.completion.chunk","created":1731749687,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"}"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UV0HG18MmatHQkZMWKcyFHf6pg","object":"chat.completion.chunk","created":1731749687,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UV0HG18MmatHQkZMWKcyFHf6pg","object":"chat.completion.chunk","created":1731749687,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[],"usage":{"prompt_tokens":71,"completion_tokens":5,"total_tokens":76,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-RAY: + - 8e367cb91a449661-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:47 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-processing-ms: + - '225' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29958' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 84ms + x-request-id: + - req_5cb54121f1d817bce42d9b7e00b35d82 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_prompt_function/test_decorator_max_retries.yaml b/tests/cassettes/test_prompt_function/test_decorator_max_retries.yaml new file mode 100644 index 00000000..025b6cbd --- /dev/null +++ b/tests/cassettes/test_prompt_function/test_decorator_max_retries.yaml @@ -0,0 +1,239 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Return a country."}], "model": + "gpt-4o", "parallel_tool_calls": false, "stream": true, "stream_options": {"include_usage": + true}, "tool_choice": {"type": "function", "function": {"name": "return_country"}}, + "tools": [{"type": "function", "function": {"name": "return_country", "parameters": + {"properties": {"name": {"title": "Name", "type": "string"}}, "required": ["name"], + "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '439' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UZipZ8xDJl7GFgAuLyFkFGnJ9p","object":"chat.completion.chunk","created":1731749691,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_wdEg17NjgwLbqVdKjq6MKLJ1","type":"function","function":{"name":"return_country","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UZipZ8xDJl7GFgAuLyFkFGnJ9p","object":"chat.completion.chunk","created":1731749691,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UZipZ8xDJl7GFgAuLyFkFGnJ9p","object":"chat.completion.chunk","created":1731749691,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"name"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UZipZ8xDJl7GFgAuLyFkFGnJ9p","object":"chat.completion.chunk","created":1731749691,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UZipZ8xDJl7GFgAuLyFkFGnJ9p","object":"chat.completion.chunk","created":1731749691,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Canada"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UZipZ8xDJl7GFgAuLyFkFGnJ9p","object":"chat.completion.chunk","created":1731749691,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"}"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UZipZ8xDJl7GFgAuLyFkFGnJ9p","object":"chat.completion.chunk","created":1731749691,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UZipZ8xDJl7GFgAuLyFkFGnJ9p","object":"chat.completion.chunk","created":1731749691,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[],"usage":{"prompt_tokens":53,"completion_tokens":5,"total_tokens":58,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367cd11df226b0-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:51 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '238' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29978' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 44ms + x-request-id: + - req_55c15dbef4c2f0a4026078c4d3051d04 + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"role": "user", "content": "Return a country."}, {"role": + "assistant", "content": null, "tool_calls": [{"id": "call_wdEg17NjgwLbqVdKjq6MKLJ1", + "type": "function", "function": {"name": "return_country", "arguments": "{\"name\":\"Canada\"}"}}]}, + {"role": "tool", "tool_call_id": "call_wdEg17NjgwLbqVdKjq6MKLJ1", "content": + "1 validation error for Country\nname\n Value error, Country must be Ireland. + [type=value_error, input_value=''Canada'', input_type=str]\n For further + information visit https://errors.pydantic.dev/2.9/v/value_error"}], "model": + "gpt-4o", "parallel_tool_calls": false, "stream": true, "stream_options": {"include_usage": + true}, "tool_choice": {"type": "function", "function": {"name": "return_country"}}, + "tools": [{"type": "function", "function": {"name": "return_country", "parameters": + {"properties": {"name": {"title": "Name", "type": "string"}}, "required": ["name"], + "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '931' + content-type: + - application/json + cookie: + - __cf_bm=sPO4iMakhVSeN2qInDys83OtESskcGEQtUulfF25yU8-1731749691-1.0.1.1-bndGTvCeKjcqqi0MUQq4bEF3.atEdhQbF.8VGPbpjf1qoXcYhD5.v59eEOEpo6RpfegQYZGaUOPOT_fbY7Au1A; + _cfuvid=sCef7lr9GC3CdWBEwnTFFR7tRfAdsuJ0FQJjudsAOpQ-1731749691329-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UZl5mf807mUw8xigORAVUueic3","object":"chat.completion.chunk","created":1731749691,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_bb84311112","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_cH1CgAuhZ0YHubyQGGfxl42Q","type":"function","function":{"name":"return_country","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UZl5mf807mUw8xigORAVUueic3","object":"chat.completion.chunk","created":1731749691,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_bb84311112","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UZl5mf807mUw8xigORAVUueic3","object":"chat.completion.chunk","created":1731749691,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_bb84311112","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"name"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UZl5mf807mUw8xigORAVUueic3","object":"chat.completion.chunk","created":1731749691,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_bb84311112","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UZl5mf807mUw8xigORAVUueic3","object":"chat.completion.chunk","created":1731749691,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_bb84311112","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Ireland"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UZl5mf807mUw8xigORAVUueic3","object":"chat.completion.chunk","created":1731749691,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_bb84311112","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"}"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UZl5mf807mUw8xigORAVUueic3","object":"chat.completion.chunk","created":1731749691,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_bb84311112","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UZl5mf807mUw8xigORAVUueic3","object":"chat.completion.chunk","created":1731749691,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_bb84311112","choices":[],"usage":{"prompt_tokens":125,"completion_tokens":5,"total_tokens":130,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367cd34ff326b0-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:51 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '356' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29913' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 172ms + x-request-id: + - req_d1d6dffe6036d31153d701cfd53dead1 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_prompt_function/test_decorator_return_async_parallel_function_call.yaml b/tests/cassettes/test_prompt_function/test_decorator_return_async_parallel_function_call.yaml new file mode 100644 index 00000000..9eb34454 --- /dev/null +++ b/tests/cassettes/test_prompt_function/test_decorator_return_async_parallel_function_call.yaml @@ -0,0 +1,137 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Sum 2 and 3. Also subtract 2 + from 3."}], "model": "gpt-4o", "stream": true, "stream_options": {"include_usage": + true}, "tool_choice": "required", "tools": [{"type": "function", "function": + {"name": "plus", "parameters": {"properties": {"a": {"title": "A", "type": "integer"}, + "b": {"title": "B", "type": "integer"}}, "required": ["a", "b"], "type": "object"}}}, + {"type": "function", "function": {"name": "minus", "parameters": {"properties": + {"a": {"title": "A", "type": "integer"}, "b": {"title": "B", "type": "integer"}}, + "required": ["a", "b"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '612' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UdGLf1JBtYmSVd0kbxywMGLwO4","object":"chat.completion.chunk","created":1731749695,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","usage":null,"choices":[{"index":0,"delta":{"role":"assistant","content":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AU9UdGLf1JBtYmSVd0kbxywMGLwO4","object":"chat.completion.chunk","created":1731749695,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","usage":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"id":"call_rcIpC2NftzB1LKx6Oo3fqPOS","type":"function","function":{"name":"plus","arguments":""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AU9UdGLf1JBtYmSVd0kbxywMGLwO4","object":"chat.completion.chunk","created":1731749695,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","usage":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\"a\""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AU9UdGLf1JBtYmSVd0kbxywMGLwO4","object":"chat.completion.chunk","created":1731749695,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","usage":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":": + 2, "}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AU9UdGLf1JBtYmSVd0kbxywMGLwO4","object":"chat.completion.chunk","created":1731749695,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","usage":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"b\": + 3"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AU9UdGLf1JBtYmSVd0kbxywMGLwO4","object":"chat.completion.chunk","created":1731749695,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","usage":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"}"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AU9UdGLf1JBtYmSVd0kbxywMGLwO4","object":"chat.completion.chunk","created":1731749695,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","usage":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"id":"call_mATU3QNODJZK8ddgsnr2bJIS","type":"function","function":{"name":"minus","arguments":""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AU9UdGLf1JBtYmSVd0kbxywMGLwO4","object":"chat.completion.chunk","created":1731749695,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","usage":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"function":{"arguments":"{\"a\""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AU9UdGLf1JBtYmSVd0kbxywMGLwO4","object":"chat.completion.chunk","created":1731749695,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","usage":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"function":{"arguments":": + 3, "}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AU9UdGLf1JBtYmSVd0kbxywMGLwO4","object":"chat.completion.chunk","created":1731749695,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","usage":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"function":{"arguments":"\"b\": + 2"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AU9UdGLf1JBtYmSVd0kbxywMGLwO4","object":"chat.completion.chunk","created":1731749695,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","usage":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"function":{"arguments":"}"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AU9UdGLf1JBtYmSVd0kbxywMGLwO4","object":"chat.completion.chunk","created":1731749695,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"tool_calls"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UdGLf1JBtYmSVd0kbxywMGLwO4","object":"chat.completion.chunk","created":1731749695,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[],"usage":{"prompt_tokens":82,"completion_tokens":50,"total_tokens":132,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-RAY: + - 8e367ce9d8b6cee9-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:55 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-processing-ms: + - '730' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29974' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 52ms + x-request-id: + - req_bc5279887f910d0c136cea89c5c93e87 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_prompt_function/test_decorator_return_bool.yaml b/tests/cassettes/test_prompt_function/test_decorator_return_bool.yaml new file mode 100644 index 00000000..bcdc97e1 --- /dev/null +++ b/tests/cassettes/test_prompt_function/test_decorator_return_bool.yaml @@ -0,0 +1,116 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "True if Dublin is the capital + of Ireland."}], "model": "gpt-4o", "parallel_tool_calls": false, "stream": true, + "stream_options": {"include_usage": true}, "tool_choice": {"type": "function", + "function": {"name": "return_bool"}}, "tools": [{"type": "function", "function": + {"name": "return_bool", "parameters": {"properties": {"value": {"title": "Value", + "type": "boolean"}}, "required": ["value"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '461' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UTkaSIvRSC2uUUuvpthuI9f4Yu","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_7DGn1pz8HJD4x8QTVIdR8aGu","type":"function","function":{"name":"return_bool","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTkaSIvRSC2uUUuvpthuI9f4Yu","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTkaSIvRSC2uUUuvpthuI9f4Yu","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"value"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTkaSIvRSC2uUUuvpthuI9f4Yu","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTkaSIvRSC2uUUuvpthuI9f4Yu","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"true"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTkaSIvRSC2uUUuvpthuI9f4Yu","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"}"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTkaSIvRSC2uUUuvpthuI9f4Yu","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTkaSIvRSC2uUUuvpthuI9f4Yu","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[],"usage":{"prompt_tokens":58,"completion_tokens":5,"total_tokens":63,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367cab4b40645c-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:45 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '275' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29972' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 56ms + x-request-id: + - req_b6975260ca3846e6e073c2de3c30453d + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_prompt_function/test_decorator_return_bool_str.yaml b/tests/cassettes/test_prompt_function/test_decorator_return_bool_str.yaml new file mode 100644 index 00000000..d895bea6 --- /dev/null +++ b/tests/cassettes/test_prompt_function/test_decorator_return_bool_str.yaml @@ -0,0 +1,319 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Hello, how are you?"}], "model": + "gpt-4o", "parallel_tool_calls": false, "stream": true, "stream_options": {"include_usage": + true}, "tools": [{"type": "function", "function": {"name": "return_bool", "parameters": + {"properties": {"value": {"title": "Value", "type": "boolean"}}, "required": + ["value"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '365' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"!"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + I''m"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + just"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + a"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + computer"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + program"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":","},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + so"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + I"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + don''t"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + have"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + feelings"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":","},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + but"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + I''m"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + here"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + to"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + help"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + you"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"."},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + How"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + can"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + I"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + assist"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + you"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + today"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"?"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UTzv5q7oWivrZ25Kzp8eVKxCOw","object":"chat.completion.chunk","created":1731749685,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[],"usage":{"prompt_tokens":46,"completion_tokens":29,"total_tokens":75,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-RAY: + - 8e367cae7da62284-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:45 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-processing-ms: + - '253' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29978' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 44ms + x-request-id: + - req_f56cfb7101f4a42cf31b4268c62a316d + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"role": "user", "content": "Use the tool/function to return + the value True."}], "model": "gpt-4o", "parallel_tool_calls": false, "stream": + true, "stream_options": {"include_usage": true}, "tools": [{"type": "function", + "function": {"name": "return_bool", "parameters": {"properties": {"value": {"title": + "Value", "type": "boolean"}}, "required": ["value"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '393' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UU2gQjwozGhSc9nt8sUBgMDeSe","object":"chat.completion.chunk","created":1731749686,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_fi5ybFYOwhz72CBNRJkChgoo","type":"function","function":{"name":"return_bool","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UU2gQjwozGhSc9nt8sUBgMDeSe","object":"chat.completion.chunk","created":1731749686,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UU2gQjwozGhSc9nt8sUBgMDeSe","object":"chat.completion.chunk","created":1731749686,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"value"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UU2gQjwozGhSc9nt8sUBgMDeSe","object":"chat.completion.chunk","created":1731749686,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UU2gQjwozGhSc9nt8sUBgMDeSe","object":"chat.completion.chunk","created":1731749686,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"true"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UU2gQjwozGhSc9nt8sUBgMDeSe","object":"chat.completion.chunk","created":1731749686,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"}"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UU2gQjwozGhSc9nt8sUBgMDeSe","object":"chat.completion.chunk","created":1731749686,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"tool_calls"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UU2gQjwozGhSc9nt8sUBgMDeSe","object":"chat.completion.chunk","created":1731749686,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[],"usage":{"prompt_tokens":50,"completion_tokens":14,"total_tokens":64,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367cb2fc362516-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:46 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '352' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29971' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 58ms + x-request-id: + - req_154ef95756e330d6b77974635695f77e + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_prompt_function/test_decorator_return_function_call.yaml b/tests/cassettes/test_prompt_function/test_decorator_return_function_call.yaml new file mode 100644 index 00000000..12de8a8d --- /dev/null +++ b/tests/cassettes/test_prompt_function/test_decorator_return_function_call.yaml @@ -0,0 +1,128 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Sum 2 and 3"}], "model": "gpt-4o", + "parallel_tool_calls": false, "stream": true, "stream_options": {"include_usage": + true}, "tool_choice": {"type": "function", "function": {"name": "plus"}}, "tools": + [{"type": "function", "function": {"name": "plus", "parameters": {"properties": + {"a": {"title": "A", "type": "integer"}, "b": {"title": "B", "type": "integer"}}, + "required": ["a", "b"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '450' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UV2Q3QDo5u5KfyKZDzpRbfxwiQ","object":"chat.completion.chunk","created":1731749687,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_I4rgKPZdvSkKA3XnEcMYmHN2","type":"function","function":{"name":"plus","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UV2Q3QDo5u5KfyKZDzpRbfxwiQ","object":"chat.completion.chunk","created":1731749687,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UV2Q3QDo5u5KfyKZDzpRbfxwiQ","object":"chat.completion.chunk","created":1731749687,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"a"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UV2Q3QDo5u5KfyKZDzpRbfxwiQ","object":"chat.completion.chunk","created":1731749687,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UV2Q3QDo5u5KfyKZDzpRbfxwiQ","object":"chat.completion.chunk","created":1731749687,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"2"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UV2Q3QDo5u5KfyKZDzpRbfxwiQ","object":"chat.completion.chunk","created":1731749687,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":",\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UV2Q3QDo5u5KfyKZDzpRbfxwiQ","object":"chat.completion.chunk","created":1731749687,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"b"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UV2Q3QDo5u5KfyKZDzpRbfxwiQ","object":"chat.completion.chunk","created":1731749687,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UV2Q3QDo5u5KfyKZDzpRbfxwiQ","object":"chat.completion.chunk","created":1731749687,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"3"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UV2Q3QDo5u5KfyKZDzpRbfxwiQ","object":"chat.completion.chunk","created":1731749687,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"}"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UV2Q3QDo5u5KfyKZDzpRbfxwiQ","object":"chat.completion.chunk","created":1731749687,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UV2Q3QDo5u5KfyKZDzpRbfxwiQ","object":"chat.completion.chunk","created":1731749687,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[],"usage":{"prompt_tokens":59,"completion_tokens":9,"total_tokens":68,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367cbc095967ad-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:47 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '177' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29980' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 40ms + x-request-id: + - req_66478688d1aa53f70f0d6180d14e3ddc + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_prompt_function/test_decorator_return_parallel_function_call.yaml b/tests/cassettes/test_prompt_function/test_decorator_return_parallel_function_call.yaml new file mode 100644 index 00000000..82c88ff6 --- /dev/null +++ b/tests/cassettes/test_prompt_function/test_decorator_return_parallel_function_call.yaml @@ -0,0 +1,137 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Sum 2 and 3. Also subtract 2 + from 3."}], "model": "gpt-4o", "stream": true, "stream_options": {"include_usage": + true}, "tool_choice": "required", "tools": [{"type": "function", "function": + {"name": "plus", "parameters": {"properties": {"a": {"title": "A", "type": "integer"}, + "b": {"title": "B", "type": "integer"}}, "required": ["a", "b"], "type": "object"}}}, + {"type": "function", "function": {"name": "minus", "parameters": {"properties": + {"a": {"title": "A", "type": "integer"}, "b": {"title": "B", "type": "integer"}}, + "required": ["a", "b"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '612' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UWVZJHxSXwx1SffWtyoXswc5zK","object":"chat.completion.chunk","created":1731749688,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","usage":null,"choices":[{"index":0,"delta":{"role":"assistant","content":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AU9UWVZJHxSXwx1SffWtyoXswc5zK","object":"chat.completion.chunk","created":1731749688,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","usage":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"id":"call_8Sp49rZGndlZALo0uq1XvA7A","type":"function","function":{"name":"plus","arguments":""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AU9UWVZJHxSXwx1SffWtyoXswc5zK","object":"chat.completion.chunk","created":1731749688,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","usage":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\"a\""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AU9UWVZJHxSXwx1SffWtyoXswc5zK","object":"chat.completion.chunk","created":1731749688,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","usage":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":": + 2, "}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AU9UWVZJHxSXwx1SffWtyoXswc5zK","object":"chat.completion.chunk","created":1731749688,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","usage":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"b\": + 3"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AU9UWVZJHxSXwx1SffWtyoXswc5zK","object":"chat.completion.chunk","created":1731749688,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","usage":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"}"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AU9UWVZJHxSXwx1SffWtyoXswc5zK","object":"chat.completion.chunk","created":1731749688,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","usage":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"id":"call_u5dbdPz1mAis8zZVk4ZBqXgL","type":"function","function":{"name":"minus","arguments":""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AU9UWVZJHxSXwx1SffWtyoXswc5zK","object":"chat.completion.chunk","created":1731749688,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","usage":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"function":{"arguments":"{\"a\""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AU9UWVZJHxSXwx1SffWtyoXswc5zK","object":"chat.completion.chunk","created":1731749688,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","usage":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"function":{"arguments":": + 3, "}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AU9UWVZJHxSXwx1SffWtyoXswc5zK","object":"chat.completion.chunk","created":1731749688,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","usage":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"function":{"arguments":"\"b\": + 2"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AU9UWVZJHxSXwx1SffWtyoXswc5zK","object":"chat.completion.chunk","created":1731749688,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","usage":null,"choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"function":{"arguments":"}"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AU9UWVZJHxSXwx1SffWtyoXswc5zK","object":"chat.completion.chunk","created":1731749688,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"tool_calls"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UWVZJHxSXwx1SffWtyoXswc5zK","object":"chat.completion.chunk","created":1731749688,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[],"usage":{"prompt_tokens":82,"completion_tokens":50,"total_tokens":132,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367cbe8d54158f-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:48 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '691' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29974' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 52ms + x-request-id: + - req_20e0e13268e35075a1b748999c491e2b + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_prompt_function/test_decorator_return_pydantic_model.yaml b/tests/cassettes/test_prompt_function/test_decorator_return_pydantic_model.yaml new file mode 100644 index 00000000..e847be2d --- /dev/null +++ b/tests/cassettes/test_prompt_function/test_decorator_return_pydantic_model.yaml @@ -0,0 +1,132 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "What is the capital of Ireland? + Make sure to follow the schema."}], "model": "gpt-4o", "parallel_tool_calls": + false, "stream": true, "stream_options": {"include_usage": true}, "tool_choice": + {"type": "function", "function": {"name": "return_capitalcity"}}, "tools": [{"type": + "function", "function": {"name": "return_capitalcity", "parameters": {"properties": + {"capital": {"title": "Capital", "type": "string"}, "country": {"title": "Country", + "type": "string"}}, "required": ["capital", "country"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '564' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UUHvolQofVGqVPYjJw1LwOEMC7","object":"chat.completion.chunk","created":1731749686,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_bb84311112","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_OIbHsv0i6bI1gbiGf1Se0OJS","type":"function","function":{"name":"return_capitalcity","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UUHvolQofVGqVPYjJw1LwOEMC7","object":"chat.completion.chunk","created":1731749686,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_bb84311112","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UUHvolQofVGqVPYjJw1LwOEMC7","object":"chat.completion.chunk","created":1731749686,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_bb84311112","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"capital"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UUHvolQofVGqVPYjJw1LwOEMC7","object":"chat.completion.chunk","created":1731749686,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_bb84311112","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UUHvolQofVGqVPYjJw1LwOEMC7","object":"chat.completion.chunk","created":1731749686,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_bb84311112","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"D"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UUHvolQofVGqVPYjJw1LwOEMC7","object":"chat.completion.chunk","created":1731749686,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_bb84311112","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"ublin"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UUHvolQofVGqVPYjJw1LwOEMC7","object":"chat.completion.chunk","created":1731749686,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_bb84311112","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\",\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UUHvolQofVGqVPYjJw1LwOEMC7","object":"chat.completion.chunk","created":1731749686,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_bb84311112","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"country"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UUHvolQofVGqVPYjJw1LwOEMC7","object":"chat.completion.chunk","created":1731749686,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_bb84311112","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UUHvolQofVGqVPYjJw1LwOEMC7","object":"chat.completion.chunk","created":1731749686,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_bb84311112","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Ireland"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UUHvolQofVGqVPYjJw1LwOEMC7","object":"chat.completion.chunk","created":1731749686,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_bb84311112","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"}"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UUHvolQofVGqVPYjJw1LwOEMC7","object":"chat.completion.chunk","created":1731749686,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_bb84311112","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UUHvolQofVGqVPYjJw1LwOEMC7","object":"chat.completion.chunk","created":1731749686,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_bb84311112","choices":[],"usage":{"prompt_tokens":73,"completion_tokens":10,"total_tokens":83,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367cb64f67645e-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:46 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '166' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29967' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 66ms + x-request-id: + - req_76a1fd93332b5938cb8fb9ca7c68ac81 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_prompt_function/test_decorator_return_str.yaml b/tests/cassettes/test_prompt_function/test_decorator_return_str.yaml new file mode 100644 index 00000000..7f24e914 --- /dev/null +++ b/tests/cassettes/test_prompt_function/test_decorator_return_str.yaml @@ -0,0 +1,104 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "What is the capital of Ireland? + Name only. No punctuation."}], "model": "gpt-4o", "stream": true, "stream_options": + {"include_usage": true}}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '183' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9USoDM9VoFGL0TyvHg9COHYE1oX","object":"chat.completion.chunk","created":1731749684,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9USoDM9VoFGL0TyvHg9COHYE1oX","object":"chat.completion.chunk","created":1731749684,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{"content":"D"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9USoDM9VoFGL0TyvHg9COHYE1oX","object":"chat.completion.chunk","created":1731749684,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{"content":"ublin"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9USoDM9VoFGL0TyvHg9COHYE1oX","object":"chat.completion.chunk","created":1731749684,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9USoDM9VoFGL0TyvHg9COHYE1oX","object":"chat.completion.chunk","created":1731749684,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[],"usage":{"prompt_tokens":20,"completion_tokens":2,"total_tokens":22,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367ca8ce17ed37-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:44 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '238' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29947' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 105ms + x-request-id: + - req_1c8450a76ace5d03f8a507e2ce504f08 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_prompt_function/test_decorator_return_streamed_str.yaml b/tests/cassettes/test_prompt_function/test_decorator_return_streamed_str.yaml new file mode 100644 index 00000000..aebfadd2 --- /dev/null +++ b/tests/cassettes/test_prompt_function/test_decorator_return_streamed_str.yaml @@ -0,0 +1,123 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "What is the capital of Ireland?"}], + "model": "gpt-4o", "stream": true, "stream_options": {"include_usage": true}}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '156' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UYHrU2QpCwERUUANaEXRiNRuGh","object":"chat.completion.chunk","created":1731749690,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UYHrU2QpCwERUUANaEXRiNRuGh","object":"chat.completion.chunk","created":1731749690,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":"The"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UYHrU2QpCwERUUANaEXRiNRuGh","object":"chat.completion.chunk","created":1731749690,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + capital"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UYHrU2QpCwERUUANaEXRiNRuGh","object":"chat.completion.chunk","created":1731749690,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + of"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UYHrU2QpCwERUUANaEXRiNRuGh","object":"chat.completion.chunk","created":1731749690,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + Ireland"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UYHrU2QpCwERUUANaEXRiNRuGh","object":"chat.completion.chunk","created":1731749690,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + is"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UYHrU2QpCwERUUANaEXRiNRuGh","object":"chat.completion.chunk","created":1731749690,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + Dublin"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UYHrU2QpCwERUUANaEXRiNRuGh","object":"chat.completion.chunk","created":1731749690,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":"."},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UYHrU2QpCwERUUANaEXRiNRuGh","object":"chat.completion.chunk","created":1731749690,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UYHrU2QpCwERUUANaEXRiNRuGh","object":"chat.completion.chunk","created":1731749690,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[],"usage":{"prompt_tokens":14,"completion_tokens":7,"total_tokens":21,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367ccdea42689b-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:50 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '232' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29975' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 50ms + x-request-id: + - req_9e40beeb0e0f5d292528a67228119422 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_vision/test_chatprompt_with_user_image_message.yaml b/tests/cassettes/test_vision/test_chatprompt_with_user_image_message.yaml new file mode 100644 index 00000000..7f6100e4 --- /dev/null +++ b/tests/cassettes/test_vision/test_chatprompt_with_user_image_message.yaml @@ -0,0 +1,105 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Describe this image in one word."}, + {"role": "user", "content": [{"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,/9j/4QDoRXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAAagEoAAMAAAABAAIAAAExAAIAAAARAAAAcgITAAMAAAABAAEAAIdpAAQAAAABAAAAhAAAAAAAAABIAAAAAQAAAEgAAAABd3d3Lmlua3NjYXBlLm9yZwAAAAeQAAAHAAAABDAyMjGRAQAHAAAABAECAwCgAAAHAAAABDAxMDCgAQADAAAAAQABAACgAgAEAAAAAQAAADKgAwAEAAAAAQAAAEGkBgADAAAAAQAAAAAAAAAAAAD/2wCEAAEBAQEBAQIBAQIDAgICAwQDAwMDBAYEBAQEBAYHBgYGBgYGBwcHBwcHBwcICAgICAgJCQkJCQsLCwsLCwsLCwsBAgICAwMDBQMDBQsIBggLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLC//dAAQABP/AABEIAEEAMgMBIgACEQEDEQH/xAGiAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgsQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+gEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoLEQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/AP6RNf8AEvh/wrZLqPiS8hsYGcRI0zhAzt0Rc9WOOFHJ7CsbRfiP4E8RQ2M+h6rbXK6lLLb2wRxl5YFLSJjqGQKdykAjHNeSftB3t7p2r/Du90+zkv5o/FKlbeJkR3/4l99wpkZUzjplgPcV5npXw7+KGm+KYfi7JocjSSeKLvVG0RJ7f7RFaXFgLIMGMggMu5BI6CXbhuDkYIB7z4n+N/grw14j0Pw4Z1uX1jVJ9JZozkW81vA8zBwAeflVcf7YPQVzvwf+N/h/xhZf2P4l1iwXX31XVrOOzWRUlKWd3PHGuzOd3kxq2OpALYxXi/gHQPFniHV4/HNjpj/8Srx/qd7cWnmxeasMllJZkg7/ACyY5HG4B+gOMkAHr9N+FHja3+H2g6I9kEvLLxrcaxKBJHlLSTULiYSA5xkwyL8o+bBxjqKAPoDSvin8Odb1yfw1pOs2k99b+aHiWQf8sOJAD0PlnhwudnfFHhv4pfDvxfrD+H/DOsW17eJEZ/KifJaIHaXTs6A4BZMgEgelfKdt8JfiZc+C/Cnw0m0p7Y+D1vWk1MzwlL4ta3FtGsW1zJmczCSXzUjAwRzxXqPhv4c+K9P8QfDDUbq0Cr4c8P3VhqDb0JimlitVVOD8wLRNyuRx9KAPpmiiigD/0P6SdU0HR9ansrnVbdJ5NOn+1WzMOYpgjR7l99jsv0NWNT02z1jT5dLv1LQTrscKxQkH3Ugj8DV+vzj/AGwv25NT/Z+8VwfD3wHpltqGqeQtxczXm4wxLJnYgRChLEDJO4ADHXt25fl1fG1lQw8by+7RHFj8woYKj7bEO0djrPip8f8Axl8IfDXjH/hR3gS1vvDfwx+wRa1eSXcdrFbSakR5Kx24/eSZZhuZe+cjvXyH4G/4K3TvrtvafEvwrFBp0jBZbjT5mMkQP8XluPmA7gMD6elfBPxE/aGtviT4ov8Axn4w8F6Lc3+psj3LrLqEauUUKvyJeKvAA6CvlrWbiG9v5rq0t0tI5pGZIIixSMMchF3lmwo4G5icdSa/SsNwthI0fZ4ij71lrfyV9pPre2iVrKx+cYnijFOtz4er7va3S+n2V0st36n9ocMsU8SzwkMjgMpHQg9KkrB0HzbXRLG3nXayQRKwPBBCit6vwbh/irLc69usvnd0Zckk1azX6O2jXY/Y8dleIwapuvG3MroKKKK+iOA//9H+mCv51/8Ago9oGp6T+01qOqXqsINUtLSe3Yj5SiRCI4+jRmv6KK8z+I3wb+F/xcgt7f4kaJbasLXPktMvzx7uoVlwwBwMgHHFe9w7m8ctxft5xvFpp2+X+R4XEOUSzHC+whKzTTXbt+TPiH9mP/gnb8A9T+DGheMfilp8muarrdnFfPuuJYY4VnUOsaLC6fdUgEnOTnGBgD6M0D9hf9lPwXr1t4l0HwhAt5ZuJIWmmnuFV16HZLIyZHbjivrXw3pWmaB4YsdA0WJYLSwhS3hiXokcQ2qo+gAFbkGg29/o+oatLfw272QQrBI2JJt5x8g77e9fxZxf4kcX4zP8xwkM1q04c9VKCk4pQi5aJK1rRWnV9Ls/Ycj4SyTDYDDTeDpykow15U3ey1u13+70PPbkZO0fSr9N2jO4jmnV+u+FXh9iOGKGJeLqxnUrOPw3slFO26WvvO+nY8TifPqeZTpKlG0YJ72627dNEFFFFfrB8sf/0v6L/GHjbTfBq6fDdQzXd3q1ybKxtbdVMk84hknKguURcRQyNl2VcLjOcCvM0/aR+GsmlprURu2to7YXl+wgP/EugMskG65H8O2WGVGC7iPLZsbFLDS+L3grxP4w1zwRP4anlshpGuSXtzdQ+UXghOm30AYLMrK2ZJo0ICk4bIxjcOQP7LXgyLTpdHsNT1CC01GzNjrEYMLf2nC1xNct55MR2l5LifcYvLysrDA+Xb1wjQ5VzvX/AIf9LW/yOScq3M+Raf8AAX9P8Do5f2lPhjYXaWNxczwzPHqzlDEQU/sV2S4RsdGPlu0Y/jVGI4FRv+018LEvtXs9QvJIBosN7NO7JuDDTmWO6CKhZ90TsEIKjcc7NwBIz9c/Zh+HGv8AiLUvE1492txqerWOsOEkARJLGMxeWg28Rzo8qzL/ABiV+Rmp7v8AZ38P3GieI/CkOqXsOkeJDeyS2irBiGXUXMs7RyGLzMGRmcKzEAsf4dqryzy3K51Y4iVJOore84q69Ha+n6GixGOjF01L3e3T7rmndfH7wXpPiCw8KeJILrStRvRalre5EW+D7dO1va+Zskf/AF0iEKE37B/rNlc/onxqm8afFfQdD8MQXUWhX1nq8n2ieJFivHsZbeNXhOTJsBd8ZVA4IIyMGu91H4U6fc/EQ/ErTL+4sLy4gtra8jjSGSK4itHd4siWNyjDzHUtGVJU4PIUrn+B/groPgbUbK9tL67u49Jju4NNgnMYjtLe8dHeJNkaMyr5aqm8sVUAe9dSdBK/W36f57eXmZ2rXt0/4b9PL8D2SiiiuQ6z/9P+mCiiigAooooAKKKKACiiigD/2Q==", + "detail": "auto"}}]}], "model": "gpt-4-vision-preview", "stream": true, "stream_options": + {"include_usage": true}}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '3928' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UekcCIrvw5AYOdFePjtg7isKEN","object":"chat.completion.chunk","created":1731749696,"model":"gpt-4-1106-vision-preview","system_fingerprint":null,"choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UekcCIrvw5AYOdFePjtg7isKEN","object":"chat.completion.chunk","created":1731749696,"model":"gpt-4-1106-vision-preview","system_fingerprint":null,"choices":[{"index":0,"delta":{"content":"Programming"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UekcCIrvw5AYOdFePjtg7isKEN","object":"chat.completion.chunk","created":1731749696,"model":"gpt-4-1106-vision-preview","system_fingerprint":null,"choices":[{"index":0,"delta":{"content":"."},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UekcCIrvw5AYOdFePjtg7isKEN","object":"chat.completion.chunk","created":1731749696,"model":"gpt-4-1106-vision-preview","system_fingerprint":null,"choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UekcCIrvw5AYOdFePjtg7isKEN","object":"chat.completion.chunk","created":1731749696,"model":"gpt-4-1106-vision-preview","system_fingerprint":null,"choices":[],"usage":{"prompt_tokens":273,"completion_tokens":2,"total_tokens":275,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367cf02b3fcfdd-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:57 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '1075' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '10000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '9209' + x-ratelimit-reset-requests: + - 2m52.8s + x-ratelimit-reset-tokens: + - 4.746s + x-request-id: + - req_8b2091daa7462e82b6a8dbffd2307cfb + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_vision/test_chatprompt_with_user_image_message_anthropic.yaml b/tests/cassettes/test_vision/test_chatprompt_with_user_image_message_anthropic.yaml new file mode 100644 index 00000000..4e0a7d39 --- /dev/null +++ b/tests/cassettes/test_vision/test_chatprompt_with_user_image_message_anthropic.yaml @@ -0,0 +1,113 @@ +interactions: +- request: + body: '{"max_tokens": 1024, "messages": [{"role": "user", "content": [{"type": + "text", "text": "Describe this image in one word."}, {"type": "image", "source": + {"type": "base64", "media_type": "image/jpeg", "data": "/9j/4QDoRXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAAagEoAAMAAAABAAIAAAExAAIAAAARAAAAcgITAAMAAAABAAEAAIdpAAQAAAABAAAAhAAAAAAAAABIAAAAAQAAAEgAAAABd3d3Lmlua3NjYXBlLm9yZwAAAAeQAAAHAAAABDAyMjGRAQAHAAAABAECAwCgAAAHAAAABDAxMDCgAQADAAAAAQABAACgAgAEAAAAAQAAADKgAwAEAAAAAQAAAEGkBgADAAAAAQAAAAAAAAAAAAD/2wCEAAEBAQEBAQIBAQIDAgICAwQDAwMDBAYEBAQEBAYHBgYGBgYGBwcHBwcHBwcICAgICAgJCQkJCQsLCwsLCwsLCwsBAgICAwMDBQMDBQsIBggLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLC//dAAQABP/AABEIAEEAMgMBIgACEQEDEQH/xAGiAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgsQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+gEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoLEQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/AP6RNf8AEvh/wrZLqPiS8hsYGcRI0zhAzt0Rc9WOOFHJ7CsbRfiP4E8RQ2M+h6rbXK6lLLb2wRxl5YFLSJjqGQKdykAjHNeSftB3t7p2r/Du90+zkv5o/FKlbeJkR3/4l99wpkZUzjplgPcV5npXw7+KGm+KYfi7JocjSSeKLvVG0RJ7f7RFaXFgLIMGMggMu5BI6CXbhuDkYIB7z4n+N/grw14j0Pw4Z1uX1jVJ9JZozkW81vA8zBwAeflVcf7YPQVzvwf+N/h/xhZf2P4l1iwXX31XVrOOzWRUlKWd3PHGuzOd3kxq2OpALYxXi/gHQPFniHV4/HNjpj/8Srx/qd7cWnmxeasMllJZkg7/ACyY5HG4B+gOMkAHr9N+FHja3+H2g6I9kEvLLxrcaxKBJHlLSTULiYSA5xkwyL8o+bBxjqKAPoDSvin8Odb1yfw1pOs2k99b+aHiWQf8sOJAD0PlnhwudnfFHhv4pfDvxfrD+H/DOsW17eJEZ/KifJaIHaXTs6A4BZMgEgelfKdt8JfiZc+C/Cnw0m0p7Y+D1vWk1MzwlL4ta3FtGsW1zJmczCSXzUjAwRzxXqPhv4c+K9P8QfDDUbq0Cr4c8P3VhqDb0JimlitVVOD8wLRNyuRx9KAPpmiiigD/0P6SdU0HR9ansrnVbdJ5NOn+1WzMOYpgjR7l99jsv0NWNT02z1jT5dLv1LQTrscKxQkH3Ugj8DV+vzj/AGwv25NT/Z+8VwfD3wHpltqGqeQtxczXm4wxLJnYgRChLEDJO4ADHXt25fl1fG1lQw8by+7RHFj8woYKj7bEO0djrPip8f8Axl8IfDXjH/hR3gS1vvDfwx+wRa1eSXcdrFbSakR5Kx24/eSZZhuZe+cjvXyH4G/4K3TvrtvafEvwrFBp0jBZbjT5mMkQP8XluPmA7gMD6elfBPxE/aGtviT4ov8Axn4w8F6Lc3+psj3LrLqEauUUKvyJeKvAA6CvlrWbiG9v5rq0t0tI5pGZIIixSMMchF3lmwo4G5icdSa/SsNwthI0fZ4ij71lrfyV9pPre2iVrKx+cYnijFOtz4er7va3S+n2V0st36n9ocMsU8SzwkMjgMpHQg9KkrB0HzbXRLG3nXayQRKwPBBCit6vwbh/irLc69usvnd0Zckk1azX6O2jXY/Y8dleIwapuvG3MroKKKK+iOA//9H+mCv51/8Ago9oGp6T+01qOqXqsINUtLSe3Yj5SiRCI4+jRmv6KK8z+I3wb+F/xcgt7f4kaJbasLXPktMvzx7uoVlwwBwMgHHFe9w7m8ctxft5xvFpp2+X+R4XEOUSzHC+whKzTTXbt+TPiH9mP/gnb8A9T+DGheMfilp8muarrdnFfPuuJYY4VnUOsaLC6fdUgEnOTnGBgD6M0D9hf9lPwXr1t4l0HwhAt5ZuJIWmmnuFV16HZLIyZHbjivrXw3pWmaB4YsdA0WJYLSwhS3hiXokcQ2qo+gAFbkGg29/o+oatLfw272QQrBI2JJt5x8g77e9fxZxf4kcX4zP8xwkM1q04c9VKCk4pQi5aJK1rRWnV9Ls/Ycj4SyTDYDDTeDpykow15U3ey1u13+70PPbkZO0fSr9N2jO4jmnV+u+FXh9iOGKGJeLqxnUrOPw3slFO26WvvO+nY8TifPqeZTpKlG0YJ72627dNEFFFFfrB8sf/0v6L/GHjbTfBq6fDdQzXd3q1ybKxtbdVMk84hknKguURcRQyNl2VcLjOcCvM0/aR+GsmlprURu2to7YXl+wgP/EugMskG65H8O2WGVGC7iPLZsbFLDS+L3grxP4w1zwRP4anlshpGuSXtzdQ+UXghOm30AYLMrK2ZJo0ICk4bIxjcOQP7LXgyLTpdHsNT1CC01GzNjrEYMLf2nC1xNct55MR2l5LifcYvLysrDA+Xb1wjQ5VzvX/AIf9LW/yOScq3M+Raf8AAX9P8Do5f2lPhjYXaWNxczwzPHqzlDEQU/sV2S4RsdGPlu0Y/jVGI4FRv+018LEvtXs9QvJIBosN7NO7JuDDTmWO6CKhZ90TsEIKjcc7NwBIz9c/Zh+HGv8AiLUvE1492txqerWOsOEkARJLGMxeWg28Rzo8qzL/ABiV+Rmp7v8AZ38P3GieI/CkOqXsOkeJDeyS2irBiGXUXMs7RyGLzMGRmcKzEAsf4dqryzy3K51Y4iVJOore84q69Ha+n6GixGOjF01L3e3T7rmndfH7wXpPiCw8KeJILrStRvRalre5EW+D7dO1va+Zskf/AF0iEKE37B/rNlc/onxqm8afFfQdD8MQXUWhX1nq8n2ieJFivHsZbeNXhOTJsBd8ZVA4IIyMGu91H4U6fc/EQ/ErTL+4sLy4gtra8jjSGSK4itHd4siWNyjDzHUtGVJU4PIUrn+B/groPgbUbK9tL67u49Jju4NNgnMYjtLe8dHeJNkaMyr5aqm8sVUAe9dSdBK/W36f57eXmZ2rXt0/4b9PL8D2SiiiuQ6z/9P+mCiiigAooooAKKKKACiiigD/2Q=="}}]}], + "model": "claude-3-haiku-20240307", "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '3904' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.39.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.39.0 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + x-stainless-stream-helper: + - messages + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_01RuDdh1j88J9j3nWwZE1W4w","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":24,"output_tokens":2}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Program"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"med."}} + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null},"usage":{"output_tokens":7} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e36924269e7169a-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:49:29 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_01NdQTfXvCbzfhS6QFVdomLq + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete[List three fruits-output_types3-list].yaml b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete[List three fruits-output_types3-list].yaml new file mode 100644 index 00000000..13bf740e --- /dev/null +++ b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete[List three fruits-output_types3-list].yaml @@ -0,0 +1,148 @@ +interactions: +- request: + body: '{"max_tokens": 1024, "messages": [{"role": "user", "content": [{"type": + "text", "text": "List three fruits"}]}], "model": "claude-3-haiku-20240307", + "tools": [{"name": "return_list_of_str", "description": "", "input_schema": + {"properties": {"value": {"items": {"type": "string"}, "title": "Value", "type": + "array"}}, "required": ["value"], "type": "object"}}], "tool_choice": {"type": + "tool", "name": "return_list_of_str"}, "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '439' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - AsyncAnthropic/Python 0.39.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.39.0 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + x-stainless-stream-helper: + - messages + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_0112MGZjoQ4ZLYCnpMbygvh5","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":437,"output_tokens":19}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_011gNN2edn7N8oXLrunbZtEr","name":"return_list_of_str","input":{}} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\"value\": + [\""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"apple"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"\","} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":" + \"ban"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"ana"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"\", + \"or"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"ange\"]}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":41} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3691df3a49cfd9-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:49:14 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_01DQRCtSo88cPjZVdDNqxwhC + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete[Return True-output_types1-bool].yaml b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete[Return True-output_types1-bool].yaml new file mode 100644 index 00000000..48291510 --- /dev/null +++ b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete[Return True-output_types1-bool].yaml @@ -0,0 +1,125 @@ +interactions: +- request: + body: '{"max_tokens": 1024, "messages": [{"role": "user", "content": [{"type": + "text", "text": "Return True"}]}], "model": "claude-3-haiku-20240307", "tools": + [{"name": "return_bool", "description": "", "input_schema": {"properties": {"value": + {"title": "Value", "type": "boolean"}}, "required": ["value"], "type": "object"}}], + "tool_choice": {"type": "tool", "name": "return_bool"}, "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '392' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - AsyncAnthropic/Python 0.39.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.39.0 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + x-stainless-stream-helper: + - messages + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_01DascK4FkKUmTE7apaN5P8y","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":418,"output_tokens":19}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_01HvGEn3ZnQAZ3opDFUUNeqR","name":"return_bool","input":{}}} + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\"value\": + "} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"tru"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"e}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":33} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3691d51c73ceb1-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:49:12 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_016hQbxJRWpUiZQspfbchzat + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete[Return the numbers 1 to 5-output_types2-list].yaml b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete[Return the numbers 1 to 5-output_types2-list].yaml new file mode 100644 index 00000000..295d2d3c --- /dev/null +++ b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete[Return the numbers 1 to 5-output_types2-list].yaml @@ -0,0 +1,133 @@ +interactions: +- request: + body: '{"max_tokens": 1024, "messages": [{"role": "user", "content": [{"type": + "text", "text": "Return the numbers 1 to 5"}]}], "model": "claude-3-haiku-20240307", + "tools": [{"name": "return_list_of_int", "description": "", "input_schema": + {"properties": {"value": {"items": {"type": "integer"}, "title": "Value", "type": + "array"}}, "required": ["value"], "type": "object"}}], "tool_choice": {"type": + "tool", "name": "return_list_of_int"}, "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '448' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - AsyncAnthropic/Python 0.39.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.39.0 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + x-stainless-stream-helper: + - messages + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_01HrohtjfXXAoUZv2VWxCznS","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":443,"output_tokens":23}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_011wdiikpYEsSCyzy3a4uLBa","name":"return_list_of_int","input":{}} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\"valu"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"e\": + [1, "} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"2, + 3,"}} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":" + 4, 5]}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":47} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3691daae697ae5-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:49:13 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_0158eJFUJW1ZZ5zrkF3uEk8V + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete[Say hello!-output_types0-str].yaml b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete[Say hello!-output_types0-str].yaml new file mode 100644 index 00000000..775d8e93 --- /dev/null +++ b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete[Say hello!-output_types0-str].yaml @@ -0,0 +1,108 @@ +interactions: +- request: + body: '{"max_tokens": 1024, "messages": [{"role": "user", "content": [{"type": + "text", "text": "Say hello!"}]}], "model": "claude-3-haiku-20240307", "stream": + true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '157' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - AsyncAnthropic/Python 0.39.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.39.0 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + x-stainless-stream-helper: + - messages + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_01V83KTfaDjzmroDDH21Hhy5","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":10,"output_tokens":2}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""} + } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello!"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null},"usage":{"output_tokens":5} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3691d2989a256c-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:49:11 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_01DZjFpoR1cRoTVw9N2mRz6w + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete_async_parallel_function_call.yaml b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete_async_parallel_function_call.yaml new file mode 100644 index 00000000..b73ba3eb --- /dev/null +++ b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete_async_parallel_function_call.yaml @@ -0,0 +1,169 @@ +interactions: +- request: + body: '{"max_tokens": 1024, "messages": [{"role": "user", "content": [{"type": + "text", "text": "Use the plus tool to sum 1 and 2. Use the minus tool to subtract + 1 from 2. Use both tools at the same time."}]}], "model": "claude-3-opus-20240229", + "tools": [{"name": "plus", "description": "", "input_schema": {"properties": + {"a": {"title": "A", "type": "integer"}, "b": {"title": "B", "type": "integer"}}, + "required": ["a", "b"], "type": "object"}}, {"name": "minus", "description": + "", "input_schema": {"properties": {"a": {"title": "A", "type": "integer"}, + "b": {"title": "B", "type": "integer"}}, "required": ["a", "b"], "type": "object"}}], + "tool_choice": {"type": "any"}, "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '683' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - AsyncAnthropic/Python 0.39.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.39.0 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + x-stainless-stream-helper: + - messages + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_012X15Kcz2Wu677j3nd9FqEh","type":"message","role":"assistant","model":"claude-3-opus-20240229","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":469,"output_tokens":8}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_01RJGtVku2YsNB6VPCM1vD7x","name":"plus","input":{}} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""}} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\"a\": + 1"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":", + "} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"\"b\""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":": + 2}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: content_block_start + + data: {"type":"content_block_start","index":1,"content_block":{"type":"tool_use","id":"toolu_01GuGH37ceFTQc3k53ui7JvQ","name":"minus","input":{}} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":"{\""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":"a\": + 2"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":", + \"b\": 1}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":1 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":104} + } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3691fa6dc69667-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:49:21 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_01GXWHQw2cE2gB1c1CW9tXmz + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete_function_call.yaml b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete_function_call.yaml new file mode 100644 index 00000000..63a5b35c --- /dev/null +++ b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete_function_call.yaml @@ -0,0 +1,128 @@ +interactions: +- request: + body: '{"max_tokens": 1024, "messages": [{"role": "user", "content": [{"type": + "text", "text": "Use the tool to sum 1 and 2"}]}], "model": "claude-3-haiku-20240307", + "tools": [{"name": "plus", "description": "Sum two numbers.", "input_schema": + {"properties": {"a": {"title": "A", "type": "integer"}, "b": {"title": "B", + "type": "integer"}}, "required": ["a", "b"], "type": "object"}}], "tool_choice": + {"type": "tool", "name": "plus"}, "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '443' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - AsyncAnthropic/Python 0.39.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.39.0 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + x-stainless-stream-helper: + - messages + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_01GYPUQowpzUpkBPt4HMykzV","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":450,"output_tokens":20}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_01A8zhHTSo88ebpMvxmG21Qa","name":"plus","input":{}} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\"a\": + 1"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":", + \"b"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"\": + 2}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":50} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3691f4eb9e9e74-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:49:17 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_01HB8Zfhv3jVq6w6pWCqtdqT + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete_raises_tool_schema_parse_error.yaml b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete_raises_tool_schema_parse_error.yaml new file mode 100644 index 00000000..f93e4708 --- /dev/null +++ b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete_raises_tool_schema_parse_error.yaml @@ -0,0 +1,127 @@ +interactions: +- request: + body: '{"max_tokens": 1024, "messages": [{"role": "user", "content": [{"type": + "text", "text": "Return a test value of 42."}]}], "model": "claude-3-haiku-20240307", + "tools": [{"name": "return_test", "description": "", "input_schema": {"properties": + {"value": {"title": "Value", "type": "integer"}}, "required": ["value"], "type": + "object"}}], "tool_choice": {"type": "tool", "name": "return_test"}, "stream": + true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '407' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - AsyncAnthropic/Python 0.39.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.39.0 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + x-stainless-stream-helper: + - messages + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_01KRooZ1rHZDqY2y9stMtw5n","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":424,"output_tokens":20}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_01Qr1nZ8ap53UeDikVZjmrD1","name":"return_test","input":{}} + } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\"valu"}} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"e\": + 4"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"2}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":33} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-RAY: + - 8e3691efce2bfaaa-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:49:16 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + cf-cache-status: + - DYNAMIC + request-id: + - req_01VmQBWGw2b49id16pLqpw8s + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete_usage.yaml b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete_usage.yaml new file mode 100644 index 00000000..f5d82c82 --- /dev/null +++ b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete_usage.yaml @@ -0,0 +1,107 @@ +interactions: +- request: + body: '{"max_tokens": 1024, "messages": [{"role": "user", "content": [{"type": + "text", "text": "Say hello!"}]}], "model": "claude-3-haiku-20240307", "stream": + true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '157' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - AsyncAnthropic/Python 0.39.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.39.0 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + x-stainless-stream-helper: + - messages + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_015LRTGyXQyMXJvySdwPFM4s","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":10,"output_tokens":2}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello!"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null},"usage":{"output_tokens":5} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3691e65ffe2700-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:49:15 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_01G2cpZjBjeVSBBqBwTB1DL7 + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete_usage_structured_output.yaml b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete_usage_structured_output.yaml new file mode 100644 index 00000000..bd8749f6 --- /dev/null +++ b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_acomplete_usage_structured_output.yaml @@ -0,0 +1,133 @@ +interactions: +- request: + body: '{"max_tokens": 1024, "messages": [{"role": "user", "content": [{"type": + "text", "text": "Count to 5"}]}], "model": "claude-3-haiku-20240307", "tools": + [{"name": "return_list_of_int", "description": "", "input_schema": {"properties": + {"value": {"items": {"type": "integer"}, "title": "Value", "type": "array"}}, + "required": ["value"], "type": "object"}}], "tool_choice": {"type": "tool", + "name": "return_list_of_int"}, "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '433' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - AsyncAnthropic/Python 0.39.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.39.0 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + x-stainless-stream-helper: + - messages + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_017dm1Zo6f1VidVAoiVFvEmS","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":438,"output_tokens":22}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_01WEnDDMz3DwYEuVVNXQr1oQ","name":"return_list_of_int","input":{}} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\"value\":"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":" + [1, "} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"2, + 3, 4"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":", + 5]}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0} + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":47} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3691ea2b515c22-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:49:15 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_01NPcjcYWTbNdZZnojYbrm8g + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete[List three fruits-output_types3-list].yaml b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete[List three fruits-output_types3-list].yaml new file mode 100644 index 00000000..0c3e11e0 --- /dev/null +++ b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete[List three fruits-output_types3-list].yaml @@ -0,0 +1,143 @@ +interactions: +- request: + body: '{"max_tokens": 1024, "messages": [{"role": "user", "content": [{"type": + "text", "text": "List three fruits"}]}], "model": "claude-3-haiku-20240307", + "tools": [{"name": "return_list_of_str", "description": "", "input_schema": + {"properties": {"value": {"items": {"type": "string"}, "title": "Value", "type": + "array"}}, "required": ["value"], "type": "object"}}], "tool_choice": {"type": + "tool", "name": "return_list_of_str"}, "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '439' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.39.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.39.0 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + x-stainless-stream-helper: + - messages + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_018KaFKrex5PfZD8K59hD6E5","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":437,"output_tokens":15}}} + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_01XDGRbi61qxWvHe1Fu7YpTv","name":"return_list_of_str","input":{}} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\"value\": + ["} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"\"appl"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"e\", + \"b"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"anan"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"a\", + \"ora"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"nge\"]}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":41} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e36918c3a1b17f2-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:49:00 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_01Ne1W7SmPpV7JuhdHx3HEcD + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete[Return True-output_types1-bool].yaml b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete[Return True-output_types1-bool].yaml new file mode 100644 index 00000000..a5218d0d --- /dev/null +++ b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete[Return True-output_types1-bool].yaml @@ -0,0 +1,130 @@ +interactions: +- request: + body: '{"max_tokens": 1024, "messages": [{"role": "user", "content": [{"type": + "text", "text": "Return True"}]}], "model": "claude-3-haiku-20240307", "tools": + [{"name": "return_bool", "description": "", "input_schema": {"properties": {"value": + {"title": "Value", "type": "boolean"}}, "required": ["value"], "type": "object"}}], + "tool_choice": {"type": "tool", "name": "return_bool"}, "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '392' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.39.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.39.0 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + x-stainless-stream-helper: + - messages + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_012UuzyN2ywFJoSbJbERuuqE","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":418,"output_tokens":23}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_01Nnwtgay21yhqb8DawHUre1","name":"return_bool","input":{}} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"value"}} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"\": + tr"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"ue}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":33} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3691837f74eb29-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:48:59 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_01MDk6j5izjMXnbfStdk94sr + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete[Return the numbers 1 to 5-output_types2-list].yaml b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete[Return the numbers 1 to 5-output_types2-list].yaml new file mode 100644 index 00000000..995eb523 --- /dev/null +++ b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete[Return the numbers 1 to 5-output_types2-list].yaml @@ -0,0 +1,127 @@ +interactions: +- request: + body: '{"max_tokens": 1024, "messages": [{"role": "user", "content": [{"type": + "text", "text": "Return the numbers 1 to 5"}]}], "model": "claude-3-haiku-20240307", + "tools": [{"name": "return_list_of_int", "description": "", "input_schema": + {"properties": {"value": {"items": {"type": "integer"}, "title": "Value", "type": + "array"}}, "required": ["value"], "type": "object"}}], "tool_choice": {"type": + "tool", "name": "return_list_of_int"}, "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '448' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.39.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.39.0 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + x-stainless-stream-helper: + - messages + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_01XYProGF6uaZMxnaPy9iLi5","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":443,"output_tokens":18}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_01A4yjX3XN5zfJmJnq8oKV5w","name":"return_list_of_int","input":{}} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\"val"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"ue\": + [1,"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":" + 2, 3, 4, 5]}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":47} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e36918788b0fa2a-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:48:59 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_01LTHuZX7AMwJHHgpmaxXR16 + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete[Say hello!-output_types0-str].yaml b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete[Say hello!-output_types0-str].yaml new file mode 100644 index 00000000..13f31955 --- /dev/null +++ b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete[Say hello!-output_types0-str].yaml @@ -0,0 +1,107 @@ +interactions: +- request: + body: '{"max_tokens": 1024, "messages": [{"role": "user", "content": [{"type": + "text", "text": "Say hello!"}]}], "model": "claude-3-haiku-20240307", "stream": + true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '157' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.39.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.39.0 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + x-stainless-stream-helper: + - messages + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_01GpA1NoVFHQxEBPLbuTSw5Q","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":10,"output_tokens":2}}} + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello!"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null},"usage":{"output_tokens":5} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e369180d97f24df-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:48:58 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_01NCuzGmkNbhpyufidygKhPE + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete_function_call.yaml b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete_function_call.yaml new file mode 100644 index 00000000..581ea539 --- /dev/null +++ b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete_function_call.yaml @@ -0,0 +1,127 @@ +interactions: +- request: + body: '{"max_tokens": 1024, "messages": [{"role": "user", "content": [{"type": + "text", "text": "Use the tool to sum 1 and 2"}]}], "model": "claude-3-haiku-20240307", + "tools": [{"name": "plus", "description": "Sum two numbers.", "input_schema": + {"properties": {"a": {"title": "A", "type": "integer"}, "b": {"title": "B", + "type": "integer"}}, "required": ["a", "b"], "type": "object"}}], "tool_choice": + {"type": "tool", "name": "plus"}, "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '443' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.39.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.39.0 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + x-stainless-stream-helper: + - messages + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_01HHPbZSxL5ojfeDq4La3LgW","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":450,"output_tokens":20}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_01241nJU2Az1M4ksrkC48L7F","name":"plus","input":{}} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"a\": + 1"}} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":", + \"b\": 2}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":50} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3691a80fb967a8-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:49:05 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_01Ji3d6D29mX3fCW3KfeaCJK + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete_no_structured_output_error.yaml b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete_no_structured_output_error.yaml new file mode 100644 index 00000000..8bd77151 --- /dev/null +++ b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete_no_structured_output_error.yaml @@ -0,0 +1,123 @@ +interactions: +- request: + body: '{"max_tokens": 1024, "messages": [{"role": "user", "content": [{"type": + "text", "text": "Tell me a short joke. Return a string, not a tool call."}]}], + "model": "claude-3-haiku-20240307", "tools": [{"name": "return_int", "description": + "", "input_schema": {"properties": {"value": {"title": "Value", "type": "integer"}}, + "required": ["value"], "type": "object"}}, {"name": "return_bool", "description": + "", "input_schema": {"properties": {"value": {"title": "Value", "type": "boolean"}}, + "required": ["value"], "type": "object"}}], "tool_choice": {"type": "any"}, + "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '578' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.39.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.39.0 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + x-stainless-stream-helper: + - messages + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_01S86azh3xwx7QZoJxirtvhc","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":475,"output_tokens":8}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_01NKJhv1asrehTjeCV179BEQ","name":"return_int","input":{}} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\"value\": + "} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"42}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":38} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e36919a0aaf176d-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:49:03 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_01N9DCTgb5ZL8g5tqtAm9tS7 + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete_parallel_function_call.yaml b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete_parallel_function_call.yaml new file mode 100644 index 00000000..f9aaeaf4 --- /dev/null +++ b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete_parallel_function_call.yaml @@ -0,0 +1,163 @@ +interactions: +- request: + body: '{"max_tokens": 1024, "messages": [{"role": "user", "content": [{"type": + "text", "text": "Use the plus tool to sum 1 and 2. Use the minus tool to subtract + 1 from 2. Use both tools at the same time."}]}], "model": "claude-3-opus-20240229", + "tools": [{"name": "plus", "description": "", "input_schema": {"properties": + {"a": {"title": "A", "type": "integer"}, "b": {"title": "B", "type": "integer"}}, + "required": ["a", "b"], "type": "object"}}, {"name": "minus", "description": + "", "input_schema": {"properties": {"a": {"title": "A", "type": "integer"}, + "b": {"title": "B", "type": "integer"}}, "required": ["a", "b"], "type": "object"}}], + "tool_choice": {"type": "any"}, "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '683' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.39.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.39.0 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + x-stainless-stream-helper: + - messages + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_012f3EyS95ZaC3e3BnCqTDa7","type":"message","role":"assistant","model":"claude-3-opus-20240229","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":469,"output_tokens":8}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_01GsvW1rYits8MPJif9rkZ4G","name":"plus","input":{}} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\"a\": + 1"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":", + \"b\""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":": + "} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"2}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: content_block_start + + data: {"type":"content_block_start","index":1,"content_block":{"type":"tool_use","id":"toolu_01M2EwdtY31e6afyqWGhPCpc","name":"minus","input":{}} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":"{\"a\": + 2"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":", + \"b\": 1}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":1 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":104} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3691acab48fa8e-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:49:08 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_01NTz6P9SwW8GXBoocicUsGe + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete_raises_tool_schema_parse_error.yaml b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete_raises_tool_schema_parse_error.yaml new file mode 100644 index 00000000..48259971 --- /dev/null +++ b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete_raises_tool_schema_parse_error.yaml @@ -0,0 +1,126 @@ +interactions: +- request: + body: '{"max_tokens": 1024, "messages": [{"role": "user", "content": [{"type": + "text", "text": "Return a test value of 42."}]}], "model": "claude-3-haiku-20240307", + "tools": [{"name": "return_test", "description": "", "input_schema": {"properties": + {"value": {"title": "Value", "type": "integer"}}, "required": ["value"], "type": + "object"}}], "tool_choice": {"type": "tool", "name": "return_test"}, "stream": + true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '407' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.39.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.39.0 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + x-stainless-stream-helper: + - messages + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_01JXPa72pYkSKvH8WPeUCWda","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":424,"output_tokens":24}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_019YyzPstko6nDxuysY9HEXd","name":"return_test","input":{}} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\"valu"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"e\": + 4"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"2}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":33} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3691a10eac67ef-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:49:04 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_019tQZw2ihJPm54aNMskMbYP + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete_usage.yaml b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete_usage.yaml new file mode 100644 index 00000000..48d879c4 --- /dev/null +++ b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete_usage.yaml @@ -0,0 +1,112 @@ +interactions: +- request: + body: '{"max_tokens": 1024, "messages": [{"role": "user", "content": [{"type": + "text", "text": "Say hello!"}]}], "model": "claude-3-haiku-20240307", "stream": + true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '157' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.39.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.39.0 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + x-stainless-stream-helper: + - messages + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_01JA4HW2syaVwCPnGCr7YyUt","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":10,"output_tokens":1}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"!"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null},"usage":{"output_tokens":5} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e36919108e1ce70-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:49:01 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_01KzDy3XbJH8hEFdH9vwkt5H + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete_usage_structured_output.yaml b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete_usage_structured_output.yaml new file mode 100644 index 00000000..9bad4825 --- /dev/null +++ b/tests/chat_model/cassettes/test_anthropic_chat_model/test_anthropic_chat_model_complete_usage_structured_output.yaml @@ -0,0 +1,127 @@ +interactions: +- request: + body: '{"max_tokens": 1024, "messages": [{"role": "user", "content": [{"type": + "text", "text": "Count to 5"}]}], "model": "claude-3-haiku-20240307", "tools": + [{"name": "return_list_of_int", "description": "", "input_schema": {"properties": + {"value": {"items": {"type": "integer"}, "title": "Value", "type": "array"}}, + "required": ["value"], "type": "object"}}], "tool_choice": {"type": "tool", + "name": "return_list_of_int"}, "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '433' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.39.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.39.0 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + x-stainless-stream-helper: + - messages + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_0116XLL7XUccn6FbtwrrUT2X","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":438,"output_tokens":22}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_01FLCbsmf2rzFD92tDTCYWx7","name":"return_list_of_int","input":{}} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\"valu"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"e\": + [1, 2"}} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":", + 3, 4, 5]}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":47} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e36919328e167b3-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:49:02 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_016qnx1wRUHhWinN9N2i3WpG + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_anthropic[Return True-output_types1-bool].yaml b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_anthropic[Return True-output_types1-bool].yaml new file mode 100644 index 00000000..e4d27063 --- /dev/null +++ b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_anthropic[Return True-output_types1-bool].yaml @@ -0,0 +1,108 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": [{"type": "text", "text": "Return + True"}]}], "tools": [{"name": "return_bool", "input_schema": {"properties": + {"value": {"title": "Value", "type": "boolean"}}, "required": ["value"], "type": + "object"}}], "tool_choice": {"type": "tool", "name": "return_bool"}, "max_tokens": + 4096, "model": "claude-3-haiku-20240307", "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '373' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - litellm/1.52.6 + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_01FQd6QU1NdrMaoMfjM4423e","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":418,"output_tokens":19}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_016LwwbEV3h5jQ4pGxBxhbqW","name":"return_bool","input":{}} + } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\"value"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"\":"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":" + true}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":33} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3e082f9c4b15d4-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:33:20 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_01JsdSkoEyJCxNdDAnSUKDVb + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_anthropic[Return the numbers 1 to 5-output_types2-list].yaml b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_anthropic[Return the numbers 1 to 5-output_types2-list].yaml new file mode 100644 index 00000000..b3b48500 --- /dev/null +++ b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_anthropic[Return the numbers 1 to 5-output_types2-list].yaml @@ -0,0 +1,121 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": [{"type": "text", "text": "Return + the numbers 1 to 5"}]}], "tools": [{"name": "return_list_of_int", "input_schema": + {"properties": {"value": {"items": {"type": "integer"}, "title": "Value", "type": + "array"}}, "required": ["value"], "type": "object"}}], "tool_choice": {"type": + "tool", "name": "return_list_of_int"}, "max_tokens": 4096, "model": "claude-3-haiku-20240307", + "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '429' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - litellm/1.52.6 + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_014r9cnDB9ecLXgwfTYr8jMH","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":443,"output_tokens":26}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_016sjfiVHSXm2C4uq5rBkcQd","name":"return_list_of_int","input":{}} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\"va"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"lue\": + "} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"[1, + 2, 3"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":", + 4"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":", + 5]}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":47} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3e0351eefef94b-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:30:01 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_01NCDe2yQFkBUEkGrQijMZyu + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_anthropic[Say hello!-output_types0-str].yaml b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_anthropic[Say hello!-output_types0-str].yaml new file mode 100644 index 00000000..1d5809d4 --- /dev/null +++ b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_anthropic[Say hello!-output_types0-str].yaml @@ -0,0 +1,94 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": [{"type": "text", "text": "Say + hello!"}]}], "max_tokens": 4096, "model": "claude-3-haiku-20240307", "stream": + true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '157' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - litellm/1.52.6 + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_017qZTvwsnnrVdzXbAQfthUh","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":10,"output_tokens":1}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"!"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0} + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null},"usage":{"output_tokens":5} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3e034aba091584-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:29:59 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_01TyZAQvsFEy5qmkLRe4c5Za + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_anthropic_async_parallel_function_call.yaml b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_anthropic_async_parallel_function_call.yaml new file mode 100644 index 00000000..872ac00c --- /dev/null +++ b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_anthropic_async_parallel_function_call.yaml @@ -0,0 +1,106 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": [{"type": "text", "text": "Use + the plus tool to sum 1 and 2. Use the minus tool to subtract 1 from 2."}]}], + "tools": [{"name": "plus", "input_schema": {"properties": {"a": {"title": "A", + "type": "integer"}, "b": {"title": "B", "type": "integer"}}, "required": ["a", + "b"], "type": "object"}}, {"name": "minus", "input_schema": {"properties": {"a": + {"title": "A", "type": "integer"}, "b": {"title": "B", "type": "integer"}}, + "required": ["a", "b"], "type": "object"}}], "tool_choice": {"type": "any"}, + "max_tokens": 4096, "model": "claude-3-haiku-20240307", "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '613' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - litellm/1.52.6 + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_01V6ee3cxMD3U9WhW5BhQNYC","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":520,"output_tokens":12}}} + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_01AxzhUYwDB4V16SpHkEJgNk","name":"plus","input":{}} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\"a\": + 1"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":", + \"b\": 2}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":53} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-RAY: + - 8e3e035b7af124ee-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:30:02 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + cf-cache-status: + - DYNAMIC + request-id: + - req_014s5rkoqfE4RJF9fJABAnZq + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_anthropic_function_call.yaml b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_anthropic_function_call.yaml new file mode 100644 index 00000000..8f026867 --- /dev/null +++ b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_anthropic_function_call.yaml @@ -0,0 +1,109 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": [{"type": "text", "text": "Use + the tool to sum 1 and 2"}]}], "tools": [{"name": "plus", "input_schema": {"properties": + {"a": {"title": "A", "type": "integer"}, "b": {"title": "B", "type": "integer"}}, + "required": ["a", "b"], "type": "object"}, "description": "Sum two numbers."}], + "tool_choice": {"type": "tool", "name": "plus"}, "max_tokens": 4096, "model": + "claude-3-haiku-20240307", "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '443' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - litellm/1.52.6 + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_01EVQvLSiD8JrU7SZBHq91gg","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":450,"output_tokens":12}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_017jinMBaL2FmAAMNpgA7AFS","name":"plus","input":{}} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\"a\":"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":" + 1"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":", + \"b\": 2}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":50} } + + + event: message_stop + + data: {"type":"message_stop"} + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3e089f7aa8ce98-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:33:38 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_01YMKM4VMVMkHirZKNKz29py + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_ollama[Say hello!-output_types0-str].yaml b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_ollama[Say hello!-output_types0-str].yaml new file mode 100644 index 00000000..5782ec65 --- /dev/null +++ b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_ollama[Say hello!-output_types0-str].yaml @@ -0,0 +1,861 @@ +interactions: +- request: + body: '{"name": "llama3.1"}' + headers: + accept: + - '*/*' + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '20' + content-type: + - application/json + host: + - localhost:11434 + user-agent: + - litellm/1.52.6 + method: POST + uri: http://localhost:11434/api/show + response: + body: + string: "{\"license\":\"LLAMA 3.1 COMMUNITY LICENSE AGREEMENT\\nLlama 3.1 Version + Release Date: July 23, 2024\\n\\n\u201CAgreement\u201D means the terms and + conditions for use, reproduction, distribution and modification of the\\nLlama + Materials set forth herein.\\n\\n\u201CDocumentation\u201D means the specifications, + manuals and documentation accompanying Llama 3.1\\ndistributed by Meta at + https://llama.meta.com/doc/overview.\\n\\n\u201CLicensee\u201D or \u201Cyou\u201D + means you, or your employer or any other person or entity (if you are entering + into\\nthis Agreement on such person or entity\u2019s behalf), of the age + required under applicable laws, rules or\\nregulations to provide legal consent + and that has legal authority to bind your employer or such other\\nperson + or entity if you are entering in this Agreement on their behalf.\\n\\n\u201CLlama + 3.1\u201D means the foundational large language models and software and algorithms, + including\\nmachine-learning model code, trained model weights, inference-enabling + code, training-enabling code,\\nfine-tuning enabling code and other elements + of the foregoing distributed by Meta at\\nhttps://llama.meta.com/llama-downloads.\\n\\n\u201CLlama + Materials\u201D means, collectively, Meta\u2019s proprietary Llama 3.1 and + Documentation (and any\\nportion thereof) made available under this Agreement.\\n\\n\u201CMeta\u201D + or \u201Cwe\u201D means Meta Platforms Ireland Limited (if you are located + in or, if you are an entity, your\\nprincipal place of business is in the + EEA or Switzerland) and Meta Platforms, Inc. (if you are located\\noutside + of the EEA or Switzerland).\\n\\nBy clicking \u201CI Accept\u201D below or + by using or distributing any portion or element of the Llama Materials,\\nyou + agree to be bound by this Agreement.\\n\\n1. License Rights and Redistribution.\\n\\n + \ a. Grant of Rights. You are granted a non-exclusive, worldwide, non-transferable + and royalty-free\\nlimited license under Meta\u2019s intellectual property + or other rights owned by Meta embodied in the Llama\\nMaterials to use, reproduce, + distribute, copy, create derivative works of, and make modifications to the\\nLlama + Materials.\\n\\n b. Redistribution and Use.\\n\\n i. If you distribute + or make available the Llama Materials (or any derivative works\\nthereof), + or a product or service (including another AI model) that contains any of + them, you shall (A)\\nprovide a copy of this Agreement with any such Llama + Materials; and (B) prominently display \u201CBuilt with\\nLlama\u201D on a + related website, user interface, blogpost, about page, or product documentation. + If you use\\nthe Llama Materials or any outputs or results of the Llama Materials + to create, train, fine tune, or\\notherwise improve an AI model, which is + distributed or made available, you shall also include \u201CLlama\u201D at\\nthe + beginning of any such AI model name.\\n\\n ii. If you receive Llama Materials, + or any derivative works thereof, from a Licensee as part \\nof an integrated + end user product, then Section 2 of this Agreement will not apply to you.\\n\\n + \ iii. You must retain in all copies of the Llama Materials that you distribute + the following\\nattribution notice within a \u201CNotice\u201D text file distributed + as a part of such copies: \u201CLlama 3.1 is\\nlicensed under the Llama 3.1 + Community License, Copyright \xA9 Meta Platforms, Inc. All Rights\\nReserved.\u201D\\n\\n + \ iv. Your use of the Llama Materials must comply with applicable laws + and regulations\\n(including trade compliance laws and regulations) and adhere + to the Acceptable Use Policy for the Llama\\nMaterials (available at https://llama.meta.com/llama3_1/use-policy), + which is hereby incorporated by\\nreference into this Agreement.\\n\\n2. Additional + Commercial Terms. If, on the Llama 3.1 version release date, the monthly active + users\\nof the products or services made available by or for Licensee, or + Licensee\u2019s affiliates, is greater than 700\\nmillion monthly active users + in the preceding calendar month, you must request a license from Meta,\\nwhich + Meta may grant to you in its sole discretion, and you are not authorized to + exercise any of the\\nrights under this Agreement unless or until Meta otherwise + expressly grants you such rights.\\n\\n3. Disclaimer of Warranty. UNLESS REQUIRED + BY APPLICABLE LAW, THE LLAMA MATERIALS AND ANY\\nOUTPUT AND RESULTS THEREFROM + ARE PROVIDED ON AN \u201CAS IS\u201D BASIS, WITHOUT WARRANTIES OF\\nANY KIND, + AND META DISCLAIMS ALL WARRANTIES OF ANY KIND, BOTH EXPRESS AND IMPLIED,\\nINCLUDING, + WITHOUT LIMITATION, ANY WARRANTIES OF TITLE, NON-INFRINGEMENT,\\nMERCHANTABILITY, + OR FITNESS FOR A PARTICULAR PURPOSE. YOU ARE SOLELY RESPONSIBLE FOR\\nDETERMINING + THE APPROPRIATENESS OF USING OR REDISTRIBUTING THE LLAMA MATERIALS AND\\nASSUME + ANY RISKS ASSOCIATED WITH YOUR USE OF THE LLAMA MATERIALS AND ANY OUTPUT AND\\nRESULTS.\\n\\n4. + Limitation of Liability. IN NO EVENT WILL META OR ITS AFFILIATES BE LIABLE + UNDER ANY THEORY OF\\nLIABILITY, WHETHER IN CONTRACT, TORT, NEGLIGENCE, PRODUCTS + LIABILITY, OR OTHERWISE, ARISING\\nOUT OF THIS AGREEMENT, FOR ANY LOST PROFITS + OR ANY INDIRECT, SPECIAL, CONSEQUENTIAL,\\nINCIDENTAL, EXEMPLARY OR PUNITIVE + DAMAGES, EVEN IF META OR ITS AFFILIATES HAVE BEEN ADVISED\\nOF THE POSSIBILITY + OF ANY OF THE FOREGOING.\\n\\n5. Intellectual Property.\\n\\n a. No trademark + licenses are granted under this Agreement, and in connection with the Llama\\nMaterials, + neither Meta nor Licensee may use any name or mark owned by or associated + with the other\\nor any of its affiliates, except as required for reasonable + and customary use in describing and\\nredistributing the Llama Materials or + as set forth in this Section 5(a). Meta hereby grants you a license to\\nuse + \u201CLlama\u201D (the \u201CMark\u201D) solely as required to comply with + the last sentence of Section 1.b.i. You will\\ncomply with Meta\u2019s brand + guidelines (currently accessible at\\nhttps://about.meta.com/brand/resources/meta/company-brand/ + ). All goodwill arising out of your use\\nof the Mark will inure to the benefit + of Meta.\\n\\n b. Subject to Meta\u2019s ownership of Llama Materials and + derivatives made by or for Meta, with\\nrespect to any derivative works and + modifications of the Llama Materials that are made by you, as\\nbetween you + and Meta, you are and will be the owner of such derivative works and modifications.\\n\\n + \ c. If you institute litigation or other proceedings against Meta or any + entity (including a\\ncross-claim or counterclaim in a lawsuit) alleging that + the Llama Materials or Llama 3.1 outputs or\\nresults, or any portion of any + of the foregoing, constitutes infringement of intellectual property or other\\nrights + owned or licensable by you, then any licenses granted to you under this Agreement + shall\\nterminate as of the date such litigation or claim is filed or instituted. + You will indemnify and hold\\nharmless Meta from and against any claim by + any third party arising out of or related to your use or\\ndistribution of + the Llama Materials.\\n\\n6. Term and Termination. The term of this Agreement + will commence upon your acceptance of this\\nAgreement or access to the Llama + Materials and will continue in full force and effect until terminated in\\naccordance + with the terms and conditions herein. Meta may terminate this Agreement if + you are in\\nbreach of any term or condition of this Agreement. Upon termination + of this Agreement, you shall delete\\nand cease use of the Llama Materials. + Sections 3, 4 and 7 shall survive the termination of this\\nAgreement.\\n\\n7. + Governing Law and Jurisdiction. This Agreement will be governed and construed + under the laws of\\nthe State of California without regard to choice of law + principles, and the UN Convention on Contracts\\nfor the International Sale + of Goods does not apply to this Agreement. The courts of California shall + have\\nexclusive jurisdiction of any dispute arising out of this Agreement.\\n\\n# + Llama 3.1 Acceptable Use Policy\\n\\nMeta is committed to promoting safe and + fair use of its tools and features, including Llama 3.1. If you\\naccess or + use Llama 3.1, you agree to this Acceptable Use Policy (\u201CPolicy\u201D). + The most recent copy of\\nthis policy can be found at [https://llama.meta.com/llama3_1/use-policy](https://llama.meta.com/llama3_1/use-policy)\\n\\n## + Prohibited Uses\\n\\nWe want everyone to use Llama 3.1 safely and responsibly. + You agree you will not use, or allow\\nothers to use, Llama 3.1 to:\\n\\n1. + Violate the law or others\u2019 rights, including to:\\n 1. Engage in, + promote, generate, contribute to, encourage, plan, incite, or further illegal + or unlawful activity or content, such as:\\n 1. Violence or terrorism\\n + \ 2. Exploitation or harm to children, including the solicitation, creation, + acquisition, or dissemination of child exploitative content or failure to + report Child Sexual Abuse Material\\n 3. Human trafficking, exploitation, + and sexual violence\\n 4. The illegal distribution of information or + materials to minors, including obscene materials, or failure to employ legally + required age-gating in connection with such information or materials.\\n 5. + Sexual solicitation\\n 6. Any other criminal activity\\n 3. Engage + in, promote, incite, or facilitate the harassment, abuse, threatening, or + bullying of individuals or groups of individuals\\n 4. Engage in, promote, + incite, or facilitate discrimination or other unlawful or harmful conduct + in the provision of employment, employment benefits, credit, housing, other + economic benefits, or other essential goods and services\\n 5. Engage in + the unauthorized or unlicensed practice of any profession including, but not + limited to, financial, legal, medical/health, or related professional practices\\n + \ 6. Collect, process, disclose, generate, or infer health, demographic, + or other sensitive personal or private information about individuals without + rights and consents required by applicable laws\\n 7. Engage in or facilitate + any action or generate any content that infringes, misappropriates, or otherwise + violates any third-party rights, including the outputs or results of any products + or services using the Llama Materials\\n 8. Create, generate, or facilitate + the creation of malicious code, malware, computer viruses or do anything else + that could disable, overburden, interfere with or impair the proper working, + integrity, operation or appearance of a website or computer system\\n\\n2. + Engage in, promote, incite, facilitate, or assist in the planning or development + of activities that present a risk of death or bodily harm to individuals, + including use of Llama 3.1 related to the following:\\n 1. Military, warfare, + nuclear industries or applications, espionage, use for materials or activities + that are subject to the International Traffic Arms Regulations (ITAR) maintained + by the United States Department of State\\n 2. Guns and illegal weapons + (including weapon development)\\n 3. Illegal drugs and regulated/controlled + substances\\n 4. Operation of critical infrastructure, transportation technologies, + or heavy machinery\\n 5. Self-harm or harm to others, including suicide, + cutting, and eating disorders\\n 6. Any content intended to incite or promote + violence, abuse, or any infliction of bodily harm to an individual\\n\\n3. + Intentionally deceive or mislead others, including use of Llama 3.1 related + to the following:\\n 1. Generating, promoting, or furthering fraud or the + creation or promotion of disinformation\\n 2. Generating, promoting, or + furthering defamatory content, including the creation of defamatory statements, + images, or other content\\n 3. Generating, promoting, or further distributing + spam\\n 4. Impersonating another individual without consent, authorization, + or legal right\\n 5. Representing that the use of Llama 3.1 or outputs + are human-generated\\n 6. Generating or facilitating false online engagement, + including fake reviews and other means of fake online engagement\\n\\n4. Fail + to appropriately disclose to end users any known dangers of your AI system\\n\\nPlease + report any violation of this Policy, software \u201Cbug,\u201D or other problems + that could lead to a violation\\nof this Policy through one of the following + means:\\n\\n* Reporting issues with the model: [https://github.com/meta-llama/llama-models/issues](https://github.com/meta-llama/llama-models/issues)\\n* + Reporting risky content generated by the model: developers.facebook.com/llama_output_feedback\\n* + Reporting bugs and security concerns: facebook.com/whitehat/info\\n* Reporting + violations of the Acceptable Use Policy or unlicensed uses of Llama 3.1: LlamaUseReport@meta.com\\n\",\"modelfile\":\"# + Modelfile generated by \\\"ollama show\\\"\\n# To build a new Modelfile based + on this, replace FROM with:\\n# FROM llama3.1:latest\\n\\nFROM /Users/jack/.ollama/models/blobs/sha256-87048bcd55216712ef14c11c2c303728463207b165bf18440b9b84b07ec00f87\\nTEMPLATE + \\\"\\\"\\\"{{ if .Messages }}\\n{{- if or .System .Tools }}\\u003c|start_header_id|\\u003esystem\\u003c|end_header_id|\\u003e\\n{{- + if .System }}\\n\\n{{ .System }}\\n{{- end }}\\n{{- if .Tools }}\\n\\nYou + are a helpful assistant with tool calling capabilities. When you receive a + tool call response, use the output to format an answer to the orginal use + question.\\n{{- end }}\\u003c|eot_id|\\u003e\\n{{- end }}\\n{{- range $i, + $_ := .Messages }}\\n{{- $last := eq (len (slice $.Messages $i)) 1 }}\\n{{- + if eq .Role \\\"user\\\" }}\\u003c|start_header_id|\\u003euser\\u003c|end_header_id|\\u003e\\n{{- + if and $.Tools $last }}\\n\\nGiven the following functions, please respond + with a JSON for a function call with its proper arguments that best answers + the given prompt.\\n\\nRespond in the format {\\\"name\\\": function name, + \\\"parameters\\\": dictionary of argument name and its value}. Do not use + variables.\\n\\n{{ $.Tools }}\\n{{- end }}\\n\\n{{ .Content }}\\u003c|eot_id|\\u003e{{ + if $last }}\\u003c|start_header_id|\\u003eassistant\\u003c|end_header_id|\\u003e\\n\\n{{ + end }}\\n{{- else if eq .Role \\\"assistant\\\" }}\\u003c|start_header_id|\\u003eassistant\\u003c|end_header_id|\\u003e\\n{{- + if .ToolCalls }}\\n\\n{{- range .ToolCalls }}{\\\"name\\\": \\\"{{ .Function.Name + }}\\\", \\\"parameters\\\": {{ .Function.Arguments }}}{{ end }}\\n{{- else + }}\\n\\n{{ .Content }}{{ if not $last }}\\u003c|eot_id|\\u003e{{ end }}\\n{{- + end }}\\n{{- else if eq .Role \\\"tool\\\" }}\\u003c|start_header_id|\\u003eipython\\u003c|end_header_id|\\u003e\\n\\n{{ + .Content }}\\u003c|eot_id|\\u003e{{ if $last }}\\u003c|start_header_id|\\u003eassistant\\u003c|end_header_id|\\u003e\\n\\n{{ + end }}\\n{{- end }}\\n{{- end }}\\n{{- else }}\\n{{- if .System }}\\u003c|start_header_id|\\u003esystem\\u003c|end_header_id|\\u003e\\n\\n{{ + .System }}\\u003c|eot_id|\\u003e{{ end }}{{ if .Prompt }}\\u003c|start_header_id|\\u003euser\\u003c|end_header_id|\\u003e\\n\\n{{ + .Prompt }}\\u003c|eot_id|\\u003e{{ end }}\\u003c|start_header_id|\\u003eassistant\\u003c|end_header_id|\\u003e\\n\\n{{ + end }}{{ .Response }}{{ if .Response }}\\u003c|eot_id|\\u003e{{ end }}\\\"\\\"\\\"\\nPARAMETER + stop \\u003c|start_header_id|\\u003e\\nPARAMETER stop \\u003c|end_header_id|\\u003e\\nPARAMETER + stop \\u003c|eot_id|\\u003e\\nLICENSE \\\"LLAMA 3.1 COMMUNITY LICENSE AGREEMENT\\nLlama + 3.1 Version Release Date: July 23, 2024\\n\\n\u201CAgreement\u201D means the + terms and conditions for use, reproduction, distribution and modification + of the\\nLlama Materials set forth herein.\\n\\n\u201CDocumentation\u201D + means the specifications, manuals and documentation accompanying Llama 3.1\\ndistributed + by Meta at https://llama.meta.com/doc/overview.\\n\\n\u201CLicensee\u201D + or \u201Cyou\u201D means you, or your employer or any other person or entity + (if you are entering into\\nthis Agreement on such person or entity\u2019s + behalf), of the age required under applicable laws, rules or\\nregulations + to provide legal consent and that has legal authority to bind your employer + or such other\\nperson or entity if you are entering in this Agreement on + their behalf.\\n\\n\u201CLlama 3.1\u201D means the foundational large language + models and software and algorithms, including\\nmachine-learning model code, + trained model weights, inference-enabling code, training-enabling code,\\nfine-tuning + enabling code and other elements of the foregoing distributed by Meta at\\nhttps://llama.meta.com/llama-downloads.\\n\\n\u201CLlama + Materials\u201D means, collectively, Meta\u2019s proprietary Llama 3.1 and + Documentation (and any\\nportion thereof) made available under this Agreement.\\n\\n\u201CMeta\u201D + or \u201Cwe\u201D means Meta Platforms Ireland Limited (if you are located + in or, if you are an entity, your\\nprincipal place of business is in the + EEA or Switzerland) and Meta Platforms, Inc. (if you are located\\noutside + of the EEA or Switzerland).\\n\\nBy clicking \u201CI Accept\u201D below or + by using or distributing any portion or element of the Llama Materials,\\nyou + agree to be bound by this Agreement.\\n\\n1. License Rights and Redistribution.\\n\\n + \ a. Grant of Rights. You are granted a non-exclusive, worldwide, non-transferable + and royalty-free\\nlimited license under Meta\u2019s intellectual property + or other rights owned by Meta embodied in the Llama\\nMaterials to use, reproduce, + distribute, copy, create derivative works of, and make modifications to the\\nLlama + Materials.\\n\\n b. Redistribution and Use.\\n\\n i. If you distribute + or make available the Llama Materials (or any derivative works\\nthereof), + or a product or service (including another AI model) that contains any of + them, you shall (A)\\nprovide a copy of this Agreement with any such Llama + Materials; and (B) prominently display \u201CBuilt with\\nLlama\u201D on a + related website, user interface, blogpost, about page, or product documentation. + If you use\\nthe Llama Materials or any outputs or results of the Llama Materials + to create, train, fine tune, or\\notherwise improve an AI model, which is + distributed or made available, you shall also include \u201CLlama\u201D at\\nthe + beginning of any such AI model name.\\n\\n ii. If you receive Llama Materials, + or any derivative works thereof, from a Licensee as part \\nof an integrated + end user product, then Section 2 of this Agreement will not apply to you.\\n\\n + \ iii. You must retain in all copies of the Llama Materials that you distribute + the following\\nattribution notice within a \u201CNotice\u201D text file distributed + as a part of such copies: \u201CLlama 3.1 is\\nlicensed under the Llama 3.1 + Community License, Copyright \xA9 Meta Platforms, Inc. All Rights\\nReserved.\u201D\\n\\n + \ iv. Your use of the Llama Materials must comply with applicable laws + and regulations\\n(including trade compliance laws and regulations) and adhere + to the Acceptable Use Policy for the Llama\\nMaterials (available at https://llama.meta.com/llama3_1/use-policy), + which is hereby incorporated by\\nreference into this Agreement.\\n\\n2. Additional + Commercial Terms. If, on the Llama 3.1 version release date, the monthly active + users\\nof the products or services made available by or for Licensee, or + Licensee\u2019s affiliates, is greater than 700\\nmillion monthly active users + in the preceding calendar month, you must request a license from Meta,\\nwhich + Meta may grant to you in its sole discretion, and you are not authorized to + exercise any of the\\nrights under this Agreement unless or until Meta otherwise + expressly grants you such rights.\\n\\n3. Disclaimer of Warranty. UNLESS REQUIRED + BY APPLICABLE LAW, THE LLAMA MATERIALS AND ANY\\nOUTPUT AND RESULTS THEREFROM + ARE PROVIDED ON AN \u201CAS IS\u201D BASIS, WITHOUT WARRANTIES OF\\nANY KIND, + AND META DISCLAIMS ALL WARRANTIES OF ANY KIND, BOTH EXPRESS AND IMPLIED,\\nINCLUDING, + WITHOUT LIMITATION, ANY WARRANTIES OF TITLE, NON-INFRINGEMENT,\\nMERCHANTABILITY, + OR FITNESS FOR A PARTICULAR PURPOSE. YOU ARE SOLELY RESPONSIBLE FOR\\nDETERMINING + THE APPROPRIATENESS OF USING OR REDISTRIBUTING THE LLAMA MATERIALS AND\\nASSUME + ANY RISKS ASSOCIATED WITH YOUR USE OF THE LLAMA MATERIALS AND ANY OUTPUT AND\\nRESULTS.\\n\\n4. + Limitation of Liability. IN NO EVENT WILL META OR ITS AFFILIATES BE LIABLE + UNDER ANY THEORY OF\\nLIABILITY, WHETHER IN CONTRACT, TORT, NEGLIGENCE, PRODUCTS + LIABILITY, OR OTHERWISE, ARISING\\nOUT OF THIS AGREEMENT, FOR ANY LOST PROFITS + OR ANY INDIRECT, SPECIAL, CONSEQUENTIAL,\\nINCIDENTAL, EXEMPLARY OR PUNITIVE + DAMAGES, EVEN IF META OR ITS AFFILIATES HAVE BEEN ADVISED\\nOF THE POSSIBILITY + OF ANY OF THE FOREGOING.\\n\\n5. Intellectual Property.\\n\\n a. No trademark + licenses are granted under this Agreement, and in connection with the Llama\\nMaterials, + neither Meta nor Licensee may use any name or mark owned by or associated + with the other\\nor any of its affiliates, except as required for reasonable + and customary use in describing and\\nredistributing the Llama Materials or + as set forth in this Section 5(a). Meta hereby grants you a license to\\nuse + \u201CLlama\u201D (the \u201CMark\u201D) solely as required to comply with + the last sentence of Section 1.b.i. You will\\ncomply with Meta\u2019s brand + guidelines (currently accessible at\\nhttps://about.meta.com/brand/resources/meta/company-brand/ + ). All goodwill arising out of your use\\nof the Mark will inure to the benefit + of Meta.\\n\\n b. Subject to Meta\u2019s ownership of Llama Materials and + derivatives made by or for Meta, with\\nrespect to any derivative works and + modifications of the Llama Materials that are made by you, as\\nbetween you + and Meta, you are and will be the owner of such derivative works and modifications.\\n\\n + \ c. If you institute litigation or other proceedings against Meta or any + entity (including a\\ncross-claim or counterclaim in a lawsuit) alleging that + the Llama Materials or Llama 3.1 outputs or\\nresults, or any portion of any + of the foregoing, constitutes infringement of intellectual property or other\\nrights + owned or licensable by you, then any licenses granted to you under this Agreement + shall\\nterminate as of the date such litigation or claim is filed or instituted. + You will indemnify and hold\\nharmless Meta from and against any claim by + any third party arising out of or related to your use or\\ndistribution of + the Llama Materials.\\n\\n6. Term and Termination. The term of this Agreement + will commence upon your acceptance of this\\nAgreement or access to the Llama + Materials and will continue in full force and effect until terminated in\\naccordance + with the terms and conditions herein. Meta may terminate this Agreement if + you are in\\nbreach of any term or condition of this Agreement. Upon termination + of this Agreement, you shall delete\\nand cease use of the Llama Materials. + Sections 3, 4 and 7 shall survive the termination of this\\nAgreement.\\n\\n7. + Governing Law and Jurisdiction. This Agreement will be governed and construed + under the laws of\\nthe State of California without regard to choice of law + principles, and the UN Convention on Contracts\\nfor the International Sale + of Goods does not apply to this Agreement. The courts of California shall + have\\nexclusive jurisdiction of any dispute arising out of this Agreement.\\n\\n# + Llama 3.1 Acceptable Use Policy\\n\\nMeta is committed to promoting safe and + fair use of its tools and features, including Llama 3.1. If you\\naccess or + use Llama 3.1, you agree to this Acceptable Use Policy (\u201CPolicy\u201D). + The most recent copy of\\nthis policy can be found at [https://llama.meta.com/llama3_1/use-policy](https://llama.meta.com/llama3_1/use-policy)\\n\\n## + Prohibited Uses\\n\\nWe want everyone to use Llama 3.1 safely and responsibly. + You agree you will not use, or allow\\nothers to use, Llama 3.1 to:\\n\\n1. + Violate the law or others\u2019 rights, including to:\\n 1. Engage in, + promote, generate, contribute to, encourage, plan, incite, or further illegal + or unlawful activity or content, such as:\\n 1. Violence or terrorism\\n + \ 2. Exploitation or harm to children, including the solicitation, creation, + acquisition, or dissemination of child exploitative content or failure to + report Child Sexual Abuse Material\\n 3. Human trafficking, exploitation, + and sexual violence\\n 4. The illegal distribution of information or + materials to minors, including obscene materials, or failure to employ legally + required age-gating in connection with such information or materials.\\n 5. + Sexual solicitation\\n 6. Any other criminal activity\\n 3. Engage + in, promote, incite, or facilitate the harassment, abuse, threatening, or + bullying of individuals or groups of individuals\\n 4. Engage in, promote, + incite, or facilitate discrimination or other unlawful or harmful conduct + in the provision of employment, employment benefits, credit, housing, other + economic benefits, or other essential goods and services\\n 5. Engage in + the unauthorized or unlicensed practice of any profession including, but not + limited to, financial, legal, medical/health, or related professional practices\\n + \ 6. Collect, process, disclose, generate, or infer health, demographic, + or other sensitive personal or private information about individuals without + rights and consents required by applicable laws\\n 7. Engage in or facilitate + any action or generate any content that infringes, misappropriates, or otherwise + violates any third-party rights, including the outputs or results of any products + or services using the Llama Materials\\n 8. Create, generate, or facilitate + the creation of malicious code, malware, computer viruses or do anything else + that could disable, overburden, interfere with or impair the proper working, + integrity, operation or appearance of a website or computer system\\n\\n2. + Engage in, promote, incite, facilitate, or assist in the planning or development + of activities that present a risk of death or bodily harm to individuals, + including use of Llama 3.1 related to the following:\\n 1. Military, warfare, + nuclear industries or applications, espionage, use for materials or activities + that are subject to the International Traffic Arms Regulations (ITAR) maintained + by the United States Department of State\\n 2. Guns and illegal weapons + (including weapon development)\\n 3. Illegal drugs and regulated/controlled + substances\\n 4. Operation of critical infrastructure, transportation technologies, + or heavy machinery\\n 5. Self-harm or harm to others, including suicide, + cutting, and eating disorders\\n 6. Any content intended to incite or promote + violence, abuse, or any infliction of bodily harm to an individual\\n\\n3. + Intentionally deceive or mislead others, including use of Llama 3.1 related + to the following:\\n 1. Generating, promoting, or furthering fraud or the + creation or promotion of disinformation\\n 2. Generating, promoting, or + furthering defamatory content, including the creation of defamatory statements, + images, or other content\\n 3. Generating, promoting, or further distributing + spam\\n 4. Impersonating another individual without consent, authorization, + or legal right\\n 5. Representing that the use of Llama 3.1 or outputs + are human-generated\\n 6. Generating or facilitating false online engagement, + including fake reviews and other means of fake online engagement\\n\\n4. Fail + to appropriately disclose to end users any known dangers of your AI system\\n\\nPlease + report any violation of this Policy, software \u201Cbug,\u201D or other problems + that could lead to a violation\\nof this Policy through one of the following + means:\\n\\n* Reporting issues with the model: [https://github.com/meta-llama/llama-models/issues](https://github.com/meta-llama/llama-models/issues)\\n* + Reporting risky content generated by the model: developers.facebook.com/llama_output_feedback\\n* + Reporting bugs and security concerns: facebook.com/whitehat/info\\n* Reporting + violations of the Acceptable Use Policy or unlicensed uses of Llama 3.1: LlamaUseReport@meta.com\\n\\\"\\n\",\"parameters\":\"stop + \ \\\"\\u003c|start_header_id|\\u003e\\\"\\nstop + \ \\\"\\u003c|end_header_id|\\u003e\\\"\\nstop \\\"\\u003c|eot_id|\\u003e\\\"\",\"template\":\"{{ + if .Messages }}\\n{{- if or .System .Tools }}\\u003c|start_header_id|\\u003esystem\\u003c|end_header_id|\\u003e\\n{{- + if .System }}\\n\\n{{ .System }}\\n{{- end }}\\n{{- if .Tools }}\\n\\nYou + are a helpful assistant with tool calling capabilities. When you receive a + tool call response, use the output to format an answer to the orginal use + question.\\n{{- end }}\\u003c|eot_id|\\u003e\\n{{- end }}\\n{{- range $i, + $_ := .Messages }}\\n{{- $last := eq (len (slice $.Messages $i)) 1 }}\\n{{- + if eq .Role \\\"user\\\" }}\\u003c|start_header_id|\\u003euser\\u003c|end_header_id|\\u003e\\n{{- + if and $.Tools $last }}\\n\\nGiven the following functions, please respond + with a JSON for a function call with its proper arguments that best answers + the given prompt.\\n\\nRespond in the format {\\\"name\\\": function name, + \\\"parameters\\\": dictionary of argument name and its value}. Do not use + variables.\\n\\n{{ $.Tools }}\\n{{- end }}\\n\\n{{ .Content }}\\u003c|eot_id|\\u003e{{ + if $last }}\\u003c|start_header_id|\\u003eassistant\\u003c|end_header_id|\\u003e\\n\\n{{ + end }}\\n{{- else if eq .Role \\\"assistant\\\" }}\\u003c|start_header_id|\\u003eassistant\\u003c|end_header_id|\\u003e\\n{{- + if .ToolCalls }}\\n\\n{{- range .ToolCalls }}{\\\"name\\\": \\\"{{ .Function.Name + }}\\\", \\\"parameters\\\": {{ .Function.Arguments }}}{{ end }}\\n{{- else + }}\\n\\n{{ .Content }}{{ if not $last }}\\u003c|eot_id|\\u003e{{ end }}\\n{{- + end }}\\n{{- else if eq .Role \\\"tool\\\" }}\\u003c|start_header_id|\\u003eipython\\u003c|end_header_id|\\u003e\\n\\n{{ + .Content }}\\u003c|eot_id|\\u003e{{ if $last }}\\u003c|start_header_id|\\u003eassistant\\u003c|end_header_id|\\u003e\\n\\n{{ + end }}\\n{{- end }}\\n{{- end }}\\n{{- else }}\\n{{- if .System }}\\u003c|start_header_id|\\u003esystem\\u003c|end_header_id|\\u003e\\n\\n{{ + .System }}\\u003c|eot_id|\\u003e{{ end }}{{ if .Prompt }}\\u003c|start_header_id|\\u003euser\\u003c|end_header_id|\\u003e\\n\\n{{ + .Prompt }}\\u003c|eot_id|\\u003e{{ end }}\\u003c|start_header_id|\\u003eassistant\\u003c|end_header_id|\\u003e\\n\\n{{ + end }}{{ .Response }}{{ if .Response }}\\u003c|eot_id|\\u003e{{ end }}\",\"details\":{\"parent_model\":\"\",\"format\":\"gguf\",\"family\":\"llama\",\"families\":[\"llama\"],\"parameter_size\":\"8.0B\",\"quantization_level\":\"Q4_0\"},\"model_info\":{\"general.architecture\":\"llama\",\"general.basename\":\"Meta-Llama-3.1\",\"general.file_type\":2,\"general.finetune\":\"Instruct\",\"general.languages\":[\"en\",\"de\",\"fr\",\"it\",\"pt\",\"hi\",\"es\",\"th\"],\"general.license\":\"llama3.1\",\"general.parameter_count\":8030261248,\"general.quantization_version\":2,\"general.size_label\":\"8B\",\"general.tags\":[\"facebook\",\"meta\",\"pytorch\",\"llama\",\"llama-3\",\"text-generation\"],\"general.type\":\"model\",\"llama.attention.head_count\":32,\"llama.attention.head_count_kv\":8,\"llama.attention.layer_norm_rms_epsilon\":0.00001,\"llama.block_count\":32,\"llama.context_length\":131072,\"llama.embedding_length\":4096,\"llama.feed_forward_length\":14336,\"llama.rope.dimension_count\":128,\"llama.rope.freq_base\":500000,\"llama.vocab_size\":128256,\"tokenizer.ggml.bos_token_id\":128000,\"tokenizer.ggml.eos_token_id\":128009,\"tokenizer.ggml.merges\":null,\"tokenizer.ggml.model\":\"gpt2\",\"tokenizer.ggml.pre\":\"llama-bpe\",\"tokenizer.ggml.token_type\":null,\"tokenizer.ggml.tokens\":null},\"modified_at\":\"2024-07-28T16:34:12.391102099-07:00\"}" + headers: + Content-Type: + - application/json; charset=utf-8 + Date: + - Sun, 17 Nov 2024 08:42:00 GMT + Transfer-Encoding: + - chunked + status: + code: 200 + message: OK +- request: + body: '{"model": "llama3.1", "messages": [{"role": "user", "content": "Say hello!"}], + "options": {}, "stream": true}' + headers: + accept: + - '*/*' + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '109' + content-type: + - application/json + host: + - localhost:11434 + user-agent: + - python-httpx/0.27.2 + method: POST + uri: http://localhost:11434/api/chat + response: + body: + string: '{"model":"llama3.1","created_at":"2024-11-17T08:42:00.390484Z","message":{"role":"assistant","content":"Hello"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:42:00.473218Z","message":{"role":"assistant","content":"!"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:42:00.55595Z","message":{"role":"assistant","content":" + How"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:42:00.643264Z","message":{"role":"assistant","content":" + can"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:42:00.737483Z","message":{"role":"assistant","content":" + I"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:42:00.836942Z","message":{"role":"assistant","content":" + assist"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:42:00.943158Z","message":{"role":"assistant","content":" + you"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:42:01.056013Z","message":{"role":"assistant","content":" + today"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:42:01.172659Z","message":{"role":"assistant","content":"?"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:42:01.289772Z","message":{"role":"assistant","content":""},"done_reason":"stop","done":true,"total_duration":1006884459,"load_duration":22981209,"prompt_eval_count":13,"prompt_eval_duration":80000000,"eval_count":10,"eval_duration":902000000} + + ' + headers: + Content-Type: + - application/x-ndjson + Date: + - Sun, 17 Nov 2024 08:42:00 GMT + Transfer-Encoding: + - chunked + status: + code: 200 + message: OK +- request: + body: '{"name": "llama3.1"}' + headers: + accept: + - '*/*' + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '20' + content-type: + - application/json + host: + - localhost:11434 + user-agent: + - litellm/1.52.6 + method: POST + uri: http://localhost:11434/api/show + response: + body: + string: "{\"license\":\"LLAMA 3.1 COMMUNITY LICENSE AGREEMENT\\nLlama 3.1 Version + Release Date: July 23, 2024\\n\\n\u201CAgreement\u201D means the terms and + conditions for use, reproduction, distribution and modification of the\\nLlama + Materials set forth herein.\\n\\n\u201CDocumentation\u201D means the specifications, + manuals and documentation accompanying Llama 3.1\\ndistributed by Meta at + https://llama.meta.com/doc/overview.\\n\\n\u201CLicensee\u201D or \u201Cyou\u201D + means you, or your employer or any other person or entity (if you are entering + into\\nthis Agreement on such person or entity\u2019s behalf), of the age + required under applicable laws, rules or\\nregulations to provide legal consent + and that has legal authority to bind your employer or such other\\nperson + or entity if you are entering in this Agreement on their behalf.\\n\\n\u201CLlama + 3.1\u201D means the foundational large language models and software and algorithms, + including\\nmachine-learning model code, trained model weights, inference-enabling + code, training-enabling code,\\nfine-tuning enabling code and other elements + of the foregoing distributed by Meta at\\nhttps://llama.meta.com/llama-downloads.\\n\\n\u201CLlama + Materials\u201D means, collectively, Meta\u2019s proprietary Llama 3.1 and + Documentation (and any\\nportion thereof) made available under this Agreement.\\n\\n\u201CMeta\u201D + or \u201Cwe\u201D means Meta Platforms Ireland Limited (if you are located + in or, if you are an entity, your\\nprincipal place of business is in the + EEA or Switzerland) and Meta Platforms, Inc. (if you are located\\noutside + of the EEA or Switzerland).\\n\\nBy clicking \u201CI Accept\u201D below or + by using or distributing any portion or element of the Llama Materials,\\nyou + agree to be bound by this Agreement.\\n\\n1. License Rights and Redistribution.\\n\\n + \ a. Grant of Rights. You are granted a non-exclusive, worldwide, non-transferable + and royalty-free\\nlimited license under Meta\u2019s intellectual property + or other rights owned by Meta embodied in the Llama\\nMaterials to use, reproduce, + distribute, copy, create derivative works of, and make modifications to the\\nLlama + Materials.\\n\\n b. Redistribution and Use.\\n\\n i. If you distribute + or make available the Llama Materials (or any derivative works\\nthereof), + or a product or service (including another AI model) that contains any of + them, you shall (A)\\nprovide a copy of this Agreement with any such Llama + Materials; and (B) prominently display \u201CBuilt with\\nLlama\u201D on a + related website, user interface, blogpost, about page, or product documentation. + If you use\\nthe Llama Materials or any outputs or results of the Llama Materials + to create, train, fine tune, or\\notherwise improve an AI model, which is + distributed or made available, you shall also include \u201CLlama\u201D at\\nthe + beginning of any such AI model name.\\n\\n ii. If you receive Llama Materials, + or any derivative works thereof, from a Licensee as part \\nof an integrated + end user product, then Section 2 of this Agreement will not apply to you.\\n\\n + \ iii. You must retain in all copies of the Llama Materials that you distribute + the following\\nattribution notice within a \u201CNotice\u201D text file distributed + as a part of such copies: \u201CLlama 3.1 is\\nlicensed under the Llama 3.1 + Community License, Copyright \xA9 Meta Platforms, Inc. All Rights\\nReserved.\u201D\\n\\n + \ iv. Your use of the Llama Materials must comply with applicable laws + and regulations\\n(including trade compliance laws and regulations) and adhere + to the Acceptable Use Policy for the Llama\\nMaterials (available at https://llama.meta.com/llama3_1/use-policy), + which is hereby incorporated by\\nreference into this Agreement.\\n\\n2. Additional + Commercial Terms. If, on the Llama 3.1 version release date, the monthly active + users\\nof the products or services made available by or for Licensee, or + Licensee\u2019s affiliates, is greater than 700\\nmillion monthly active users + in the preceding calendar month, you must request a license from Meta,\\nwhich + Meta may grant to you in its sole discretion, and you are not authorized to + exercise any of the\\nrights under this Agreement unless or until Meta otherwise + expressly grants you such rights.\\n\\n3. Disclaimer of Warranty. UNLESS REQUIRED + BY APPLICABLE LAW, THE LLAMA MATERIALS AND ANY\\nOUTPUT AND RESULTS THEREFROM + ARE PROVIDED ON AN \u201CAS IS\u201D BASIS, WITHOUT WARRANTIES OF\\nANY KIND, + AND META DISCLAIMS ALL WARRANTIES OF ANY KIND, BOTH EXPRESS AND IMPLIED,\\nINCLUDING, + WITHOUT LIMITATION, ANY WARRANTIES OF TITLE, NON-INFRINGEMENT,\\nMERCHANTABILITY, + OR FITNESS FOR A PARTICULAR PURPOSE. YOU ARE SOLELY RESPONSIBLE FOR\\nDETERMINING + THE APPROPRIATENESS OF USING OR REDISTRIBUTING THE LLAMA MATERIALS AND\\nASSUME + ANY RISKS ASSOCIATED WITH YOUR USE OF THE LLAMA MATERIALS AND ANY OUTPUT AND\\nRESULTS.\\n\\n4. + Limitation of Liability. IN NO EVENT WILL META OR ITS AFFILIATES BE LIABLE + UNDER ANY THEORY OF\\nLIABILITY, WHETHER IN CONTRACT, TORT, NEGLIGENCE, PRODUCTS + LIABILITY, OR OTHERWISE, ARISING\\nOUT OF THIS AGREEMENT, FOR ANY LOST PROFITS + OR ANY INDIRECT, SPECIAL, CONSEQUENTIAL,\\nINCIDENTAL, EXEMPLARY OR PUNITIVE + DAMAGES, EVEN IF META OR ITS AFFILIATES HAVE BEEN ADVISED\\nOF THE POSSIBILITY + OF ANY OF THE FOREGOING.\\n\\n5. Intellectual Property.\\n\\n a. No trademark + licenses are granted under this Agreement, and in connection with the Llama\\nMaterials, + neither Meta nor Licensee may use any name or mark owned by or associated + with the other\\nor any of its affiliates, except as required for reasonable + and customary use in describing and\\nredistributing the Llama Materials or + as set forth in this Section 5(a). Meta hereby grants you a license to\\nuse + \u201CLlama\u201D (the \u201CMark\u201D) solely as required to comply with + the last sentence of Section 1.b.i. You will\\ncomply with Meta\u2019s brand + guidelines (currently accessible at\\nhttps://about.meta.com/brand/resources/meta/company-brand/ + ). All goodwill arising out of your use\\nof the Mark will inure to the benefit + of Meta.\\n\\n b. Subject to Meta\u2019s ownership of Llama Materials and + derivatives made by or for Meta, with\\nrespect to any derivative works and + modifications of the Llama Materials that are made by you, as\\nbetween you + and Meta, you are and will be the owner of such derivative works and modifications.\\n\\n + \ c. If you institute litigation or other proceedings against Meta or any + entity (including a\\ncross-claim or counterclaim in a lawsuit) alleging that + the Llama Materials or Llama 3.1 outputs or\\nresults, or any portion of any + of the foregoing, constitutes infringement of intellectual property or other\\nrights + owned or licensable by you, then any licenses granted to you under this Agreement + shall\\nterminate as of the date such litigation or claim is filed or instituted. + You will indemnify and hold\\nharmless Meta from and against any claim by + any third party arising out of or related to your use or\\ndistribution of + the Llama Materials.\\n\\n6. Term and Termination. The term of this Agreement + will commence upon your acceptance of this\\nAgreement or access to the Llama + Materials and will continue in full force and effect until terminated in\\naccordance + with the terms and conditions herein. Meta may terminate this Agreement if + you are in\\nbreach of any term or condition of this Agreement. Upon termination + of this Agreement, you shall delete\\nand cease use of the Llama Materials. + Sections 3, 4 and 7 shall survive the termination of this\\nAgreement.\\n\\n7. + Governing Law and Jurisdiction. This Agreement will be governed and construed + under the laws of\\nthe State of California without regard to choice of law + principles, and the UN Convention on Contracts\\nfor the International Sale + of Goods does not apply to this Agreement. The courts of California shall + have\\nexclusive jurisdiction of any dispute arising out of this Agreement.\\n\\n# + Llama 3.1 Acceptable Use Policy\\n\\nMeta is committed to promoting safe and + fair use of its tools and features, including Llama 3.1. If you\\naccess or + use Llama 3.1, you agree to this Acceptable Use Policy (\u201CPolicy\u201D). + The most recent copy of\\nthis policy can be found at [https://llama.meta.com/llama3_1/use-policy](https://llama.meta.com/llama3_1/use-policy)\\n\\n## + Prohibited Uses\\n\\nWe want everyone to use Llama 3.1 safely and responsibly. + You agree you will not use, or allow\\nothers to use, Llama 3.1 to:\\n\\n1. + Violate the law or others\u2019 rights, including to:\\n 1. Engage in, + promote, generate, contribute to, encourage, plan, incite, or further illegal + or unlawful activity or content, such as:\\n 1. Violence or terrorism\\n + \ 2. Exploitation or harm to children, including the solicitation, creation, + acquisition, or dissemination of child exploitative content or failure to + report Child Sexual Abuse Material\\n 3. Human trafficking, exploitation, + and sexual violence\\n 4. The illegal distribution of information or + materials to minors, including obscene materials, or failure to employ legally + required age-gating in connection with such information or materials.\\n 5. + Sexual solicitation\\n 6. Any other criminal activity\\n 3. Engage + in, promote, incite, or facilitate the harassment, abuse, threatening, or + bullying of individuals or groups of individuals\\n 4. Engage in, promote, + incite, or facilitate discrimination or other unlawful or harmful conduct + in the provision of employment, employment benefits, credit, housing, other + economic benefits, or other essential goods and services\\n 5. Engage in + the unauthorized or unlicensed practice of any profession including, but not + limited to, financial, legal, medical/health, or related professional practices\\n + \ 6. Collect, process, disclose, generate, or infer health, demographic, + or other sensitive personal or private information about individuals without + rights and consents required by applicable laws\\n 7. Engage in or facilitate + any action or generate any content that infringes, misappropriates, or otherwise + violates any third-party rights, including the outputs or results of any products + or services using the Llama Materials\\n 8. Create, generate, or facilitate + the creation of malicious code, malware, computer viruses or do anything else + that could disable, overburden, interfere with or impair the proper working, + integrity, operation or appearance of a website or computer system\\n\\n2. + Engage in, promote, incite, facilitate, or assist in the planning or development + of activities that present a risk of death or bodily harm to individuals, + including use of Llama 3.1 related to the following:\\n 1. Military, warfare, + nuclear industries or applications, espionage, use for materials or activities + that are subject to the International Traffic Arms Regulations (ITAR) maintained + by the United States Department of State\\n 2. Guns and illegal weapons + (including weapon development)\\n 3. Illegal drugs and regulated/controlled + substances\\n 4. Operation of critical infrastructure, transportation technologies, + or heavy machinery\\n 5. Self-harm or harm to others, including suicide, + cutting, and eating disorders\\n 6. Any content intended to incite or promote + violence, abuse, or any infliction of bodily harm to an individual\\n\\n3. + Intentionally deceive or mislead others, including use of Llama 3.1 related + to the following:\\n 1. Generating, promoting, or furthering fraud or the + creation or promotion of disinformation\\n 2. Generating, promoting, or + furthering defamatory content, including the creation of defamatory statements, + images, or other content\\n 3. Generating, promoting, or further distributing + spam\\n 4. Impersonating another individual without consent, authorization, + or legal right\\n 5. Representing that the use of Llama 3.1 or outputs + are human-generated\\n 6. Generating or facilitating false online engagement, + including fake reviews and other means of fake online engagement\\n\\n4. Fail + to appropriately disclose to end users any known dangers of your AI system\\n\\nPlease + report any violation of this Policy, software \u201Cbug,\u201D or other problems + that could lead to a violation\\nof this Policy through one of the following + means:\\n\\n* Reporting issues with the model: [https://github.com/meta-llama/llama-models/issues](https://github.com/meta-llama/llama-models/issues)\\n* + Reporting risky content generated by the model: developers.facebook.com/llama_output_feedback\\n* + Reporting bugs and security concerns: facebook.com/whitehat/info\\n* Reporting + violations of the Acceptable Use Policy or unlicensed uses of Llama 3.1: LlamaUseReport@meta.com\\n\",\"modelfile\":\"# + Modelfile generated by \\\"ollama show\\\"\\n# To build a new Modelfile based + on this, replace FROM with:\\n# FROM llama3.1:latest\\n\\nFROM /Users/jack/.ollama/models/blobs/sha256-87048bcd55216712ef14c11c2c303728463207b165bf18440b9b84b07ec00f87\\nTEMPLATE + \\\"\\\"\\\"{{ if .Messages }}\\n{{- if or .System .Tools }}\\u003c|start_header_id|\\u003esystem\\u003c|end_header_id|\\u003e\\n{{- + if .System }}\\n\\n{{ .System }}\\n{{- end }}\\n{{- if .Tools }}\\n\\nYou + are a helpful assistant with tool calling capabilities. When you receive a + tool call response, use the output to format an answer to the orginal use + question.\\n{{- end }}\\u003c|eot_id|\\u003e\\n{{- end }}\\n{{- range $i, + $_ := .Messages }}\\n{{- $last := eq (len (slice $.Messages $i)) 1 }}\\n{{- + if eq .Role \\\"user\\\" }}\\u003c|start_header_id|\\u003euser\\u003c|end_header_id|\\u003e\\n{{- + if and $.Tools $last }}\\n\\nGiven the following functions, please respond + with a JSON for a function call with its proper arguments that best answers + the given prompt.\\n\\nRespond in the format {\\\"name\\\": function name, + \\\"parameters\\\": dictionary of argument name and its value}. Do not use + variables.\\n\\n{{ $.Tools }}\\n{{- end }}\\n\\n{{ .Content }}\\u003c|eot_id|\\u003e{{ + if $last }}\\u003c|start_header_id|\\u003eassistant\\u003c|end_header_id|\\u003e\\n\\n{{ + end }}\\n{{- else if eq .Role \\\"assistant\\\" }}\\u003c|start_header_id|\\u003eassistant\\u003c|end_header_id|\\u003e\\n{{- + if .ToolCalls }}\\n\\n{{- range .ToolCalls }}{\\\"name\\\": \\\"{{ .Function.Name + }}\\\", \\\"parameters\\\": {{ .Function.Arguments }}}{{ end }}\\n{{- else + }}\\n\\n{{ .Content }}{{ if not $last }}\\u003c|eot_id|\\u003e{{ end }}\\n{{- + end }}\\n{{- else if eq .Role \\\"tool\\\" }}\\u003c|start_header_id|\\u003eipython\\u003c|end_header_id|\\u003e\\n\\n{{ + .Content }}\\u003c|eot_id|\\u003e{{ if $last }}\\u003c|start_header_id|\\u003eassistant\\u003c|end_header_id|\\u003e\\n\\n{{ + end }}\\n{{- end }}\\n{{- end }}\\n{{- else }}\\n{{- if .System }}\\u003c|start_header_id|\\u003esystem\\u003c|end_header_id|\\u003e\\n\\n{{ + .System }}\\u003c|eot_id|\\u003e{{ end }}{{ if .Prompt }}\\u003c|start_header_id|\\u003euser\\u003c|end_header_id|\\u003e\\n\\n{{ + .Prompt }}\\u003c|eot_id|\\u003e{{ end }}\\u003c|start_header_id|\\u003eassistant\\u003c|end_header_id|\\u003e\\n\\n{{ + end }}{{ .Response }}{{ if .Response }}\\u003c|eot_id|\\u003e{{ end }}\\\"\\\"\\\"\\nPARAMETER + stop \\u003c|start_header_id|\\u003e\\nPARAMETER stop \\u003c|end_header_id|\\u003e\\nPARAMETER + stop \\u003c|eot_id|\\u003e\\nLICENSE \\\"LLAMA 3.1 COMMUNITY LICENSE AGREEMENT\\nLlama + 3.1 Version Release Date: July 23, 2024\\n\\n\u201CAgreement\u201D means the + terms and conditions for use, reproduction, distribution and modification + of the\\nLlama Materials set forth herein.\\n\\n\u201CDocumentation\u201D + means the specifications, manuals and documentation accompanying Llama 3.1\\ndistributed + by Meta at https://llama.meta.com/doc/overview.\\n\\n\u201CLicensee\u201D + or \u201Cyou\u201D means you, or your employer or any other person or entity + (if you are entering into\\nthis Agreement on such person or entity\u2019s + behalf), of the age required under applicable laws, rules or\\nregulations + to provide legal consent and that has legal authority to bind your employer + or such other\\nperson or entity if you are entering in this Agreement on + their behalf.\\n\\n\u201CLlama 3.1\u201D means the foundational large language + models and software and algorithms, including\\nmachine-learning model code, + trained model weights, inference-enabling code, training-enabling code,\\nfine-tuning + enabling code and other elements of the foregoing distributed by Meta at\\nhttps://llama.meta.com/llama-downloads.\\n\\n\u201CLlama + Materials\u201D means, collectively, Meta\u2019s proprietary Llama 3.1 and + Documentation (and any\\nportion thereof) made available under this Agreement.\\n\\n\u201CMeta\u201D + or \u201Cwe\u201D means Meta Platforms Ireland Limited (if you are located + in or, if you are an entity, your\\nprincipal place of business is in the + EEA or Switzerland) and Meta Platforms, Inc. (if you are located\\noutside + of the EEA or Switzerland).\\n\\nBy clicking \u201CI Accept\u201D below or + by using or distributing any portion or element of the Llama Materials,\\nyou + agree to be bound by this Agreement.\\n\\n1. License Rights and Redistribution.\\n\\n + \ a. Grant of Rights. You are granted a non-exclusive, worldwide, non-transferable + and royalty-free\\nlimited license under Meta\u2019s intellectual property + or other rights owned by Meta embodied in the Llama\\nMaterials to use, reproduce, + distribute, copy, create derivative works of, and make modifications to the\\nLlama + Materials.\\n\\n b. Redistribution and Use.\\n\\n i. If you distribute + or make available the Llama Materials (or any derivative works\\nthereof), + or a product or service (including another AI model) that contains any of + them, you shall (A)\\nprovide a copy of this Agreement with any such Llama + Materials; and (B) prominently display \u201CBuilt with\\nLlama\u201D on a + related website, user interface, blogpost, about page, or product documentation. + If you use\\nthe Llama Materials or any outputs or results of the Llama Materials + to create, train, fine tune, or\\notherwise improve an AI model, which is + distributed or made available, you shall also include \u201CLlama\u201D at\\nthe + beginning of any such AI model name.\\n\\n ii. If you receive Llama Materials, + or any derivative works thereof, from a Licensee as part \\nof an integrated + end user product, then Section 2 of this Agreement will not apply to you.\\n\\n + \ iii. You must retain in all copies of the Llama Materials that you distribute + the following\\nattribution notice within a \u201CNotice\u201D text file distributed + as a part of such copies: \u201CLlama 3.1 is\\nlicensed under the Llama 3.1 + Community License, Copyright \xA9 Meta Platforms, Inc. All Rights\\nReserved.\u201D\\n\\n + \ iv. Your use of the Llama Materials must comply with applicable laws + and regulations\\n(including trade compliance laws and regulations) and adhere + to the Acceptable Use Policy for the Llama\\nMaterials (available at https://llama.meta.com/llama3_1/use-policy), + which is hereby incorporated by\\nreference into this Agreement.\\n\\n2. Additional + Commercial Terms. If, on the Llama 3.1 version release date, the monthly active + users\\nof the products or services made available by or for Licensee, or + Licensee\u2019s affiliates, is greater than 700\\nmillion monthly active users + in the preceding calendar month, you must request a license from Meta,\\nwhich + Meta may grant to you in its sole discretion, and you are not authorized to + exercise any of the\\nrights under this Agreement unless or until Meta otherwise + expressly grants you such rights.\\n\\n3. Disclaimer of Warranty. UNLESS REQUIRED + BY APPLICABLE LAW, THE LLAMA MATERIALS AND ANY\\nOUTPUT AND RESULTS THEREFROM + ARE PROVIDED ON AN \u201CAS IS\u201D BASIS, WITHOUT WARRANTIES OF\\nANY KIND, + AND META DISCLAIMS ALL WARRANTIES OF ANY KIND, BOTH EXPRESS AND IMPLIED,\\nINCLUDING, + WITHOUT LIMITATION, ANY WARRANTIES OF TITLE, NON-INFRINGEMENT,\\nMERCHANTABILITY, + OR FITNESS FOR A PARTICULAR PURPOSE. YOU ARE SOLELY RESPONSIBLE FOR\\nDETERMINING + THE APPROPRIATENESS OF USING OR REDISTRIBUTING THE LLAMA MATERIALS AND\\nASSUME + ANY RISKS ASSOCIATED WITH YOUR USE OF THE LLAMA MATERIALS AND ANY OUTPUT AND\\nRESULTS.\\n\\n4. + Limitation of Liability. IN NO EVENT WILL META OR ITS AFFILIATES BE LIABLE + UNDER ANY THEORY OF\\nLIABILITY, WHETHER IN CONTRACT, TORT, NEGLIGENCE, PRODUCTS + LIABILITY, OR OTHERWISE, ARISING\\nOUT OF THIS AGREEMENT, FOR ANY LOST PROFITS + OR ANY INDIRECT, SPECIAL, CONSEQUENTIAL,\\nINCIDENTAL, EXEMPLARY OR PUNITIVE + DAMAGES, EVEN IF META OR ITS AFFILIATES HAVE BEEN ADVISED\\nOF THE POSSIBILITY + OF ANY OF THE FOREGOING.\\n\\n5. Intellectual Property.\\n\\n a. No trademark + licenses are granted under this Agreement, and in connection with the Llama\\nMaterials, + neither Meta nor Licensee may use any name or mark owned by or associated + with the other\\nor any of its affiliates, except as required for reasonable + and customary use in describing and\\nredistributing the Llama Materials or + as set forth in this Section 5(a). Meta hereby grants you a license to\\nuse + \u201CLlama\u201D (the \u201CMark\u201D) solely as required to comply with + the last sentence of Section 1.b.i. You will\\ncomply with Meta\u2019s brand + guidelines (currently accessible at\\nhttps://about.meta.com/brand/resources/meta/company-brand/ + ). All goodwill arising out of your use\\nof the Mark will inure to the benefit + of Meta.\\n\\n b. Subject to Meta\u2019s ownership of Llama Materials and + derivatives made by or for Meta, with\\nrespect to any derivative works and + modifications of the Llama Materials that are made by you, as\\nbetween you + and Meta, you are and will be the owner of such derivative works and modifications.\\n\\n + \ c. If you institute litigation or other proceedings against Meta or any + entity (including a\\ncross-claim or counterclaim in a lawsuit) alleging that + the Llama Materials or Llama 3.1 outputs or\\nresults, or any portion of any + of the foregoing, constitutes infringement of intellectual property or other\\nrights + owned or licensable by you, then any licenses granted to you under this Agreement + shall\\nterminate as of the date such litigation or claim is filed or instituted. + You will indemnify and hold\\nharmless Meta from and against any claim by + any third party arising out of or related to your use or\\ndistribution of + the Llama Materials.\\n\\n6. Term and Termination. The term of this Agreement + will commence upon your acceptance of this\\nAgreement or access to the Llama + Materials and will continue in full force and effect until terminated in\\naccordance + with the terms and conditions herein. Meta may terminate this Agreement if + you are in\\nbreach of any term or condition of this Agreement. Upon termination + of this Agreement, you shall delete\\nand cease use of the Llama Materials. + Sections 3, 4 and 7 shall survive the termination of this\\nAgreement.\\n\\n7. + Governing Law and Jurisdiction. This Agreement will be governed and construed + under the laws of\\nthe State of California without regard to choice of law + principles, and the UN Convention on Contracts\\nfor the International Sale + of Goods does not apply to this Agreement. The courts of California shall + have\\nexclusive jurisdiction of any dispute arising out of this Agreement.\\n\\n# + Llama 3.1 Acceptable Use Policy\\n\\nMeta is committed to promoting safe and + fair use of its tools and features, including Llama 3.1. If you\\naccess or + use Llama 3.1, you agree to this Acceptable Use Policy (\u201CPolicy\u201D). + The most recent copy of\\nthis policy can be found at [https://llama.meta.com/llama3_1/use-policy](https://llama.meta.com/llama3_1/use-policy)\\n\\n## + Prohibited Uses\\n\\nWe want everyone to use Llama 3.1 safely and responsibly. + You agree you will not use, or allow\\nothers to use, Llama 3.1 to:\\n\\n1. + Violate the law or others\u2019 rights, including to:\\n 1. Engage in, + promote, generate, contribute to, encourage, plan, incite, or further illegal + or unlawful activity or content, such as:\\n 1. Violence or terrorism\\n + \ 2. Exploitation or harm to children, including the solicitation, creation, + acquisition, or dissemination of child exploitative content or failure to + report Child Sexual Abuse Material\\n 3. Human trafficking, exploitation, + and sexual violence\\n 4. The illegal distribution of information or + materials to minors, including obscene materials, or failure to employ legally + required age-gating in connection with such information or materials.\\n 5. + Sexual solicitation\\n 6. Any other criminal activity\\n 3. Engage + in, promote, incite, or facilitate the harassment, abuse, threatening, or + bullying of individuals or groups of individuals\\n 4. Engage in, promote, + incite, or facilitate discrimination or other unlawful or harmful conduct + in the provision of employment, employment benefits, credit, housing, other + economic benefits, or other essential goods and services\\n 5. Engage in + the unauthorized or unlicensed practice of any profession including, but not + limited to, financial, legal, medical/health, or related professional practices\\n + \ 6. Collect, process, disclose, generate, or infer health, demographic, + or other sensitive personal or private information about individuals without + rights and consents required by applicable laws\\n 7. Engage in or facilitate + any action or generate any content that infringes, misappropriates, or otherwise + violates any third-party rights, including the outputs or results of any products + or services using the Llama Materials\\n 8. Create, generate, or facilitate + the creation of malicious code, malware, computer viruses or do anything else + that could disable, overburden, interfere with or impair the proper working, + integrity, operation or appearance of a website or computer system\\n\\n2. + Engage in, promote, incite, facilitate, or assist in the planning or development + of activities that present a risk of death or bodily harm to individuals, + including use of Llama 3.1 related to the following:\\n 1. Military, warfare, + nuclear industries or applications, espionage, use for materials or activities + that are subject to the International Traffic Arms Regulations (ITAR) maintained + by the United States Department of State\\n 2. Guns and illegal weapons + (including weapon development)\\n 3. Illegal drugs and regulated/controlled + substances\\n 4. Operation of critical infrastructure, transportation technologies, + or heavy machinery\\n 5. Self-harm or harm to others, including suicide, + cutting, and eating disorders\\n 6. Any content intended to incite or promote + violence, abuse, or any infliction of bodily harm to an individual\\n\\n3. + Intentionally deceive or mislead others, including use of Llama 3.1 related + to the following:\\n 1. Generating, promoting, or furthering fraud or the + creation or promotion of disinformation\\n 2. Generating, promoting, or + furthering defamatory content, including the creation of defamatory statements, + images, or other content\\n 3. Generating, promoting, or further distributing + spam\\n 4. Impersonating another individual without consent, authorization, + or legal right\\n 5. Representing that the use of Llama 3.1 or outputs + are human-generated\\n 6. Generating or facilitating false online engagement, + including fake reviews and other means of fake online engagement\\n\\n4. Fail + to appropriately disclose to end users any known dangers of your AI system\\n\\nPlease + report any violation of this Policy, software \u201Cbug,\u201D or other problems + that could lead to a violation\\nof this Policy through one of the following + means:\\n\\n* Reporting issues with the model: [https://github.com/meta-llama/llama-models/issues](https://github.com/meta-llama/llama-models/issues)\\n* + Reporting risky content generated by the model: developers.facebook.com/llama_output_feedback\\n* + Reporting bugs and security concerns: facebook.com/whitehat/info\\n* Reporting + violations of the Acceptable Use Policy or unlicensed uses of Llama 3.1: LlamaUseReport@meta.com\\n\\\"\\n\",\"parameters\":\"stop + \ \\\"\\u003c|start_header_id|\\u003e\\\"\\nstop + \ \\\"\\u003c|end_header_id|\\u003e\\\"\\nstop \\\"\\u003c|eot_id|\\u003e\\\"\",\"template\":\"{{ + if .Messages }}\\n{{- if or .System .Tools }}\\u003c|start_header_id|\\u003esystem\\u003c|end_header_id|\\u003e\\n{{- + if .System }}\\n\\n{{ .System }}\\n{{- end }}\\n{{- if .Tools }}\\n\\nYou + are a helpful assistant with tool calling capabilities. When you receive a + tool call response, use the output to format an answer to the orginal use + question.\\n{{- end }}\\u003c|eot_id|\\u003e\\n{{- end }}\\n{{- range $i, + $_ := .Messages }}\\n{{- $last := eq (len (slice $.Messages $i)) 1 }}\\n{{- + if eq .Role \\\"user\\\" }}\\u003c|start_header_id|\\u003euser\\u003c|end_header_id|\\u003e\\n{{- + if and $.Tools $last }}\\n\\nGiven the following functions, please respond + with a JSON for a function call with its proper arguments that best answers + the given prompt.\\n\\nRespond in the format {\\\"name\\\": function name, + \\\"parameters\\\": dictionary of argument name and its value}. Do not use + variables.\\n\\n{{ $.Tools }}\\n{{- end }}\\n\\n{{ .Content }}\\u003c|eot_id|\\u003e{{ + if $last }}\\u003c|start_header_id|\\u003eassistant\\u003c|end_header_id|\\u003e\\n\\n{{ + end }}\\n{{- else if eq .Role \\\"assistant\\\" }}\\u003c|start_header_id|\\u003eassistant\\u003c|end_header_id|\\u003e\\n{{- + if .ToolCalls }}\\n\\n{{- range .ToolCalls }}{\\\"name\\\": \\\"{{ .Function.Name + }}\\\", \\\"parameters\\\": {{ .Function.Arguments }}}{{ end }}\\n{{- else + }}\\n\\n{{ .Content }}{{ if not $last }}\\u003c|eot_id|\\u003e{{ end }}\\n{{- + end }}\\n{{- else if eq .Role \\\"tool\\\" }}\\u003c|start_header_id|\\u003eipython\\u003c|end_header_id|\\u003e\\n\\n{{ + .Content }}\\u003c|eot_id|\\u003e{{ if $last }}\\u003c|start_header_id|\\u003eassistant\\u003c|end_header_id|\\u003e\\n\\n{{ + end }}\\n{{- end }}\\n{{- end }}\\n{{- else }}\\n{{- if .System }}\\u003c|start_header_id|\\u003esystem\\u003c|end_header_id|\\u003e\\n\\n{{ + .System }}\\u003c|eot_id|\\u003e{{ end }}{{ if .Prompt }}\\u003c|start_header_id|\\u003euser\\u003c|end_header_id|\\u003e\\n\\n{{ + .Prompt }}\\u003c|eot_id|\\u003e{{ end }}\\u003c|start_header_id|\\u003eassistant\\u003c|end_header_id|\\u003e\\n\\n{{ + end }}{{ .Response }}{{ if .Response }}\\u003c|eot_id|\\u003e{{ end }}\",\"details\":{\"parent_model\":\"\",\"format\":\"gguf\",\"family\":\"llama\",\"families\":[\"llama\"],\"parameter_size\":\"8.0B\",\"quantization_level\":\"Q4_0\"},\"model_info\":{\"general.architecture\":\"llama\",\"general.basename\":\"Meta-Llama-3.1\",\"general.file_type\":2,\"general.finetune\":\"Instruct\",\"general.languages\":[\"en\",\"de\",\"fr\",\"it\",\"pt\",\"hi\",\"es\",\"th\"],\"general.license\":\"llama3.1\",\"general.parameter_count\":8030261248,\"general.quantization_version\":2,\"general.size_label\":\"8B\",\"general.tags\":[\"facebook\",\"meta\",\"pytorch\",\"llama\",\"llama-3\",\"text-generation\"],\"general.type\":\"model\",\"llama.attention.head_count\":32,\"llama.attention.head_count_kv\":8,\"llama.attention.layer_norm_rms_epsilon\":0.00001,\"llama.block_count\":32,\"llama.context_length\":131072,\"llama.embedding_length\":4096,\"llama.feed_forward_length\":14336,\"llama.rope.dimension_count\":128,\"llama.rope.freq_base\":500000,\"llama.vocab_size\":128256,\"tokenizer.ggml.bos_token_id\":128000,\"tokenizer.ggml.eos_token_id\":128009,\"tokenizer.ggml.merges\":null,\"tokenizer.ggml.model\":\"gpt2\",\"tokenizer.ggml.pre\":\"llama-bpe\",\"tokenizer.ggml.token_type\":null,\"tokenizer.ggml.tokens\":null},\"modified_at\":\"2024-07-28T16:34:12.391102099-07:00\"}" + headers: + Content-Type: + - application/json; charset=utf-8 + Date: + - Sun, 17 Nov 2024 08:42:01 GMT + Transfer-Encoding: + - chunked + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_openai[List three fruits-output_types3-list].yaml b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_openai[List three fruits-output_types3-list].yaml new file mode 100644 index 00000000..2d000c98 --- /dev/null +++ b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_openai[List three fruits-output_types3-list].yaml @@ -0,0 +1,133 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "List three fruits"}], "model": + "gpt-4o", "stream": true, "tool_choice": {"type": "function", "function": {"name": + "return_list_of_str"}}, "tools": [{"type": "function", "function": {"name": + "return_list_of_str", "parameters": {"properties": {"value": {"items": {"type": + "string"}, "title": "Value", "type": "array"}}, "required": ["value"], "type": + "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '405' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '1' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AUTwf4o5SKUhOyfvSPLp3t2GJcT8F","object":"chat.completion.chunk","created":1731828313,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45c6de4934","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_7mIwfT9C7KMERmluhssVwtcN","type":"function","function":{"name":"return_list_of_str","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwf4o5SKUhOyfvSPLp3t2GJcT8F","object":"chat.completion.chunk","created":1731828313,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45c6de4934","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwf4o5SKUhOyfvSPLp3t2GJcT8F","object":"chat.completion.chunk","created":1731828313,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45c6de4934","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"value"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwf4o5SKUhOyfvSPLp3t2GJcT8F","object":"chat.completion.chunk","created":1731828313,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45c6de4934","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":[\""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwf4o5SKUhOyfvSPLp3t2GJcT8F","object":"chat.completion.chunk","created":1731828313,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45c6de4934","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Apple"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwf4o5SKUhOyfvSPLp3t2GJcT8F","object":"chat.completion.chunk","created":1731828313,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45c6de4934","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\",\""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwf4o5SKUhOyfvSPLp3t2GJcT8F","object":"chat.completion.chunk","created":1731828313,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45c6de4934","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Ban"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwf4o5SKUhOyfvSPLp3t2GJcT8F","object":"chat.completion.chunk","created":1731828313,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45c6de4934","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"ana"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwf4o5SKUhOyfvSPLp3t2GJcT8F","object":"chat.completion.chunk","created":1731828313,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45c6de4934","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\",\""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwf4o5SKUhOyfvSPLp3t2GJcT8F","object":"chat.completion.chunk","created":1731828313,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45c6de4934","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Cherry"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwf4o5SKUhOyfvSPLp3t2GJcT8F","object":"chat.completion.chunk","created":1731828313,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45c6de4934","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"]"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwf4o5SKUhOyfvSPLp3t2GJcT8F","object":"chat.completion.chunk","created":1731828313,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45c6de4934","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"}"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwf4o5SKUhOyfvSPLp3t2GJcT8F","object":"chat.completion.chunk","created":1731828313,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45c6de4934","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3dfc5109f1967c-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:25:13 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '166' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29978' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 44ms + x-request-id: + - req_c4e65be0b007a9d9ae73819cfe58f427 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_openai[Return True-output_types1-bool].yaml b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_openai[Return True-output_types1-bool].yaml new file mode 100644 index 00000000..ce90efb2 --- /dev/null +++ b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_openai[Return True-output_types1-bool].yaml @@ -0,0 +1,114 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Return True"}], "model": "gpt-4o", + "stream": true, "tool_choice": {"type": "function", "function": {"name": "return_bool"}}, + "tools": [{"type": "function", "function": {"name": "return_bool", "parameters": + {"properties": {"value": {"title": "Value", "type": "boolean"}}, "required": + ["value"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '358' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '1' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AUTwdEJP2oGLwSUYenyC3lRplVWJS","object":"chat.completion.chunk","created":1731828311,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_4C1sZNWK6M2pD5y0ulrRy3fg","type":"function","function":{"name":"return_bool","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwdEJP2oGLwSUYenyC3lRplVWJS","object":"chat.completion.chunk","created":1731828311,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwdEJP2oGLwSUYenyC3lRplVWJS","object":"chat.completion.chunk","created":1731828311,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"value"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwdEJP2oGLwSUYenyC3lRplVWJS","object":"chat.completion.chunk","created":1731828311,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwdEJP2oGLwSUYenyC3lRplVWJS","object":"chat.completion.chunk","created":1731828311,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"true"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwdEJP2oGLwSUYenyC3lRplVWJS","object":"chat.completion.chunk","created":1731828311,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"}"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwdEJP2oGLwSUYenyC3lRplVWJS","object":"chat.completion.chunk","created":1731828311,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-RAY: + - 8e3dfc41feab26ae-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:25:11 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-processing-ms: + - '195' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29980' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 40ms + x-request-id: + - req_feb59c8f79f4726fdd14a6b80eae44b9 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_openai[Return the numbers 1 to 5-output_types2-list].yaml b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_openai[Return the numbers 1 to 5-output_types2-list].yaml new file mode 100644 index 00000000..919b2706 --- /dev/null +++ b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_openai[Return the numbers 1 to 5-output_types2-list].yaml @@ -0,0 +1,139 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Return the numbers 1 to 5"}], + "model": "gpt-4o", "stream": true, "tool_choice": {"type": "function", "function": + {"name": "return_list_of_int"}}, "tools": [{"type": "function", "function": + {"name": "return_list_of_int", "parameters": {"properties": {"value": {"items": + {"type": "integer"}, "title": "Value", "type": "array"}}, "required": ["value"], + "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '414' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '1' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AUTwebHW8sQA089xMHGEuDIYfa34L","object":"chat.completion.chunk","created":1731828312,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_RazWgO8AoRHcel2hz9XAQGmF","type":"function","function":{"name":"return_list_of_int","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwebHW8sQA089xMHGEuDIYfa34L","object":"chat.completion.chunk","created":1731828312,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwebHW8sQA089xMHGEuDIYfa34L","object":"chat.completion.chunk","created":1731828312,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"value"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwebHW8sQA089xMHGEuDIYfa34L","object":"chat.completion.chunk","created":1731828312,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":["}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwebHW8sQA089xMHGEuDIYfa34L","object":"chat.completion.chunk","created":1731828312,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"1"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwebHW8sQA089xMHGEuDIYfa34L","object":"chat.completion.chunk","created":1731828312,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":","}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwebHW8sQA089xMHGEuDIYfa34L","object":"chat.completion.chunk","created":1731828312,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"2"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwebHW8sQA089xMHGEuDIYfa34L","object":"chat.completion.chunk","created":1731828312,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":","}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwebHW8sQA089xMHGEuDIYfa34L","object":"chat.completion.chunk","created":1731828312,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"3"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwebHW8sQA089xMHGEuDIYfa34L","object":"chat.completion.chunk","created":1731828312,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":","}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwebHW8sQA089xMHGEuDIYfa34L","object":"chat.completion.chunk","created":1731828312,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"4"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwebHW8sQA089xMHGEuDIYfa34L","object":"chat.completion.chunk","created":1731828312,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":","}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwebHW8sQA089xMHGEuDIYfa34L","object":"chat.completion.chunk","created":1731828312,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"5"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwebHW8sQA089xMHGEuDIYfa34L","object":"chat.completion.chunk","created":1731828312,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"]}"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwebHW8sQA089xMHGEuDIYfa34L","object":"chat.completion.chunk","created":1731828312,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3dfc470b9515b8-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:25:13 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '782' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29976' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 48ms + x-request-id: + - req_517f43f3b68fb13fa08a6da2c15000d7 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_openai[Say hello!-output_types0-str].yaml b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_openai[Say hello!-output_types0-str].yaml new file mode 100644 index 00000000..c29695e2 --- /dev/null +++ b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_openai[Say hello!-output_types0-str].yaml @@ -0,0 +1,129 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Say hello!"}], "model": "gpt-4o", + "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '92' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '1' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AUTwcEN0rf1XTlGxobymnliUqnUWM","object":"chat.completion.chunk","created":1731828310,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwcEN0rf1XTlGxobymnliUqnUWM","object":"chat.completion.chunk","created":1731828310,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwcEN0rf1XTlGxobymnliUqnUWM","object":"chat.completion.chunk","created":1731828310,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"content":"!"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwcEN0rf1XTlGxobymnliUqnUWM","object":"chat.completion.chunk","created":1731828310,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"content":" + How"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwcEN0rf1XTlGxobymnliUqnUWM","object":"chat.completion.chunk","created":1731828310,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"content":" + can"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwcEN0rf1XTlGxobymnliUqnUWM","object":"chat.completion.chunk","created":1731828310,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"content":" + I"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwcEN0rf1XTlGxobymnliUqnUWM","object":"chat.completion.chunk","created":1731828310,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"content":" + assist"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwcEN0rf1XTlGxobymnliUqnUWM","object":"chat.completion.chunk","created":1731828310,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"content":" + you"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwcEN0rf1XTlGxobymnliUqnUWM","object":"chat.completion.chunk","created":1731828310,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"content":" + today"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwcEN0rf1XTlGxobymnliUqnUWM","object":"chat.completion.chunk","created":1731828310,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"content":"?"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwcEN0rf1XTlGxobymnliUqnUWM","object":"chat.completion.chunk","created":1731828310,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3dfc3a48fbaaa6-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:25:10 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '175' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29980' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 40ms + x-request-id: + - req_a75aef1305f643233bb3f2f6075c48e1 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_raises_tool_schema_parse_error.yaml b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_raises_tool_schema_parse_error.yaml new file mode 100644 index 00000000..6dfaa52c --- /dev/null +++ b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_acomplete_raises_tool_schema_parse_error.yaml @@ -0,0 +1,114 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Return a test value of 42."}], + "model": "gpt-4o", "stream": true, "tool_choice": {"type": "function", "function": + {"name": "return_test"}}, "tools": [{"type": "function", "function": {"name": + "return_test", "parameters": {"properties": {"value": {"title": "Value", "type": + "integer"}}, "required": ["value"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '373' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '1' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AUTwbUv4HAQjaRVaaXlMbhEi7uQ7G","object":"chat.completion.chunk","created":1731828309,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_PPex46eWcFYAOLk1o79zfORX","type":"function","function":{"name":"return_test","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwbUv4HAQjaRVaaXlMbhEi7uQ7G","object":"chat.completion.chunk","created":1731828309,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwbUv4HAQjaRVaaXlMbhEi7uQ7G","object":"chat.completion.chunk","created":1731828309,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"value"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwbUv4HAQjaRVaaXlMbhEi7uQ7G","object":"chat.completion.chunk","created":1731828309,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwbUv4HAQjaRVaaXlMbhEi7uQ7G","object":"chat.completion.chunk","created":1731828309,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"42"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwbUv4HAQjaRVaaXlMbhEi7uQ7G","object":"chat.completion.chunk","created":1731828309,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"}"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwbUv4HAQjaRVaaXlMbhEi7uQ7G","object":"chat.completion.chunk","created":1731828309,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3dfc34be3b17e0-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:25:09 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '241' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29976' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 48ms + x-request-id: + - req_9f1f8e3287ea83e46a23244ec90d14a3 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_anthropic[Return True-output_types1-bool].yaml b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_anthropic[Return True-output_types1-bool].yaml new file mode 100644 index 00000000..0769470b --- /dev/null +++ b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_anthropic[Return True-output_types1-bool].yaml @@ -0,0 +1,170 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - identity + Connection: + - keep-alive + X-Amzn-Trace-Id: + - 9f598468-b36e-4c8b-bc42-0cc2a08c771f + user-agent: + - unknown/None; hf_hub/0.26.2; python/3.10.15 + method: HEAD + uri: https://huggingface.co/claude-3-haiku-20240307/resolve/main/tokenizer.json + response: + body: + string: '' + headers: + Access-Control-Allow-Origin: + - https://huggingface.co + Access-Control-Expose-Headers: + - X-Repo-Commit,X-Request-Id,X-Error-Code,X-Error-Message,X-Total-Count,ETag,Link,Accept-Ranges,Content-Range + Connection: + - keep-alive + Content-Length: + - '29' + Content-Type: + - text/plain; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:29:56 GMT + ETag: + - W/"1d-DMkJvg8tpLoaQbsiq9Mz7l2CJyI" + Referrer-Policy: + - strict-origin-when-cross-origin + Vary: + - Origin + Via: + - 1.1 7189b8cad57dc2d1ab0dd5f90144f2a2.cloudfront.net (CloudFront) + WWW-Authenticate: + - Bearer realm="Authentication required", charset="UTF-8" + X-Amz-Cf-Id: + - YubdV2kfkCBL1Ca0TubsnUE1rOPrKfugsWauazsAW77Qxt9n4DGfnQ== + X-Amz-Cf-Pop: + - SFO5-P1 + X-Cache: + - Error from cloudfront + X-Error-Message: + - Invalid username or password. + X-Powered-By: + - huggingface-moon + X-Request-Id: + - Root=1-67399b74-3e5edc941dcbac1c0ff52324;9f598468-b36e-4c8b-bc42-0cc2a08c771f + cross-origin-opener-policy: + - same-origin + status: + code: 401 + message: Unauthorized +- request: + body: '{"messages": [{"role": "user", "content": [{"type": "text", "text": "Return + True"}]}], "tools": [{"name": "return_bool", "input_schema": {"properties": + {"value": {"title": "Value", "type": "boolean"}}, "required": ["value"], "type": + "object"}}], "tool_choice": {"type": "tool", "name": "return_bool"}, "max_tokens": + 4096, "model": "claude-3-haiku-20240307", "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '373' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - litellm/1.52.6 + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_01X5Hu9ydDxNrE5yvJUfVfye","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":418,"output_tokens":20}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_01QFtyC73Kpf7dLKmcXVHmmf","name":"return_bool","input":{}} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"value"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"\": + \"T"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"rue\"}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":33} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3e033409e9fb50-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:29:56 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_01CDAj1FP2pKEF8W6EpnjTWZ + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_anthropic[Return the numbers 1 to 5-output_types2-list].yaml b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_anthropic[Return the numbers 1 to 5-output_types2-list].yaml new file mode 100644 index 00000000..8590fc14 --- /dev/null +++ b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_anthropic[Return the numbers 1 to 5-output_types2-list].yaml @@ -0,0 +1,110 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": [{"type": "text", "text": "Return + the numbers 1 to 5"}]}], "tools": [{"name": "return_list_of_int", "input_schema": + {"properties": {"value": {"items": {"type": "integer"}, "title": "Value", "type": + "array"}}, "required": ["value"], "type": "object"}}], "tool_choice": {"type": + "tool", "name": "return_list_of_int"}, "max_tokens": 4096, "model": "claude-3-haiku-20240307", + "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '429' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - litellm/1.52.6 + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_01VPrTqYqUpttP9GS7uGH7UZ","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":443,"output_tokens":27}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_01XKd6qB1T4UbXmEyFRzDwqf","name":"return_list_of_int","input":{}}} + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\"value\": + "} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"[1, + "} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"2, + 3, 4, 5]}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":47} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3e0339ce96fb50-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:29:57 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_013KvbntTNqjDajrfWkMGaaM + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_anthropic[Say hello!-output_types0-str].yaml b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_anthropic[Say hello!-output_types0-str].yaml new file mode 100644 index 00000000..02818c71 --- /dev/null +++ b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_anthropic[Say hello!-output_types0-str].yaml @@ -0,0 +1,89 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": [{"type": "text", "text": "Say + hello!"}]}], "max_tokens": 4096, "model": "claude-3-haiku-20240307", "stream": + true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '157' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - litellm/1.52.6 + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_01CHww2eLCdujNPrZWfYKPeU","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":10,"output_tokens":2}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello!"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null},"usage":{"output_tokens":5} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-RAY: + - 8e3e03324864fb50-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:29:55 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + cf-cache-status: + - DYNAMIC + request-id: + - req_01BJ4uMGbRviZidhYTozbKXq + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_anthropic_function_call.yaml b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_anthropic_function_call.yaml new file mode 100644 index 00000000..8932c7cc --- /dev/null +++ b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_anthropic_function_call.yaml @@ -0,0 +1,105 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": [{"type": "text", "text": "Use + the tool to sum 1 and 2"}]}], "tools": [{"name": "plus", "input_schema": {"properties": + {"a": {"title": "A", "type": "integer"}, "b": {"title": "B", "type": "integer"}}, + "required": ["a", "b"], "type": "object"}, "description": "Sum two numbers."}], + "tool_choice": {"type": "tool", "name": "plus"}, "max_tokens": 4096, "model": + "claude-3-haiku-20240307", "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '443' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - litellm/1.52.6 + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_01TZAz4krKFibFDdstrarQQV","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":450,"output_tokens":24}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_012FwM2t7ByNpZueCQL4cQ2W","name":"plus","input":{}} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\"a\": + 1"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":", + \"b\": 2}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":50} + } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3e033d895dfb50-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:29:58 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_013q1Gb1zxZkPeaQHTFTwFgU + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_anthropic_parallel_function_call.yaml b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_anthropic_parallel_function_call.yaml new file mode 100644 index 00000000..fba85003 --- /dev/null +++ b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_anthropic_parallel_function_call.yaml @@ -0,0 +1,111 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": [{"type": "text", "text": "Use + the plus tool to sum 1 and 2. Use the minus tool to subtract 1 from 2."}]}], + "tools": [{"name": "plus", "input_schema": {"properties": {"a": {"title": "A", + "type": "integer"}, "b": {"title": "B", "type": "integer"}}, "required": ["a", + "b"], "type": "object"}}, {"name": "minus", "input_schema": {"properties": {"a": + {"title": "A", "type": "integer"}, "b": {"title": "B", "type": "integer"}}, + "required": ["a", "b"], "type": "object"}}], "tool_choice": {"type": "any"}, + "max_tokens": 4096, "model": "claude-3-haiku-20240307", "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '613' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - litellm/1.52.6 + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_01BC8o94ucd534pzo4kycs2P","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":520,"output_tokens":12}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_01TNVw3uBPsJ9DycmyWi8QsC","name":"plus","input":{}} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\"a"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"\": + 1"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":", + \"b\": 2}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":53} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-RAY: + - 8e3e0343cf98fb50-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:29:58 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + cf-cache-status: + - DYNAMIC + request-id: + - req_01FNu53nQFUoemZrsMnzoH21 + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_ollama[Say hello!-output_types0-str].yaml b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_ollama[Say hello!-output_types0-str].yaml new file mode 100644 index 00000000..bfafcab5 --- /dev/null +++ b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_ollama[Say hello!-output_types0-str].yaml @@ -0,0 +1,157 @@ +interactions: +- request: + body: '{"model": "llama3.1", "messages": [{"role": "user", "content": "Say hello!"}], + "options": {}, "stream": true}' + headers: + accept: + - '*/*' + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '109' + content-type: + - application/json + host: + - localhost:11434 + user-agent: + - python-httpx/0.27.2 + method: POST + uri: http://localhost:11434/api/chat + response: + body: + string: '{"model":"llama3.1","created_at":"2024-11-17T08:41:58.01856Z","message":{"role":"assistant","content":"Hello"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:41:58.110078Z","message":{"role":"assistant","content":"!"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:41:58.205749Z","message":{"role":"assistant","content":" + How"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:41:58.306306Z","message":{"role":"assistant","content":" + are"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:41:58.397683Z","message":{"role":"assistant","content":" + you"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:41:58.488401Z","message":{"role":"assistant","content":" + today"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:41:58.579851Z","message":{"role":"assistant","content":"?"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:41:58.671951Z","message":{"role":"assistant","content":" + Is"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:41:58.763943Z","message":{"role":"assistant","content":" + there"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:41:58.855374Z","message":{"role":"assistant","content":" + something"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:41:58.946026Z","message":{"role":"assistant","content":" + I"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:41:59.037282Z","message":{"role":"assistant","content":" + can"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:41:59.119938Z","message":{"role":"assistant","content":" + help"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:41:59.203584Z","message":{"role":"assistant","content":" + you"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:41:59.289934Z","message":{"role":"assistant","content":" + with"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:41:59.380588Z","message":{"role":"assistant","content":" + or"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:41:59.46176Z","message":{"role":"assistant","content":" + would"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:41:59.544232Z","message":{"role":"assistant","content":" + you"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:41:59.627553Z","message":{"role":"assistant","content":" + like"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:41:59.710636Z","message":{"role":"assistant","content":" + to"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:41:59.798031Z","message":{"role":"assistant","content":" + chat"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:41:59.882501Z","message":{"role":"assistant","content":"?"},"done":false} + + {"model":"llama3.1","created_at":"2024-11-17T08:41:59.964165Z","message":{"role":"assistant","content":""},"done_reason":"stop","done":true,"total_duration":2544046375,"load_duration":36060083,"prompt_eval_count":13,"prompt_eval_duration":560000000,"eval_count":23,"eval_duration":1946000000} + + ' + headers: + Content-Type: + - application/x-ndjson + Date: + - Sun, 17 Nov 2024 08:41:58 GMT + Transfer-Encoding: + - chunked + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - identity + Connection: + - keep-alive + X-Amzn-Trace-Id: + - 0d3eeb7e-5033-456d-b3a8-c21ce5176ca9 + user-agent: + - unknown/None; hf_hub/0.26.2; python/3.10.15 + method: HEAD + uri: https://huggingface.co/llama3.1/resolve/main/tokenizer.json + response: + body: + string: '' + headers: + Access-Control-Allow-Origin: + - https://huggingface.co + Access-Control-Expose-Headers: + - X-Repo-Commit,X-Request-Id,X-Error-Code,X-Error-Message,X-Total-Count,ETag,Link,Accept-Ranges,Content-Range + Connection: + - keep-alive + Content-Length: + - '29' + Content-Type: + - text/plain; charset=utf-8 + Date: + - Sun, 17 Nov 2024 08:42:00 GMT + ETag: + - W/"1d-DMkJvg8tpLoaQbsiq9Mz7l2CJyI" + Referrer-Policy: + - strict-origin-when-cross-origin + Vary: + - Origin + Via: + - 1.1 a282f7d4f5ae65b33d809fbc6ea8641c.cloudfront.net (CloudFront) + WWW-Authenticate: + - Bearer realm="Authentication required", charset="UTF-8" + X-Amz-Cf-Id: + - veTgRtB9BJnRGjMR8eQV52rEcilrsML2_pBHhMYgJbLth-W7ZsQp1w== + X-Amz-Cf-Pop: + - SFO5-P1 + X-Cache: + - Error from cloudfront + X-Error-Message: + - Invalid username or password. + X-Powered-By: + - huggingface-moon + X-Request-Id: + - Root=1-6739ac58-37367eb13765c9a519ee9ae9;0d3eeb7e-5033-456d-b3a8-c21ce5176ca9 + cross-origin-opener-policy: + - same-origin + status: + code: 401 + message: Unauthorized +version: 1 diff --git a/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_openai[List three fruits-output_types3-list].yaml b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_openai[List three fruits-output_types3-list].yaml new file mode 100644 index 00000000..76e44eac --- /dev/null +++ b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_openai[List three fruits-output_types3-list].yaml @@ -0,0 +1,133 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "List three fruits"}], "model": + "gpt-4o", "stream": true, "tool_choice": {"type": "function", "function": {"name": + "return_list_of_str"}}, "tools": [{"type": "function", "function": {"name": + "return_list_of_str", "parameters": {"properties": {"value": {"items": {"type": + "string"}, "title": "Value", "type": "array"}}, "required": ["value"], "type": + "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '405' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AUTwVwbDR0VvP8DZv6a4qdrmVRxLe","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_6TWoP1DD7PgJs6KTI8AAphHp","type":"function","function":{"name":"return_list_of_str","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwVwbDR0VvP8DZv6a4qdrmVRxLe","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwVwbDR0VvP8DZv6a4qdrmVRxLe","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"value"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwVwbDR0VvP8DZv6a4qdrmVRxLe","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":[\""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwVwbDR0VvP8DZv6a4qdrmVRxLe","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Apple"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwVwbDR0VvP8DZv6a4qdrmVRxLe","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\",\""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwVwbDR0VvP8DZv6a4qdrmVRxLe","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Ban"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwVwbDR0VvP8DZv6a4qdrmVRxLe","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"ana"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwVwbDR0VvP8DZv6a4qdrmVRxLe","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\",\""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwVwbDR0VvP8DZv6a4qdrmVRxLe","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Orange"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwVwbDR0VvP8DZv6a4qdrmVRxLe","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"]"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwVwbDR0VvP8DZv6a4qdrmVRxLe","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"}"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwVwbDR0VvP8DZv6a4qdrmVRxLe","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3dfc111a3906ad-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:25:03 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '239' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29967' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 65ms + x-request-id: + - req_b3ae1499d5c9efce654d1442fcdffede + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_openai[Return True-output_types1-bool].yaml b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_openai[Return True-output_types1-bool].yaml new file mode 100644 index 00000000..0a21892e --- /dev/null +++ b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_openai[Return True-output_types1-bool].yaml @@ -0,0 +1,114 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Return True"}], "model": "gpt-4o", + "stream": true, "tool_choice": {"type": "function", "function": {"name": "return_bool"}}, + "tools": [{"type": "function", "function": {"name": "return_bool", "parameters": + {"properties": {"value": {"title": "Value", "type": "boolean"}}, "required": + ["value"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '358' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AUTwUO9911hIQy1Ed7zMkprwhz2P2","object":"chat.completion.chunk","created":1731828302,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_VicATE2ce2afnMfU8WBTmR3w","type":"function","function":{"name":"return_bool","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwUO9911hIQy1Ed7zMkprwhz2P2","object":"chat.completion.chunk","created":1731828302,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwUO9911hIQy1Ed7zMkprwhz2P2","object":"chat.completion.chunk","created":1731828302,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"value"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwUO9911hIQy1Ed7zMkprwhz2P2","object":"chat.completion.chunk","created":1731828302,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwUO9911hIQy1Ed7zMkprwhz2P2","object":"chat.completion.chunk","created":1731828302,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"true"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwUO9911hIQy1Ed7zMkprwhz2P2","object":"chat.completion.chunk","created":1731828302,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"}"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwUO9911hIQy1Ed7zMkprwhz2P2","object":"chat.completion.chunk","created":1731828302,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3dfc0b0cc906ad-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:25:02 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '185' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29980' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 40ms + x-request-id: + - req_6f7f7a907f6ee99c53d7499edeb0e68a + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_openai[Return the numbers 1 to 5-output_types2-list].yaml b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_openai[Return the numbers 1 to 5-output_types2-list].yaml new file mode 100644 index 00000000..db90b1e1 --- /dev/null +++ b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_openai[Return the numbers 1 to 5-output_types2-list].yaml @@ -0,0 +1,139 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Return the numbers 1 to 5"}], + "model": "gpt-4o", "stream": true, "tool_choice": {"type": "function", "function": + {"name": "return_list_of_int"}}, "tools": [{"type": "function", "function": + {"name": "return_list_of_int", "parameters": {"properties": {"value": {"items": + {"type": "integer"}, "title": "Value", "type": "array"}}, "required": ["value"], + "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '414' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AUTwVx3A4kshIixq0gar7B48wfsfQ","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_Z75paGLxRpCe0v0uUKynnS4t","type":"function","function":{"name":"return_list_of_int","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwVx3A4kshIixq0gar7B48wfsfQ","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwVx3A4kshIixq0gar7B48wfsfQ","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"value"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwVx3A4kshIixq0gar7B48wfsfQ","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":["}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwVx3A4kshIixq0gar7B48wfsfQ","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"1"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwVx3A4kshIixq0gar7B48wfsfQ","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":","}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwVx3A4kshIixq0gar7B48wfsfQ","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"2"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwVx3A4kshIixq0gar7B48wfsfQ","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":","}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwVx3A4kshIixq0gar7B48wfsfQ","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"3"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwVx3A4kshIixq0gar7B48wfsfQ","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":","}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwVx3A4kshIixq0gar7B48wfsfQ","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"4"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwVx3A4kshIixq0gar7B48wfsfQ","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":","}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwVx3A4kshIixq0gar7B48wfsfQ","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"5"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwVx3A4kshIixq0gar7B48wfsfQ","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"]}"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwVx3A4kshIixq0gar7B48wfsfQ","object":"chat.completion.chunk","created":1731828303,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3dfc0e0f8106ad-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:25:03 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '241' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29976' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 48ms + x-request-id: + - req_f2d01c213d9fd16bd0efac7f32f39e97 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_openai[Say hello!-output_types0-str].yaml b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_openai[Say hello!-output_types0-str].yaml new file mode 100644 index 00000000..18b9035e --- /dev/null +++ b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_openai[Say hello!-output_types0-str].yaml @@ -0,0 +1,129 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Say hello!"}], "model": "gpt-4o", + "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '92' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AUTwT8NNmbSsycqtDU27uISuudJ90","object":"chat.completion.chunk","created":1731828301,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwT8NNmbSsycqtDU27uISuudJ90","object":"chat.completion.chunk","created":1731828301,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwT8NNmbSsycqtDU27uISuudJ90","object":"chat.completion.chunk","created":1731828301,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"!"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwT8NNmbSsycqtDU27uISuudJ90","object":"chat.completion.chunk","created":1731828301,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + How"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwT8NNmbSsycqtDU27uISuudJ90","object":"chat.completion.chunk","created":1731828301,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + can"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwT8NNmbSsycqtDU27uISuudJ90","object":"chat.completion.chunk","created":1731828301,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + I"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwT8NNmbSsycqtDU27uISuudJ90","object":"chat.completion.chunk","created":1731828301,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + assist"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwT8NNmbSsycqtDU27uISuudJ90","object":"chat.completion.chunk","created":1731828301,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + you"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwT8NNmbSsycqtDU27uISuudJ90","object":"chat.completion.chunk","created":1731828301,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + today"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwT8NNmbSsycqtDU27uISuudJ90","object":"chat.completion.chunk","created":1731828301,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"?"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwT8NNmbSsycqtDU27uISuudJ90","object":"chat.completion.chunk","created":1731828301,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3dfc02acce06ad-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:25:02 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '634' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29980' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 40ms + x-request-id: + - req_0ec124e13cde80d1761199ee139e4323 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_raises_tool_schema_parse_error.yaml b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_raises_tool_schema_parse_error.yaml new file mode 100644 index 00000000..311fe653 --- /dev/null +++ b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_complete_raises_tool_schema_parse_error.yaml @@ -0,0 +1,114 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Return a test value of 42."}], + "model": "gpt-4o", "stream": true, "tool_choice": {"type": "function", "function": + {"name": "return_test"}}, "tools": [{"type": "function", "function": {"name": + "return_test", "parameters": {"properties": {"value": {"title": "Value", "type": + "integer"}}, "required": ["value"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '373' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AUTwX94cwty1Mruu6NVBjLtXCG5V1","object":"chat.completion.chunk","created":1731828305,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_gAIvifBejVQLqCEWWf8C5oUw","type":"function","function":{"name":"return_test","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwX94cwty1Mruu6NVBjLtXCG5V1","object":"chat.completion.chunk","created":1731828305,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwX94cwty1Mruu6NVBjLtXCG5V1","object":"chat.completion.chunk","created":1731828305,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"value"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwX94cwty1Mruu6NVBjLtXCG5V1","object":"chat.completion.chunk","created":1731828305,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwX94cwty1Mruu6NVBjLtXCG5V1","object":"chat.completion.chunk","created":1731828305,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"42"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwX94cwty1Mruu6NVBjLtXCG5V1","object":"chat.completion.chunk","created":1731828305,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"}"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwX94cwty1Mruu6NVBjLtXCG5V1","object":"chat.completion.chunk","created":1731828305,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3dfc1979f206ad-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:25:05 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '229' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29976' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 48ms + x-request-id: + - req_0b6377a056b692faf395d9c3da087713 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_custom_llm_provider.yaml b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_custom_llm_provider.yaml new file mode 100644 index 00000000..204da7b2 --- /dev/null +++ b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_custom_llm_provider.yaml @@ -0,0 +1,129 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Say hello!"}], "model": "gpt-4o", + "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '92' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AUTwWOqWP1CeLW7Pju4cTL3idG5uW","object":"chat.completion.chunk","created":1731828304,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwWOqWP1CeLW7Pju4cTL3idG5uW","object":"chat.completion.chunk","created":1731828304,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwWOqWP1CeLW7Pju4cTL3idG5uW","object":"chat.completion.chunk","created":1731828304,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"!"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwWOqWP1CeLW7Pju4cTL3idG5uW","object":"chat.completion.chunk","created":1731828304,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + How"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwWOqWP1CeLW7Pju4cTL3idG5uW","object":"chat.completion.chunk","created":1731828304,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + can"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwWOqWP1CeLW7Pju4cTL3idG5uW","object":"chat.completion.chunk","created":1731828304,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + I"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwWOqWP1CeLW7Pju4cTL3idG5uW","object":"chat.completion.chunk","created":1731828304,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + assist"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwWOqWP1CeLW7Pju4cTL3idG5uW","object":"chat.completion.chunk","created":1731828304,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + you"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwWOqWP1CeLW7Pju4cTL3idG5uW","object":"chat.completion.chunk","created":1731828304,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + today"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwWOqWP1CeLW7Pju4cTL3idG5uW","object":"chat.completion.chunk","created":1731828304,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"?"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwWOqWP1CeLW7Pju4cTL3idG5uW","object":"chat.completion.chunk","created":1731828304,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-RAY: + - 8e3dfc170fd906ad-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:25:04 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-processing-ms: + - '153' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29980' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 40ms + x-request-id: + - req_a04ef9e00018494e3a21b4724a64e947 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_custom_llm_provider_async.yaml b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_custom_llm_provider_async.yaml new file mode 100644 index 00000000..d5768f6f --- /dev/null +++ b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_custom_llm_provider_async.yaml @@ -0,0 +1,129 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Say hello!"}], "model": "gpt-4o", + "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '92' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '1' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AUTwZ0QV9mKZIyaiRtowBZXoIN0uS","object":"chat.completion.chunk","created":1731828307,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwZ0QV9mKZIyaiRtowBZXoIN0uS","object":"chat.completion.chunk","created":1731828307,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwZ0QV9mKZIyaiRtowBZXoIN0uS","object":"chat.completion.chunk","created":1731828307,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":"!"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwZ0QV9mKZIyaiRtowBZXoIN0uS","object":"chat.completion.chunk","created":1731828307,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + How"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwZ0QV9mKZIyaiRtowBZXoIN0uS","object":"chat.completion.chunk","created":1731828307,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + can"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwZ0QV9mKZIyaiRtowBZXoIN0uS","object":"chat.completion.chunk","created":1731828307,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + I"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwZ0QV9mKZIyaiRtowBZXoIN0uS","object":"chat.completion.chunk","created":1731828307,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + assist"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwZ0QV9mKZIyaiRtowBZXoIN0uS","object":"chat.completion.chunk","created":1731828307,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + you"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwZ0QV9mKZIyaiRtowBZXoIN0uS","object":"chat.completion.chunk","created":1731828307,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + today"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwZ0QV9mKZIyaiRtowBZXoIN0uS","object":"chat.completion.chunk","created":1731828307,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":"?"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwZ0QV9mKZIyaiRtowBZXoIN0uS","object":"chat.completion.chunk","created":1731828307,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3dfc28ac22cfa8-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:25:07 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '206' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29980' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 40ms + x-request-id: + - req_a0ee01edfb277f36c487624136326bb4 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_metadata.yaml b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_metadata.yaml new file mode 100644 index 00000000..f8f224fb --- /dev/null +++ b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_metadata.yaml @@ -0,0 +1,129 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Say hello!"}], "model": "gpt-4o", + "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '92' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AUTwWxIa3SApBwVf2eLIy4JD2mTZT","object":"chat.completion.chunk","created":1731828304,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwWxIa3SApBwVf2eLIy4JD2mTZT","object":"chat.completion.chunk","created":1731828304,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwWxIa3SApBwVf2eLIy4JD2mTZT","object":"chat.completion.chunk","created":1731828304,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":"!"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwWxIa3SApBwVf2eLIy4JD2mTZT","object":"chat.completion.chunk","created":1731828304,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + How"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwWxIa3SApBwVf2eLIy4JD2mTZT","object":"chat.completion.chunk","created":1731828304,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + can"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwWxIa3SApBwVf2eLIy4JD2mTZT","object":"chat.completion.chunk","created":1731828304,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + I"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwWxIa3SApBwVf2eLIy4JD2mTZT","object":"chat.completion.chunk","created":1731828304,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + assist"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwWxIa3SApBwVf2eLIy4JD2mTZT","object":"chat.completion.chunk","created":1731828304,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + you"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwWxIa3SApBwVf2eLIy4JD2mTZT","object":"chat.completion.chunk","created":1731828304,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + today"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwWxIa3SApBwVf2eLIy4JD2mTZT","object":"chat.completion.chunk","created":1731828304,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":"?"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwWxIa3SApBwVf2eLIy4JD2mTZT","object":"chat.completion.chunk","created":1731828304,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3dfc146d8506ad-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:25:04 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '217' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29980' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 40ms + x-request-id: + - req_567994aa049585e315cf4c1d7e8d0932 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_metadata_async.yaml b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_metadata_async.yaml new file mode 100644 index 00000000..fb9581c5 --- /dev/null +++ b/tests/chat_model/cassettes/test_litellm_chat_model/test_litellm_chat_model_metadata_async.yaml @@ -0,0 +1,129 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Say hello!"}], "model": "gpt-4o", + "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '92' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AUTwXi3pJuBqnU0MdgU9RfbabIbie","object":"chat.completion.chunk","created":1731828305,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwXi3pJuBqnU0MdgU9RfbabIbie","object":"chat.completion.chunk","created":1731828305,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwXi3pJuBqnU0MdgU9RfbabIbie","object":"chat.completion.chunk","created":1731828305,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"!"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwXi3pJuBqnU0MdgU9RfbabIbie","object":"chat.completion.chunk","created":1731828305,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + How"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwXi3pJuBqnU0MdgU9RfbabIbie","object":"chat.completion.chunk","created":1731828305,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + can"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwXi3pJuBqnU0MdgU9RfbabIbie","object":"chat.completion.chunk","created":1731828305,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + I"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwXi3pJuBqnU0MdgU9RfbabIbie","object":"chat.completion.chunk","created":1731828305,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + assist"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwXi3pJuBqnU0MdgU9RfbabIbie","object":"chat.completion.chunk","created":1731828305,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + you"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwXi3pJuBqnU0MdgU9RfbabIbie","object":"chat.completion.chunk","created":1731828305,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + today"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwXi3pJuBqnU0MdgU9RfbabIbie","object":"chat.completion.chunk","created":1731828305,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"?"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwXi3pJuBqnU0MdgU9RfbabIbie","object":"chat.completion.chunk","created":1731828305,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3dfc1c6b521684-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:25:05 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '216' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29980' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 40ms + x-request-id: + - req_1dfa909c7830bc683dfbc05a99d25f1f + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_acomplete[List three fruits-output_types3-list].yaml b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_acomplete[List three fruits-output_types3-list].yaml new file mode 100644 index 00000000..8cfca4d7 --- /dev/null +++ b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_acomplete[List three fruits-output_types3-list].yaml @@ -0,0 +1,100 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "List three fruits"}], "model": + "mistral-large-latest", "stream": true, "tool_choice": "any", "tools": [{"type": + "function", "function": {"name": "return_list_of_str", "parameters": {"properties": + {"value": {"items": {"type": "string"}, "title": "Value", "type": "array"}}, + "required": ["value"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '360' + content-type: + - application/json + host: + - api.mistral.ai + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.mistral.ai/v1/chat/completions + response: + body: + string: 'data: {"id":"ca36bc7f83734d5f8ee47b89f36ca921","object":"chat.completion.chunk","created":1731829462,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]} + + + data: {"id":"ca36bc7f83734d5f8ee47b89f36ca921","object":"chat.completion.chunk","created":1731829462,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"tool_calls":[{"id":"XubyS1qTd","function":{"name":"return_list_of_str","arguments":"{\"value\": + [\"apple\", \"banana\", \"cherry\"]}"}}]},"finish_reason":"tool_calls"}],"usage":{"prompt_tokens":79,"total_tokens":112,"completion_tokens":33}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3e18588feaeb35-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:44:22 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + ratelimitbysize-limit: + - '2000000' + ratelimitbysize-query-cost: + - '32004' + ratelimitbysize-remaining: + - '1583879' + ratelimitbysize-reset: + - '39' + x-envoy-upstream-service-time: + - '963' + x-kong-proxy-latency: + - '0' + x-kong-request-id: + - 7cc8f83c1744ce2ad4ca4e1917bc4764 + x-kong-upstream-latency: + - '965' + x-ratelimitbysize-limit-minute: + - '2000000' + x-ratelimitbysize-limit-month: + - '10000000000' + x-ratelimitbysize-remaining-minute: + - '1583879' + x-ratelimitbysize-remaining-month: + - '9998399515' + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_acomplete[Return True-output_types1-bool].yaml b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_acomplete[Return True-output_types1-bool].yaml new file mode 100644 index 00000000..ae8164c5 --- /dev/null +++ b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_acomplete[Return True-output_types1-bool].yaml @@ -0,0 +1,99 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Return True"}], "model": "mistral-large-latest", + "stream": true, "tool_choice": "any", "tools": [{"type": "function", "function": + {"name": "return_bool", "parameters": {"properties": {"value": {"title": "Value", + "type": "boolean"}}, "required": ["value"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '320' + content-type: + - application/json + host: + - api.mistral.ai + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.mistral.ai/v1/chat/completions + response: + body: + string: 'data: {"id":"9a17fad690f542adb62bbfbe0bee2afb","object":"chat.completion.chunk","created":1731829459,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]} + + + data: {"id":"9a17fad690f542adb62bbfbe0bee2afb","object":"chat.completion.chunk","created":1731829459,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"tool_calls":[{"id":"EPXkQWLC5","function":{"name":"return_bool","arguments":"{\"value\": + true}"}}]},"finish_reason":"tool_calls"}],"usage":{"prompt_tokens":65,"total_tokens":84,"completion_tokens":19}} + + + data: [DONE] + + + ' + headers: + CF-RAY: + - 8e3e18459a4fcf0a-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:44:20 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + ratelimitbysize-limit: + - '2000000' + ratelimitbysize-query-cost: + - '32003' + ratelimitbysize-remaining: + - '1679894' + ratelimitbysize-reset: + - '42' + x-envoy-upstream-service-time: + - '1031' + x-kong-proxy-latency: + - '0' + x-kong-request-id: + - b16bd0599fbdb21cbe7a5718c24f1d71 + x-kong-upstream-latency: + - '1057' + x-ratelimitbysize-limit-minute: + - '2000000' + x-ratelimitbysize-limit-month: + - '10000000000' + x-ratelimitbysize-remaining-minute: + - '1679894' + x-ratelimitbysize-remaining-month: + - '9998495530' + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_acomplete[Return the numbers 1 to 5-output_types2-list].yaml b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_acomplete[Return the numbers 1 to 5-output_types2-list].yaml new file mode 100644 index 00000000..f70c5a60 --- /dev/null +++ b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_acomplete[Return the numbers 1 to 5-output_types2-list].yaml @@ -0,0 +1,100 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Return the numbers 1 to 5"}], + "model": "mistral-large-latest", "stream": true, "tool_choice": "any", "tools": + [{"type": "function", "function": {"name": "return_list_of_int", "parameters": + {"properties": {"value": {"items": {"type": "integer"}, "title": "Value", "type": + "array"}}, "required": ["value"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '369' + content-type: + - application/json + host: + - api.mistral.ai + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.mistral.ai/v1/chat/completions + response: + body: + string: 'data: {"id":"cd4105f0c81b4b449d44ef17d0f62719","object":"chat.completion.chunk","created":1731829460,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]} + + + data: {"id":"cd4105f0c81b4b449d44ef17d0f62719","object":"chat.completion.chunk","created":1731829460,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"tool_calls":[{"id":"ZGHIxPEiQ","function":{"name":"return_list_of_int","arguments":"{\"value\": + [1, 2, 3, 4, 5]}"}}]},"finish_reason":"tool_calls"}],"usage":{"prompt_tokens":84,"total_tokens":121,"completion_tokens":37}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3e184e580b964a-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:44:21 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + ratelimitbysize-limit: + - '2000000' + ratelimitbysize-query-cost: + - '32008' + ratelimitbysize-remaining: + - '1615883' + ratelimitbysize-reset: + - '40' + x-envoy-upstream-service-time: + - '1297' + x-kong-proxy-latency: + - '1' + x-kong-request-id: + - 2086cf53ed21ed5aab095628ec695b29 + x-kong-upstream-latency: + - '1297' + x-ratelimitbysize-limit-minute: + - '2000000' + x-ratelimitbysize-limit-month: + - '10000000000' + x-ratelimitbysize-remaining-minute: + - '1615883' + x-ratelimitbysize-remaining-month: + - '9998431519' + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_acomplete[Say hello!-output_types0-str].yaml b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_acomplete[Say hello!-output_types0-str].yaml new file mode 100644 index 00000000..e60c6839 --- /dev/null +++ b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_acomplete[Say hello!-output_types0-str].yaml @@ -0,0 +1,121 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Say hello!"}], "model": "mistral-large-latest", + "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '106' + content-type: + - application/json + host: + - api.mistral.ai + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.mistral.ai/v1/chat/completions + response: + body: + string: 'data: {"id":"9ccd7cb3e78f4019946b047af667b743","object":"chat.completion.chunk","created":1731829458,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]} + + + data: {"id":"9ccd7cb3e78f4019946b047af667b743","object":"chat.completion.chunk","created":1731829458,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]} + + + data: {"id":"9ccd7cb3e78f4019946b047af667b743","object":"chat.completion.chunk","created":1731829458,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"content":"!"},"finish_reason":null}]} + + + data: {"id":"9ccd7cb3e78f4019946b047af667b743","object":"chat.completion.chunk","created":1731829458,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"content":" + How"},"finish_reason":null}]} + + + data: {"id":"9ccd7cb3e78f4019946b047af667b743","object":"chat.completion.chunk","created":1731829458,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"content":" + are"},"finish_reason":null}]} + + + data: {"id":"9ccd7cb3e78f4019946b047af667b743","object":"chat.completion.chunk","created":1731829458,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"content":" + you"},"finish_reason":null}]} + + + data: {"id":"9ccd7cb3e78f4019946b047af667b743","object":"chat.completion.chunk","created":1731829458,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"content":" + today"},"finish_reason":null}]} + + + data: {"id":"9ccd7cb3e78f4019946b047af667b743","object":"chat.completion.chunk","created":1731829458,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"content":"?"},"finish_reason":null}]} + + + data: {"id":"9ccd7cb3e78f4019946b047af667b743","object":"chat.completion.chunk","created":1731829458,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"content":""},"finish_reason":"stop"}],"usage":{"prompt_tokens":7,"total_tokens":14,"completion_tokens":7}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3e183edff3238b-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:44:18 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + ratelimitbysize-limit: + - '2000000' + ratelimitbysize-query-cost: + - '32003' + ratelimitbysize-remaining: + - '1679894' + ratelimitbysize-reset: + - '42' + x-envoy-upstream-service-time: + - '233' + x-kong-proxy-latency: + - '0' + x-kong-request-id: + - 5b6e3f322fed303dde6d7a243822fa52 + x-kong-upstream-latency: + - '234' + x-ratelimitbysize-limit-minute: + - '2000000' + x-ratelimitbysize-limit-month: + - '10000000000' + x-ratelimitbysize-remaining-minute: + - '1679894' + x-ratelimitbysize-remaining-month: + - '9998495530' + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_acomplete_async_parallel_function_call.yaml b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_acomplete_async_parallel_function_call.yaml new file mode 100644 index 00000000..8e524357 --- /dev/null +++ b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_acomplete_async_parallel_function_call.yaml @@ -0,0 +1,105 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Use the plus tool to sum 1 and + 2. Use the minus tool to subtract 1 from 2. Make sure to use both tools at once."}], + "model": "mistral-large-latest", "stream": true, "tool_choice": "any", "tools": + [{"type": "function", "function": {"name": "plus", "parameters": {"properties": + {"a": {"title": "A", "type": "integer"}, "b": {"title": "B", "type": "integer"}}, + "required": ["a", "b"], "type": "object"}}}, {"type": "function", "function": + {"name": "minus", "parameters": {"properties": {"a": {"title": "A", "type": + "integer"}, "b": {"title": "B", "type": "integer"}}, "required": ["a", "b"], + "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '653' + content-type: + - application/json + host: + - api.mistral.ai + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.mistral.ai/v1/chat/completions + response: + body: + string: 'data: {"id":"1403bf4a3e5f4f4a860a3b3be51f6ee6","object":"chat.completion.chunk","created":1731829466,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]} + + + data: {"id":"1403bf4a3e5f4f4a860a3b3be51f6ee6","object":"chat.completion.chunk","created":1731829466,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"tool_calls":[{"id":"QAw0JBXkB","function":{"name":"plus","arguments":"{\"a\": + 1, \"b\": 2}"}},{"id":"HlyhI5zAI","function":{"name":"minus","arguments":"{\"a\": + 1, \"b\": 2}"}}]},"finish_reason":"tool_calls"}],"usage":{"prompt_tokens":187,"total_tokens":232,"completion_tokens":45}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3e18736af31592-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:44:28 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + ratelimitbysize-limit: + - '2000000' + ratelimitbysize-query-cost: + - '32036' + ratelimitbysize-remaining: + - '1487836' + ratelimitbysize-reset: + - '34' + x-envoy-upstream-service-time: + - '2595' + x-kong-proxy-latency: + - '0' + x-kong-request-id: + - 0f236c442c1cd56a972c003ee4f80c5c + x-kong-upstream-latency: + - '2596' + x-ratelimitbysize-limit-minute: + - '2000000' + x-ratelimitbysize-limit-month: + - '10000000000' + x-ratelimitbysize-remaining-minute: + - '1487836' + x-ratelimitbysize-remaining-month: + - '9998303472' + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_acomplete_function_call.yaml b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_acomplete_function_call.yaml new file mode 100644 index 00000000..ecfc4c71 --- /dev/null +++ b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_acomplete_function_call.yaml @@ -0,0 +1,100 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Use the tool to sum 1 and 2"}], + "model": "mistral-large-latest", "stream": true, "tool_choice": "any", "tools": + [{"type": "function", "function": {"name": "plus", "parameters": {"properties": + {"a": {"title": "A", "type": "integer"}, "b": {"title": "B", "type": "integer"}}, + "required": ["a", "b"], "type": "object"}, "description": "Sum two numbers."}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '397' + content-type: + - application/json + host: + - api.mistral.ai + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.mistral.ai/v1/chat/completions + response: + body: + string: 'data: {"id":"c914241267cc4fb89a1d3e32713fd596","object":"chat.completion.chunk","created":1731829465,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]} + + + data: {"id":"c914241267cc4fb89a1d3e32713fd596","object":"chat.completion.chunk","created":1731829465,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"tool_calls":[{"id":"p5uZPui6X","function":{"name":"plus","arguments":"{\"a\": + 1, \"b\": 2}"}}]},"finish_reason":"tool_calls"}],"usage":{"prompt_tokens":93,"total_tokens":117,"completion_tokens":24}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3e186cfbd067a3-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:44:26 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + ratelimitbysize-limit: + - '2000000' + ratelimitbysize-query-cost: + - '32011' + ratelimitbysize-remaining: + - '1487861' + ratelimitbysize-reset: + - '35' + x-envoy-upstream-service-time: + - '739' + x-kong-proxy-latency: + - '0' + x-kong-request-id: + - c8782f039373f300f4a62b782ef4861a + x-kong-upstream-latency: + - '741' + x-ratelimitbysize-limit-minute: + - '2000000' + x-ratelimitbysize-limit-month: + - '10000000000' + x-ratelimitbysize-remaining-minute: + - '1487861' + x-ratelimitbysize-remaining-month: + - '9998303497' + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_acomplete_usage.yaml b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_acomplete_usage.yaml new file mode 100644 index 00000000..f7163102 --- /dev/null +++ b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_acomplete_usage.yaml @@ -0,0 +1,121 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Say hello!"}], "model": "mistral-large-latest", + "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '106' + content-type: + - application/json + host: + - api.mistral.ai + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.mistral.ai/v1/chat/completions + response: + body: + string: 'data: {"id":"b7cca9fe62b24bb2972c31733ead5597","object":"chat.completion.chunk","created":1731829463,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]} + + + data: {"id":"b7cca9fe62b24bb2972c31733ead5597","object":"chat.completion.chunk","created":1731829463,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]} + + + data: {"id":"b7cca9fe62b24bb2972c31733ead5597","object":"chat.completion.chunk","created":1731829463,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"content":"!"},"finish_reason":null}]} + + + data: {"id":"b7cca9fe62b24bb2972c31733ead5597","object":"chat.completion.chunk","created":1731829463,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"content":" + How"},"finish_reason":null}]} + + + data: {"id":"b7cca9fe62b24bb2972c31733ead5597","object":"chat.completion.chunk","created":1731829463,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"content":" + are"},"finish_reason":null}]} + + + data: {"id":"b7cca9fe62b24bb2972c31733ead5597","object":"chat.completion.chunk","created":1731829463,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"content":" + you"},"finish_reason":null}]} + + + data: {"id":"b7cca9fe62b24bb2972c31733ead5597","object":"chat.completion.chunk","created":1731829463,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"content":" + today"},"finish_reason":null}]} + + + data: {"id":"b7cca9fe62b24bb2972c31733ead5597","object":"chat.completion.chunk","created":1731829463,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"content":"?"},"finish_reason":null}]} + + + data: {"id":"b7cca9fe62b24bb2972c31733ead5597","object":"chat.completion.chunk","created":1731829463,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"content":""},"finish_reason":"stop"}],"usage":{"prompt_tokens":7,"total_tokens":14,"completion_tokens":7}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3e18606a43fa52-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:44:23 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + ratelimitbysize-limit: + - '2000000' + ratelimitbysize-query-cost: + - '32003' + ratelimitbysize-remaining: + - '1551876' + ratelimitbysize-reset: + - '37' + x-envoy-upstream-service-time: + - '149' + x-kong-proxy-latency: + - '0' + x-kong-request-id: + - 3897d524cf28642ec3b5d5122408683f + x-kong-upstream-latency: + - '150' + x-ratelimitbysize-limit-minute: + - '2000000' + x-ratelimitbysize-limit-month: + - '10000000000' + x-ratelimitbysize-remaining-minute: + - '1551876' + x-ratelimitbysize-remaining-month: + - '9998367512' + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_acomplete_usage_structured_output.yaml b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_acomplete_usage_structured_output.yaml new file mode 100644 index 00000000..949699a2 --- /dev/null +++ b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_acomplete_usage_structured_output.yaml @@ -0,0 +1,100 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Count to 5"}], "model": "mistral-large-latest", + "stream": true, "tool_choice": "any", "tools": [{"type": "function", "function": + {"name": "return_list_of_int", "parameters": {"properties": {"value": {"items": + {"type": "integer"}, "title": "Value", "type": "array"}}, "required": ["value"], + "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '354' + content-type: + - application/json + host: + - api.mistral.ai + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.mistral.ai/v1/chat/completions + response: + body: + string: 'data: {"id":"0ab90dc8740c4e20bc118eae434457f7","object":"chat.completion.chunk","created":1731829463,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]} + + + data: {"id":"0ab90dc8740c4e20bc118eae434457f7","object":"chat.completion.chunk","created":1731829463,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"tool_calls":[{"id":"JZyQw7Md7","function":{"name":"return_list_of_int","arguments":"{\"value\": + [1, 2, 3, 4, 5]}"}}]},"finish_reason":"tool_calls"}],"usage":{"prompt_tokens":80,"total_tokens":117,"completion_tokens":37}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3e18642ad62511-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:44:24 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + ratelimitbysize-limit: + - '2000000' + ratelimitbysize-query-cost: + - '32004' + ratelimitbysize-remaining: + - '1519872' + ratelimitbysize-reset: + - '37' + x-envoy-upstream-service-time: + - '1078' + x-kong-proxy-latency: + - '1' + x-kong-request-id: + - 7b45ac1d09e88b7958510667fffa033e + x-kong-upstream-latency: + - '1079' + x-ratelimitbysize-limit-minute: + - '2000000' + x-ratelimitbysize-limit-month: + - '10000000000' + x-ratelimitbysize-remaining-minute: + - '1519872' + x-ratelimitbysize-remaining-month: + - '9998335508' + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_complete[List three fruits-output_types3-list].yaml b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_complete[List three fruits-output_types3-list].yaml new file mode 100644 index 00000000..a91f9ac1 --- /dev/null +++ b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_complete[List three fruits-output_types3-list].yaml @@ -0,0 +1,100 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "List three fruits"}], "model": + "mistral-large-latest", "stream": true, "tool_choice": "any", "tools": [{"type": + "function", "function": {"name": "return_list_of_str", "parameters": {"properties": + {"value": {"items": {"type": "string"}, "title": "Value", "type": "array"}}, + "required": ["value"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '360' + content-type: + - application/json + host: + - api.mistral.ai + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.mistral.ai/v1/chat/completions + response: + body: + string: 'data: {"id":"8982b3562a82475abaa5d999f9d61d7e","object":"chat.completion.chunk","created":1731829447,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]} + + + data: {"id":"8982b3562a82475abaa5d999f9d61d7e","object":"chat.completion.chunk","created":1731829447,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"tool_calls":[{"id":"yJqUVgW0m","function":{"name":"return_list_of_str","arguments":"{\"value\": + [\"apple\", \"banana\", \"orange\"]}"}}]},"finish_reason":"tool_calls"}],"usage":{"prompt_tokens":79,"total_tokens":112,"completion_tokens":33}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3e1800a80617e6-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:44:08 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + ratelimitbysize-limit: + - '2000000' + ratelimitbysize-query-cost: + - '32004' + ratelimitbysize-remaining: + - '1903990' + ratelimitbysize-reset: + - '53' + x-envoy-upstream-service-time: + - '1013' + x-kong-proxy-latency: + - '0' + x-kong-request-id: + - 77c1ec40311aaa6535774f4aceb2c617 + x-kong-upstream-latency: + - '1014' + x-ratelimitbysize-limit-minute: + - '2000000' + x-ratelimitbysize-limit-month: + - '10000000000' + x-ratelimitbysize-remaining-minute: + - '1903990' + x-ratelimitbysize-remaining-month: + - '9998719626' + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_complete[Return True-output_types1-bool].yaml b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_complete[Return True-output_types1-bool].yaml new file mode 100644 index 00000000..9ab73068 --- /dev/null +++ b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_complete[Return True-output_types1-bool].yaml @@ -0,0 +1,99 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Return True"}], "model": "mistral-large-latest", + "stream": true, "tool_choice": "any", "tools": [{"type": "function", "function": + {"name": "return_bool", "parameters": {"properties": {"value": {"title": "Value", + "type": "boolean"}}, "required": ["value"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '320' + content-type: + - application/json + host: + - api.mistral.ai + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.mistral.ai/v1/chat/completions + response: + body: + string: 'data: {"id":"0d5c78d518524c869fc4800d51d8cb30","object":"chat.completion.chunk","created":1731829445,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]} + + + data: {"id":"0d5c78d518524c869fc4800d51d8cb30","object":"chat.completion.chunk","created":1731829445,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"tool_calls":[{"id":"Hfc39Hu7S","function":{"name":"return_bool","arguments":"{\"value\": + true}"}}]},"finish_reason":"tool_calls"}],"usage":{"prompt_tokens":65,"total_tokens":84,"completion_tokens":19}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3e17f198b8fa8e-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:44:06 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + ratelimitbysize-limit: + - '2000000' + ratelimitbysize-query-cost: + - '32003' + ratelimitbysize-remaining: + - '1967997' + ratelimitbysize-reset: + - '55' + x-envoy-upstream-service-time: + - '734' + x-kong-proxy-latency: + - '1' + x-kong-request-id: + - da05c75e685ff125d304b0668c405936 + x-kong-upstream-latency: + - '735' + x-ratelimitbysize-limit-minute: + - '2000000' + x-ratelimitbysize-limit-month: + - '10000000000' + x-ratelimitbysize-remaining-minute: + - '1967997' + x-ratelimitbysize-remaining-month: + - '9998783633' + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_complete[Return the numbers 1 to 5-output_types2-list].yaml b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_complete[Return the numbers 1 to 5-output_types2-list].yaml new file mode 100644 index 00000000..32c58de8 --- /dev/null +++ b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_complete[Return the numbers 1 to 5-output_types2-list].yaml @@ -0,0 +1,100 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Return the numbers 1 to 5"}], + "model": "mistral-large-latest", "stream": true, "tool_choice": "any", "tools": + [{"type": "function", "function": {"name": "return_list_of_int", "parameters": + {"properties": {"value": {"items": {"type": "integer"}, "title": "Value", "type": + "array"}}, "required": ["value"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '369' + content-type: + - application/json + host: + - api.mistral.ai + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.mistral.ai/v1/chat/completions + response: + body: + string: 'data: {"id":"9d9a8aaa0a394ddc87ada887fbb6060f","object":"chat.completion.chunk","created":1731829446,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]} + + + data: {"id":"9d9a8aaa0a394ddc87ada887fbb6060f","object":"chat.completion.chunk","created":1731829446,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"tool_calls":[{"id":"MDVi7YayZ","function":{"name":"return_list_of_int","arguments":"{\"value\": + [1, 2, 3, 4, 5]}"}}]},"finish_reason":"tool_calls"}],"usage":{"prompt_tokens":84,"total_tokens":121,"completion_tokens":37}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3e17f809b0168e-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:44:07 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + ratelimitbysize-limit: + - '2000000' + ratelimitbysize-query-cost: + - '32008' + ratelimitbysize-remaining: + - '1903986' + ratelimitbysize-reset: + - '54' + x-envoy-upstream-service-time: + - '1073' + x-kong-proxy-latency: + - '1' + x-kong-request-id: + - 48d33755212f3971d31ba50b1e06aa48 + x-kong-upstream-latency: + - '1075' + x-ratelimitbysize-limit-minute: + - '2000000' + x-ratelimitbysize-limit-month: + - '10000000000' + x-ratelimitbysize-remaining-minute: + - '1903986' + x-ratelimitbysize-remaining-month: + - '9998719622' + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_complete[Say hello!-output_types0-str].yaml b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_complete[Say hello!-output_types0-str].yaml new file mode 100644 index 00000000..d1d07f9b --- /dev/null +++ b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_complete[Say hello!-output_types0-str].yaml @@ -0,0 +1,121 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Say hello!"}], "model": "mistral-large-latest", + "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '106' + content-type: + - application/json + host: + - api.mistral.ai + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.mistral.ai/v1/chat/completions + response: + body: + string: 'data: {"id":"311ce09ea04a4048a6331e2b37013451","object":"chat.completion.chunk","created":1731829444,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]} + + + data: {"id":"311ce09ea04a4048a6331e2b37013451","object":"chat.completion.chunk","created":1731829444,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]} + + + data: {"id":"311ce09ea04a4048a6331e2b37013451","object":"chat.completion.chunk","created":1731829444,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"content":"!"},"finish_reason":null}]} + + + data: {"id":"311ce09ea04a4048a6331e2b37013451","object":"chat.completion.chunk","created":1731829444,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"content":" + How"},"finish_reason":null}]} + + + data: {"id":"311ce09ea04a4048a6331e2b37013451","object":"chat.completion.chunk","created":1731829444,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"content":" + are"},"finish_reason":null}]} + + + data: {"id":"311ce09ea04a4048a6331e2b37013451","object":"chat.completion.chunk","created":1731829444,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"content":" + you"},"finish_reason":null}]} + + + data: {"id":"311ce09ea04a4048a6331e2b37013451","object":"chat.completion.chunk","created":1731829444,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"content":" + today"},"finish_reason":null}]} + + + data: {"id":"311ce09ea04a4048a6331e2b37013451","object":"chat.completion.chunk","created":1731829444,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"content":"?"},"finish_reason":null}]} + + + data: {"id":"311ce09ea04a4048a6331e2b37013451","object":"chat.completion.chunk","created":1731829444,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"content":""},"finish_reason":"stop"}],"usage":{"prompt_tokens":7,"total_tokens":14,"completion_tokens":7}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3e17eaba58fae3-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:44:05 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + ratelimitbysize-limit: + - '2000000' + ratelimitbysize-query-cost: + - '32003' + ratelimitbysize-remaining: + - '1967997' + ratelimitbysize-reset: + - '56' + x-envoy-upstream-service-time: + - '267' + x-kong-proxy-latency: + - '9' + x-kong-request-id: + - 30efd17f64756d61fd1faf7bf482eb71 + x-kong-upstream-latency: + - '268' + x-ratelimitbysize-limit-minute: + - '2000000' + x-ratelimitbysize-limit-month: + - '10000000000' + x-ratelimitbysize-remaining-minute: + - '1967997' + x-ratelimitbysize-remaining-month: + - '9998783633' + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_complete_function_call.yaml b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_complete_function_call.yaml new file mode 100644 index 00000000..ffc8d785 --- /dev/null +++ b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_complete_function_call.yaml @@ -0,0 +1,100 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Use the tool to sum 1 and 2"}], + "model": "mistral-large-latest", "stream": true, "tool_choice": "any", "tools": + [{"type": "function", "function": {"name": "plus", "parameters": {"properties": + {"a": {"title": "A", "type": "integer"}, "b": {"title": "B", "type": "integer"}}, + "required": ["a", "b"], "type": "object"}, "description": "Sum two numbers."}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '397' + content-type: + - application/json + host: + - api.mistral.ai + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.mistral.ai/v1/chat/completions + response: + body: + string: 'data: {"id":"67000ff5fb1a4bbd85ae87223d1593b1","object":"chat.completion.chunk","created":1731829452,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]} + + + data: {"id":"67000ff5fb1a4bbd85ae87223d1593b1","object":"chat.completion.chunk","created":1731829452,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"tool_calls":[{"id":"x2LypFllt","function":{"name":"plus","arguments":"{\"a\": + 1, \"b\": 2}"}}]},"finish_reason":"tool_calls"}],"usage":{"prompt_tokens":93,"total_tokens":117,"completion_tokens":24}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3e181d9d32ebed-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:44:13 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + ratelimitbysize-limit: + - '2000000' + ratelimitbysize-query-cost: + - '32011' + ratelimitbysize-remaining: + - '1775964' + ratelimitbysize-reset: + - '48' + x-envoy-upstream-service-time: + - '708' + x-kong-proxy-latency: + - '0' + x-kong-request-id: + - 4b47b56e909d824b934b490f77467b76 + x-kong-upstream-latency: + - '710' + x-ratelimitbysize-limit-minute: + - '2000000' + x-ratelimitbysize-limit-month: + - '10000000000' + x-ratelimitbysize-remaining-minute: + - '1775964' + x-ratelimitbysize-remaining-month: + - '9998591600' + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_complete_parallel_function_call.yaml b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_complete_parallel_function_call.yaml new file mode 100644 index 00000000..a920e3f9 --- /dev/null +++ b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_complete_parallel_function_call.yaml @@ -0,0 +1,105 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Use the plus tool to sum 1 and + 2. Use the minus tool to subtract 1 from 2. Make sure to use both tools at once."}], + "model": "mistral-large-latest", "stream": true, "tool_choice": "any", "tools": + [{"type": "function", "function": {"name": "plus", "parameters": {"properties": + {"a": {"title": "A", "type": "integer"}, "b": {"title": "B", "type": "integer"}}, + "required": ["a", "b"], "type": "object"}}}, {"type": "function", "function": + {"name": "minus", "parameters": {"properties": {"a": {"title": "A", "type": + "integer"}, "b": {"title": "B", "type": "integer"}}, "required": ["a", "b"], + "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '653' + content-type: + - application/json + host: + - api.mistral.ai + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.mistral.ai/v1/chat/completions + response: + body: + string: 'data: {"id":"7b9ca0036a7148d9b31648d5292abe34","object":"chat.completion.chunk","created":1731829453,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]} + + + data: {"id":"7b9ca0036a7148d9b31648d5292abe34","object":"chat.completion.chunk","created":1731829453,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"tool_calls":[{"id":"nqjf8Hqe1","function":{"name":"plus","arguments":"{\"a\": + 1, \"b\": 2}"}},{"id":"ATcpCKul3","function":{"name":"minus","arguments":"{\"a\": + 2, \"b\": 1}"}}]},"finish_reason":"tool_calls"}],"usage":{"prompt_tokens":187,"total_tokens":232,"completion_tokens":45}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3e18240afb67d7-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:44:15 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + ratelimitbysize-limit: + - '2000000' + ratelimitbysize-query-cost: + - '32036' + ratelimitbysize-remaining: + - '1775939' + ratelimitbysize-reset: + - '47' + x-envoy-upstream-service-time: + - '1279' + x-kong-proxy-latency: + - '0' + x-kong-request-id: + - 5c6496197086e47ccc15915624f5825f + x-kong-upstream-latency: + - '1280' + x-ratelimitbysize-limit-minute: + - '2000000' + x-ratelimitbysize-limit-month: + - '10000000000' + x-ratelimitbysize-remaining-minute: + - '1775939' + x-ratelimitbysize-remaining-month: + - '9998591575' + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_complete_usage.yaml b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_complete_usage.yaml new file mode 100644 index 00000000..cb77b545 --- /dev/null +++ b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_complete_usage.yaml @@ -0,0 +1,122 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Say hello!"}], "model": "mistral-large-latest", + "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '106' + content-type: + - application/json + host: + - api.mistral.ai + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.mistral.ai/v1/chat/completions + response: + body: + string: "data: {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\"},\"finish_reason\":null}]}\n\ndata: + {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Hello\"},\"finish_reason\":null}]}\n\ndata: + {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"!\"},\"finish_reason\":null}]}\n\ndata: + {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + How\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + are\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + you\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + doing\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + today\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"?\"},\"finish_reason\":null}]}\n\ndata: + {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + It\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"'\"},\"finish_reason\":null}]}\n\ndata: + {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"s\"},\"finish_reason\":null}]}\n\ndata: + {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + great\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + to\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + have\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + you\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + here\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\".\"},\"finish_reason\":null}]}\n\ndata: + {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + How\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + can\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + I\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + assist\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + you\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"?\"},\"finish_reason\":null}]}\n\ndata: + {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + Let\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"'\"},\"finish_reason\":null}]}\n\ndata: + {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"s\"},\"finish_reason\":null}]}\n\ndata: + {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + have\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + a\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + friendly\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + chat\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\".\"},\"finish_reason\":null}]}\n\ndata: + {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" + \"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"\U0001F60A\"},\"finish_reason\":null}]}\n\ndata: + {\"id\":\"0179eddf4c4e422ab9b08c2b33899392\",\"object\":\"chat.completion.chunk\",\"created\":1731829449,\"model\":\"mistral-large-latest\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"\"},\"finish_reason\":\"stop\"}],\"usage\":{\"prompt_tokens\":7,\"total_tokens\":40,\"completion_tokens\":33}}\n\ndata: + [DONE]\n\n" + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3e18092f237ace-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:44:10 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + ratelimitbysize-limit: + - '2000000' + ratelimitbysize-query-cost: + - '32003' + ratelimitbysize-remaining: + - '1871983' + ratelimitbysize-reset: + - '51' + x-envoy-upstream-service-time: + - '670' + x-kong-proxy-latency: + - '1' + x-kong-request-id: + - 952e0b7b64e07660e254d06c2164327d + x-kong-upstream-latency: + - '672' + x-ratelimitbysize-limit-minute: + - '2000000' + x-ratelimitbysize-limit-month: + - '10000000000' + x-ratelimitbysize-remaining-minute: + - '1871983' + x-ratelimitbysize-remaining-month: + - '9998687619' + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_complete_usage_structured_output.yaml b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_complete_usage_structured_output.yaml new file mode 100644 index 00000000..5ba72eb2 --- /dev/null +++ b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_complete_usage_structured_output.yaml @@ -0,0 +1,100 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Count to 5"}], "model": "mistral-large-latest", + "stream": true, "tool_choice": "any", "tools": [{"type": "function", "function": + {"name": "return_list_of_int", "parameters": {"properties": {"value": {"items": + {"type": "integer"}, "title": "Value", "type": "array"}}, "required": ["value"], + "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '354' + content-type: + - application/json + host: + - api.mistral.ai + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.mistral.ai/v1/chat/completions + response: + body: + string: 'data: {"id":"42392f433a494fc3831eaa819c8646ba","object":"chat.completion.chunk","created":1731829451,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]} + + + data: {"id":"42392f433a494fc3831eaa819c8646ba","object":"chat.completion.chunk","created":1731829451,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"tool_calls":[{"id":"xOJ08nD7E","function":{"name":"return_list_of_int","arguments":"{\"value\": + [1, 2, 3, 4, 5]}"}}]},"finish_reason":"tool_calls"}],"usage":{"prompt_tokens":80,"total_tokens":117,"completion_tokens":37}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3e18139eef642c-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:44:12 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + ratelimitbysize-limit: + - '2000000' + ratelimitbysize-query-cost: + - '32004' + ratelimitbysize-remaining: + - '1807975' + ratelimitbysize-reset: + - '50' + x-envoy-upstream-service-time: + - '1120' + x-kong-proxy-latency: + - '0' + x-kong-request-id: + - 937bb827f32a5d4d4f16e3725d08844b + x-kong-upstream-latency: + - '1121' + x-ratelimitbysize-limit-minute: + - '2000000' + x-ratelimitbysize-limit-month: + - '10000000000' + x-ratelimitbysize-remaining-minute: + - '1807975' + x-ratelimitbysize-remaining-month: + - '9998623611' + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_few_shot_prompt.yaml b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_few_shot_prompt.yaml new file mode 100644 index 00000000..0697773f --- /dev/null +++ b/tests/chat_model/cassettes/test_mistral_chat_model/test_mistral_chat_model_few_shot_prompt.yaml @@ -0,0 +1,108 @@ +interactions: +- request: + body: '{"messages": [{"role": "system", "content": "You are a movie buff."}, {"role": + "user", "content": "What is your favorite quote from Harry Potter?"}, {"role": + "assistant", "content": null, "tool_calls": [{"id": "27bd6b9a1", "type": "function", + "function": {"name": "return_quote", "arguments": "{\"quote\":\"It does not + do to dwell on dreams and forget to live.\",\"character\":\"Albus Dumbledore\"}"}}]}, + {"role": "tool", "tool_call_id": "27bd6b9a1", "content": "null"}, {"role": "assistant", + "content": "."}, {"role": "user", "content": "What is your favorite quote from + {movie}?"}], "model": "mistral-large-latest", "stream": true, "tool_choice": + "any", "tools": [{"type": "function", "function": {"name": "return_quote", "parameters": + {"properties": {"quote": {"title": "Quote", "type": "string"}, "character": + {"title": "Character", "type": "string"}}, "required": ["quote", "character"], + "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '914' + content-type: + - application/json + host: + - api.mistral.ai + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.mistral.ai/v1/chat/completions + response: + body: + string: 'data: {"id":"00abc8332085445f88ddce4ec77de843","object":"chat.completion.chunk","created":1731829455,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]} + + + data: {"id":"00abc8332085445f88ddce4ec77de843","object":"chat.completion.chunk","created":1731829455,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"tool_calls":[{"id":"gSYj4zz7O","function":{"name":"return_quote","arguments":"{\"quote\": + \"It does not do to dwell on dreams and forget to live.\", \"character\": + \"Albus Dumbledore\"}"}}]},"finish_reason":"tool_calls"}],"usage":{"prompt_tokens":192,"total_tokens":234,"completion_tokens":42}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3e182ffb907ae2-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:44:17 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + ratelimitbysize-limit: + - '2000000' + ratelimitbysize-query-cost: + - '32031' + ratelimitbysize-remaining: + - '1711897' + ratelimitbysize-reset: + - '45' + x-envoy-upstream-service-time: + - '2026' + x-kong-proxy-latency: + - '0' + x-kong-request-id: + - 97f37a4e9349b755cb74e14ceda29640 + x-kong-upstream-latency: + - '2027' + x-ratelimitbysize-limit-minute: + - '2000000' + x-ratelimitbysize-limit-month: + - '10000000000' + x-ratelimitbysize-remaining-minute: + - '1711897' + x-ratelimitbysize-remaining-month: + - '9998527533' + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_acomplete_raises_tool_schema_parse_error.yaml b/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_acomplete_raises_tool_schema_parse_error.yaml new file mode 100644 index 00000000..5b4fea9a --- /dev/null +++ b/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_acomplete_raises_tool_schema_parse_error.yaml @@ -0,0 +1,116 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Return a test value of 42."}], + "model": "gpt-4o", "parallel_tool_calls": false, "stream": true, "stream_options": + {"include_usage": true}, "tool_choice": {"type": "function", "function": {"name": + "return_test"}}, "tools": [{"type": "function", "function": {"name": "return_test", + "parameters": {"properties": {"value": {"title": "Value", "type": "integer"}}, + "required": ["value"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '446' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9ULw8UzbjiefQ8bhql4E4GZbEjS","object":"chat.completion.chunk","created":1731749677,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_pVGhHWwWWjjDcHF4Pz0VE6WK","type":"function","function":{"name":"return_test","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9ULw8UzbjiefQ8bhql4E4GZbEjS","object":"chat.completion.chunk","created":1731749677,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9ULw8UzbjiefQ8bhql4E4GZbEjS","object":"chat.completion.chunk","created":1731749677,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"value"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9ULw8UzbjiefQ8bhql4E4GZbEjS","object":"chat.completion.chunk","created":1731749677,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9ULw8UzbjiefQ8bhql4E4GZbEjS","object":"chat.completion.chunk","created":1731749677,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"42"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9ULw8UzbjiefQ8bhql4E4GZbEjS","object":"chat.completion.chunk","created":1731749677,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"}"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9ULw8UzbjiefQ8bhql4E4GZbEjS","object":"chat.completion.chunk","created":1731749677,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9ULw8UzbjiefQ8bhql4E4GZbEjS","object":"chat.completion.chunk","created":1731749677,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[],"usage":{"prompt_tokens":57,"completion_tokens":5,"total_tokens":62,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367c7b1f346462-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:37 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '151' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29976' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 48ms + x-request-id: + - req_d428c8cdbb5bccef232591482c226a78 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_acomplete_usage.yaml b/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_acomplete_usage.yaml new file mode 100644 index 00000000..202c8a2f --- /dev/null +++ b/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_acomplete_usage.yaml @@ -0,0 +1,130 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Say hello!"}], "model": "gpt-4o", + "stream": true, "stream_options": {"include_usage": true}}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '135' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UKFTz7uIVlWIVdtcPss42ipz7i","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UKFTz7uIVlWIVdtcPss42ipz7i","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UKFTz7uIVlWIVdtcPss42ipz7i","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"!"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UKFTz7uIVlWIVdtcPss42ipz7i","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + How"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UKFTz7uIVlWIVdtcPss42ipz7i","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + can"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UKFTz7uIVlWIVdtcPss42ipz7i","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + I"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UKFTz7uIVlWIVdtcPss42ipz7i","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + assist"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UKFTz7uIVlWIVdtcPss42ipz7i","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + you"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UKFTz7uIVlWIVdtcPss42ipz7i","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + today"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UKFTz7uIVlWIVdtcPss42ipz7i","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"?"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UKFTz7uIVlWIVdtcPss42ipz7i","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UKFTz7uIVlWIVdtcPss42ipz7i","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[],"usage":{"prompt_tokens":10,"completion_tokens":9,"total_tokens":19,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367c74bfc6965b-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:36 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '157' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29980' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 40ms + x-request-id: + - req_575fb1c24ce758d1816c9ac3fa710b7d + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_acomplete_usage_structured_output.yaml b/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_acomplete_usage_structured_output.yaml new file mode 100644 index 00000000..8059f155 --- /dev/null +++ b/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_acomplete_usage_structured_output.yaml @@ -0,0 +1,140 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Count to 5"}], "model": "gpt-4o", + "parallel_tool_calls": false, "stream": true, "stream_options": {"include_usage": + true}, "tool_choice": {"type": "function", "function": {"name": "return_list_of_int"}}, + "tools": [{"type": "function", "function": {"name": "return_list_of_int", "parameters": + {"properties": {"value": {"items": {"type": "integer"}, "title": "Value", "type": + "array"}}, "required": ["value"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '472' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UKqKqsm0i36F0TMqObkkSsdsrP","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_eyfgECjXyLrZpUlrjEHpfDqH","type":"function","function":{"name":"return_list_of_int","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UKqKqsm0i36F0TMqObkkSsdsrP","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UKqKqsm0i36F0TMqObkkSsdsrP","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"value"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UKqKqsm0i36F0TMqObkkSsdsrP","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":["}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UKqKqsm0i36F0TMqObkkSsdsrP","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"1"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UKqKqsm0i36F0TMqObkkSsdsrP","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":","}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UKqKqsm0i36F0TMqObkkSsdsrP","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"2"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UKqKqsm0i36F0TMqObkkSsdsrP","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":","}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UKqKqsm0i36F0TMqObkkSsdsrP","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"3"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UKqKqsm0i36F0TMqObkkSsdsrP","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":","}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UKqKqsm0i36F0TMqObkkSsdsrP","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"4"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UKqKqsm0i36F0TMqObkkSsdsrP","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":","}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UKqKqsm0i36F0TMqObkkSsdsrP","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"5"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UKqKqsm0i36F0TMqObkkSsdsrP","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"]}"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UKqKqsm0i36F0TMqObkkSsdsrP","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UKqKqsm0i36F0TMqObkkSsdsrP","object":"chat.completion.chunk","created":1731749676,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[],"usage":{"prompt_tokens":57,"completion_tokens":13,"total_tokens":70,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367c77ab0cfaae-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:37 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '233' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29980' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 40ms + x-request-id: + - req_42f01aa2fd0bfdf389c0e01c68b148c3 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_api_key.yaml b/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_api_key.yaml new file mode 100644 index 00000000..c396ace1 --- /dev/null +++ b/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_api_key.yaml @@ -0,0 +1,130 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Say hello!"}], "model": "gpt-4o", + "stream": true, "stream_options": {"include_usage": true}}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '135' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UFcBsaey0y8IRFLp3AKYDZdOyo","object":"chat.completion.chunk","created":1731749671,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UFcBsaey0y8IRFLp3AKYDZdOyo","object":"chat.completion.chunk","created":1731749671,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UFcBsaey0y8IRFLp3AKYDZdOyo","object":"chat.completion.chunk","created":1731749671,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":"!"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UFcBsaey0y8IRFLp3AKYDZdOyo","object":"chat.completion.chunk","created":1731749671,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + How"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UFcBsaey0y8IRFLp3AKYDZdOyo","object":"chat.completion.chunk","created":1731749671,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + can"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UFcBsaey0y8IRFLp3AKYDZdOyo","object":"chat.completion.chunk","created":1731749671,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + I"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UFcBsaey0y8IRFLp3AKYDZdOyo","object":"chat.completion.chunk","created":1731749671,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + assist"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UFcBsaey0y8IRFLp3AKYDZdOyo","object":"chat.completion.chunk","created":1731749671,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + you"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UFcBsaey0y8IRFLp3AKYDZdOyo","object":"chat.completion.chunk","created":1731749671,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":" + today"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UFcBsaey0y8IRFLp3AKYDZdOyo","object":"chat.completion.chunk","created":1731749671,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{"content":"?"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UFcBsaey0y8IRFLp3AKYDZdOyo","object":"chat.completion.chunk","created":1731749671,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UFcBsaey0y8IRFLp3AKYDZdOyo","object":"chat.completion.chunk","created":1731749671,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_45cf54deae","choices":[],"usage":{"prompt_tokens":10,"completion_tokens":9,"total_tokens":19,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367c552e3cfa82-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:31 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '212' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29980' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 40ms + x-request-id: + - req_6d145f2208d9359eede8308fbda57f2c + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_complete_base_url.yaml b/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_complete_base_url.yaml new file mode 100644 index 00000000..4faeb0cb --- /dev/null +++ b/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_complete_base_url.yaml @@ -0,0 +1,130 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Say hello!"}], "model": "gpt-4o", + "stream": true, "stream_options": {"include_usage": true}}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '135' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UFzbPBMIgbNnSkc0qLvlU3j1Or","object":"chat.completion.chunk","created":1731749671,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UFzbPBMIgbNnSkc0qLvlU3j1Or","object":"chat.completion.chunk","created":1731749671,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UFzbPBMIgbNnSkc0qLvlU3j1Or","object":"chat.completion.chunk","created":1731749671,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":"!"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UFzbPBMIgbNnSkc0qLvlU3j1Or","object":"chat.completion.chunk","created":1731749671,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":" + How"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UFzbPBMIgbNnSkc0qLvlU3j1Or","object":"chat.completion.chunk","created":1731749671,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":" + can"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UFzbPBMIgbNnSkc0qLvlU3j1Or","object":"chat.completion.chunk","created":1731749671,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":" + I"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UFzbPBMIgbNnSkc0qLvlU3j1Or","object":"chat.completion.chunk","created":1731749671,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":" + assist"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UFzbPBMIgbNnSkc0qLvlU3j1Or","object":"chat.completion.chunk","created":1731749671,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":" + you"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UFzbPBMIgbNnSkc0qLvlU3j1Or","object":"chat.completion.chunk","created":1731749671,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":" + today"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UFzbPBMIgbNnSkc0qLvlU3j1Or","object":"chat.completion.chunk","created":1731749671,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":"?"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UFzbPBMIgbNnSkc0qLvlU3j1Or","object":"chat.completion.chunk","created":1731749671,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UFzbPBMIgbNnSkc0qLvlU3j1Or","object":"chat.completion.chunk","created":1731749671,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[],"usage":{"prompt_tokens":10,"completion_tokens":9,"total_tokens":19,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367c580e081828-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:31 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '241' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29980' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 40ms + x-request-id: + - req_72391afae358cecbf393565564419521 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_complete_function_call_openai_strict.yaml b/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_complete_function_call_openai_strict.yaml new file mode 100644 index 00000000..2802352b --- /dev/null +++ b/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_complete_function_call_openai_strict.yaml @@ -0,0 +1,130 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Use the tool to sum 1 and 2"}], + "model": "gpt-4o", "parallel_tool_calls": false, "stream": true, "stream_options": + {"include_usage": true}, "tool_choice": {"type": "function", "function": {"name": + "plus"}}, "tools": [{"type": "function", "function": {"name": "plus", "parameters": + {"properties": {"a": {"title": "A", "type": "integer"}, "b": {"title": "B", + "type": "integer"}}, "required": ["a", "b"], "title": "FuncModel", "type": "object", + "additionalProperties": false}, "description": "Sum two numbers.", "strict": + true}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '570' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UHwljw3ZaJwEwbBETGfatPqgVl","object":"chat.completion.chunk","created":1731749673,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_1XGyax6Ww7s0YMqhwsUUTVVA","type":"function","function":{"name":"plus","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UHwljw3ZaJwEwbBETGfatPqgVl","object":"chat.completion.chunk","created":1731749673,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UHwljw3ZaJwEwbBETGfatPqgVl","object":"chat.completion.chunk","created":1731749673,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"a"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UHwljw3ZaJwEwbBETGfatPqgVl","object":"chat.completion.chunk","created":1731749673,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UHwljw3ZaJwEwbBETGfatPqgVl","object":"chat.completion.chunk","created":1731749673,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"1"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UHwljw3ZaJwEwbBETGfatPqgVl","object":"chat.completion.chunk","created":1731749673,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":",\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UHwljw3ZaJwEwbBETGfatPqgVl","object":"chat.completion.chunk","created":1731749673,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"b"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UHwljw3ZaJwEwbBETGfatPqgVl","object":"chat.completion.chunk","created":1731749673,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UHwljw3ZaJwEwbBETGfatPqgVl","object":"chat.completion.chunk","created":1731749673,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"2"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UHwljw3ZaJwEwbBETGfatPqgVl","object":"chat.completion.chunk","created":1731749673,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"}"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UHwljw3ZaJwEwbBETGfatPqgVl","object":"chat.completion.chunk","created":1731749673,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UHwljw3ZaJwEwbBETGfatPqgVl","object":"chat.completion.chunk","created":1731749673,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[],"usage":{"prompt_tokens":71,"completion_tokens":9,"total_tokens":80,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-RAY: + - 8e367c653dba67a5-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:34 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-processing-ms: + - '164' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29976' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 48ms + x-request-id: + - req_2f0ff8f45cadeb22d747b5232db09fa8 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_complete_no_structured_output_error.yaml b/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_complete_no_structured_output_error.yaml new file mode 100644 index 00000000..21e48222 --- /dev/null +++ b/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_complete_no_structured_output_error.yaml @@ -0,0 +1,118 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Tell me a short joke. Return + a string, not a tool call."}], "model": "gpt-4o", "parallel_tool_calls": false, + "stream": true, "stream_options": {"include_usage": true}, "tool_choice": "required", + "tools": [{"type": "function", "function": {"name": "return_int", "parameters": + {"properties": {"value": {"title": "Value", "type": "integer"}}, "required": + ["value"], "type": "object"}}}, {"type": "function", "function": {"name": "return_bool", + "parameters": {"properties": {"value": {"title": "Value", "type": "boolean"}}, + "required": ["value"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '607' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UJWYTCv689EvXOaKy1AaU5Vl3w","object":"chat.completion.chunk","created":1731749675,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_qwHVJFA6Z9ocj2SDDVF0awdy","type":"function","function":{"name":"return_bool","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UJWYTCv689EvXOaKy1AaU5Vl3w","object":"chat.completion.chunk","created":1731749675,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UJWYTCv689EvXOaKy1AaU5Vl3w","object":"chat.completion.chunk","created":1731749675,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"value"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UJWYTCv689EvXOaKy1AaU5Vl3w","object":"chat.completion.chunk","created":1731749675,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UJWYTCv689EvXOaKy1AaU5Vl3w","object":"chat.completion.chunk","created":1731749675,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"true"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UJWYTCv689EvXOaKy1AaU5Vl3w","object":"chat.completion.chunk","created":1731749675,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"}"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UJWYTCv689EvXOaKy1AaU5Vl3w","object":"chat.completion.chunk","created":1731749675,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"tool_calls"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UJWYTCv689EvXOaKy1AaU5Vl3w","object":"chat.completion.chunk","created":1731749675,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[],"usage":{"prompt_tokens":72,"completion_tokens":14,"total_tokens":86,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367c6d6e9a67a4-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:35 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '371' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29969' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 62ms + x-request-id: + - req_61e9347500ec55933372d3ddbe6a84cf + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_complete_pydantic_model_openai_strict.yaml b/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_complete_pydantic_model_openai_strict.yaml new file mode 100644 index 00000000..85f28042 --- /dev/null +++ b/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_complete_pydantic_model_openai_strict.yaml @@ -0,0 +1,133 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "What is the capital of Ireland?"}], + "model": "gpt-4o", "parallel_tool_calls": false, "stream": true, "stream_options": + {"include_usage": true}, "tool_choice": {"type": "function", "function": {"name": + "return_capitalcity"}}, "tools": [{"type": "function", "function": {"name": + "return_capitalcity", "parameters": {"properties": {"capital": {"title": "Capital", + "type": "string"}, "country": {"title": "Country", "type": "string"}}, "required": + ["capital", "country"], "title": "CapitalCity", "type": "object", "additionalProperties": + false}, "strict": true}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '603' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UHoRnnJLKmPFsCZA3ejOGsndJS","object":"chat.completion.chunk","created":1731749673,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_vmRc2KiHq7QOgYCNFEqDlRl0","type":"function","function":{"name":"return_capitalcity","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UHoRnnJLKmPFsCZA3ejOGsndJS","object":"chat.completion.chunk","created":1731749673,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UHoRnnJLKmPFsCZA3ejOGsndJS","object":"chat.completion.chunk","created":1731749673,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"capital"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UHoRnnJLKmPFsCZA3ejOGsndJS","object":"chat.completion.chunk","created":1731749673,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UHoRnnJLKmPFsCZA3ejOGsndJS","object":"chat.completion.chunk","created":1731749673,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"D"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UHoRnnJLKmPFsCZA3ejOGsndJS","object":"chat.completion.chunk","created":1731749673,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"ublin"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UHoRnnJLKmPFsCZA3ejOGsndJS","object":"chat.completion.chunk","created":1731749673,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\",\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UHoRnnJLKmPFsCZA3ejOGsndJS","object":"chat.completion.chunk","created":1731749673,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"country"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UHoRnnJLKmPFsCZA3ejOGsndJS","object":"chat.completion.chunk","created":1731749673,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UHoRnnJLKmPFsCZA3ejOGsndJS","object":"chat.completion.chunk","created":1731749673,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Ireland"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UHoRnnJLKmPFsCZA3ejOGsndJS","object":"chat.completion.chunk","created":1731749673,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"}"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UHoRnnJLKmPFsCZA3ejOGsndJS","object":"chat.completion.chunk","created":1731749673,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UHoRnnJLKmPFsCZA3ejOGsndJS","object":"chat.completion.chunk","created":1731749673,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[],"usage":{"prompt_tokens":70,"completion_tokens":10,"total_tokens":80,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367c611ddf1701-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:33 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '261' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29975' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 50ms + x-request-id: + - req_f74f2f37b1d2868efce46e218caee351 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_complete_raises_tool_schema_parse_error.yaml b/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_complete_raises_tool_schema_parse_error.yaml new file mode 100644 index 00000000..088f24de --- /dev/null +++ b/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_complete_raises_tool_schema_parse_error.yaml @@ -0,0 +1,116 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Return a test value of 42."}], + "model": "gpt-4o", "parallel_tool_calls": false, "stream": true, "stream_options": + {"include_usage": true}, "tool_choice": {"type": "function", "function": {"name": + "return_test"}}, "tools": [{"type": "function", "function": {"name": "return_test", + "parameters": {"properties": {"value": {"title": "Value", "type": "integer"}}, + "required": ["value"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '446' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UJ7ScqIMaEld4HQh7O98UrX9IR","object":"chat.completion.chunk","created":1731749675,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_OvO28CvvJzc0nANEr3lW4dkq","type":"function","function":{"name":"return_test","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UJ7ScqIMaEld4HQh7O98UrX9IR","object":"chat.completion.chunk","created":1731749675,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UJ7ScqIMaEld4HQh7O98UrX9IR","object":"chat.completion.chunk","created":1731749675,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"value"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UJ7ScqIMaEld4HQh7O98UrX9IR","object":"chat.completion.chunk","created":1731749675,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UJ7ScqIMaEld4HQh7O98UrX9IR","object":"chat.completion.chunk","created":1731749675,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"42"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UJ7ScqIMaEld4HQh7O98UrX9IR","object":"chat.completion.chunk","created":1731749675,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"}"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UJ7ScqIMaEld4HQh7O98UrX9IR","object":"chat.completion.chunk","created":1731749675,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UJ7ScqIMaEld4HQh7O98UrX9IR","object":"chat.completion.chunk","created":1731749675,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[],"usage":{"prompt_tokens":57,"completion_tokens":5,"total_tokens":62,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367c712968fb44-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:36 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '280' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29976' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 48ms + x-request-id: + - req_c626dfaf0ee46915b6bb61fbbb9566cc + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_complete_seed.yaml b/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_complete_seed.yaml new file mode 100644 index 00000000..cbffbba7 --- /dev/null +++ b/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_complete_seed.yaml @@ -0,0 +1,261 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Say hello!"}], "model": "gpt-4o", + "seed": 42, "stream": true, "stream_options": {"include_usage": true}}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '147' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UGukAAdZ075eXzeSrnlKYuMmkQ","object":"chat.completion.chunk","created":1731749672,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UGukAAdZ075eXzeSrnlKYuMmkQ","object":"chat.completion.chunk","created":1731749672,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UGukAAdZ075eXzeSrnlKYuMmkQ","object":"chat.completion.chunk","created":1731749672,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{"content":"!"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UGukAAdZ075eXzeSrnlKYuMmkQ","object":"chat.completion.chunk","created":1731749672,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{"content":" + How"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UGukAAdZ075eXzeSrnlKYuMmkQ","object":"chat.completion.chunk","created":1731749672,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{"content":" + can"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UGukAAdZ075eXzeSrnlKYuMmkQ","object":"chat.completion.chunk","created":1731749672,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{"content":" + I"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UGukAAdZ075eXzeSrnlKYuMmkQ","object":"chat.completion.chunk","created":1731749672,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{"content":" + assist"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UGukAAdZ075eXzeSrnlKYuMmkQ","object":"chat.completion.chunk","created":1731749672,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{"content":" + you"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UGukAAdZ075eXzeSrnlKYuMmkQ","object":"chat.completion.chunk","created":1731749672,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{"content":" + today"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UGukAAdZ075eXzeSrnlKYuMmkQ","object":"chat.completion.chunk","created":1731749672,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{"content":"?"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UGukAAdZ075eXzeSrnlKYuMmkQ","object":"chat.completion.chunk","created":1731749672,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UGukAAdZ075eXzeSrnlKYuMmkQ","object":"chat.completion.chunk","created":1731749672,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7e2833e5f9","choices":[],"usage":{"prompt_tokens":10,"completion_tokens":9,"total_tokens":19,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-RAY: + - 8e367c5b6b4667dd-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:32 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-processing-ms: + - '246' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29980' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 40ms + x-request-id: + - req_6fef64015a4136ed87ef46c1c5a35ae1 + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"role": "user", "content": "Say hello!"}], "model": "gpt-4o", + "seed": 42, "stream": true, "stream_options": {"include_usage": true}}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '147' + content-type: + - application/json + cookie: + - __cf_bm=jrgARAKhr6Ybk1xKeZOrgYjbZf8EkhTCUdf.vGzzm8Q-1731749672-1.0.1.1-UuZ21jZ7yn85outcBujI3hSUWODVup5HoNOWeB26KcvUbzISWMytj7v6Eg_ObxADiAd0WtwxHI3c5pdFobJC.A; + _cfuvid=dIMLnTMIBFd2O7nr7y2zSc5TDQDc8Uiq.Q6Uea4dClU-1731749672507-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UGqIDiDlLrdJZZhhb8Ce21Pzbo","object":"chat.completion.chunk","created":1731749672,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UGqIDiDlLrdJZZhhb8Ce21Pzbo","object":"chat.completion.chunk","created":1731749672,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UGqIDiDlLrdJZZhhb8Ce21Pzbo","object":"chat.completion.chunk","created":1731749672,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"content":"!"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UGqIDiDlLrdJZZhhb8Ce21Pzbo","object":"chat.completion.chunk","created":1731749672,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"content":" + How"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UGqIDiDlLrdJZZhhb8Ce21Pzbo","object":"chat.completion.chunk","created":1731749672,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"content":" + can"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UGqIDiDlLrdJZZhhb8Ce21Pzbo","object":"chat.completion.chunk","created":1731749672,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"content":" + I"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UGqIDiDlLrdJZZhhb8Ce21Pzbo","object":"chat.completion.chunk","created":1731749672,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"content":" + assist"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UGqIDiDlLrdJZZhhb8Ce21Pzbo","object":"chat.completion.chunk","created":1731749672,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"content":" + you"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UGqIDiDlLrdJZZhhb8Ce21Pzbo","object":"chat.completion.chunk","created":1731749672,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"content":" + today"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UGqIDiDlLrdJZZhhb8Ce21Pzbo","object":"chat.completion.chunk","created":1731749672,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{"content":"?"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UGqIDiDlLrdJZZhhb8Ce21Pzbo","object":"chat.completion.chunk","created":1731749672,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UGqIDiDlLrdJZZhhb8Ce21Pzbo","object":"chat.completion.chunk","created":1731749672,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_a7d06e42a7","choices":[],"usage":{"prompt_tokens":10,"completion_tokens":9,"total_tokens":19,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367c5e2cfb67dd-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:32 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '126' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29980' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 40ms + x-request-id: + - req_dda7c61d61ce317ef42e28ac0a01330a + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_complete_usage.yaml b/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_complete_usage.yaml new file mode 100644 index 00000000..33e2a4d6 --- /dev/null +++ b/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_complete_usage.yaml @@ -0,0 +1,130 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Say hello!"}], "model": "gpt-4o", + "stream": true, "stream_options": {"include_usage": true}}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '135' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UIKiI6NBXdUCLudJFiEJqK9Hld","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UIKiI6NBXdUCLudJFiEJqK9Hld","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UIKiI6NBXdUCLudJFiEJqK9Hld","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"!"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UIKiI6NBXdUCLudJFiEJqK9Hld","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + How"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UIKiI6NBXdUCLudJFiEJqK9Hld","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + can"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UIKiI6NBXdUCLudJFiEJqK9Hld","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + I"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UIKiI6NBXdUCLudJFiEJqK9Hld","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + assist"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UIKiI6NBXdUCLudJFiEJqK9Hld","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + you"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UIKiI6NBXdUCLudJFiEJqK9Hld","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":" + today"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UIKiI6NBXdUCLudJFiEJqK9Hld","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{"content":"?"},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UIKiI6NBXdUCLudJFiEJqK9Hld","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UIKiI6NBXdUCLudJFiEJqK9Hld","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_159d8341cc","choices":[],"usage":{"prompt_tokens":10,"completion_tokens":9,"total_tokens":19,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367c67eefe9642-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:34 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '126' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29980' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 40ms + x-request-id: + - req_3ad67611947821efae017c4b1dad63fe + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_complete_usage_structured_output.yaml b/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_complete_usage_structured_output.yaml new file mode 100644 index 00000000..8f119df1 --- /dev/null +++ b/tests/chat_model/cassettes/test_openai_chat_model/test_openai_chat_model_complete_usage_structured_output.yaml @@ -0,0 +1,140 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Count to 5"}], "model": "gpt-4o", + "parallel_tool_calls": false, "stream": true, "stream_options": {"include_usage": + true}, "tool_choice": {"type": "function", "function": {"name": "return_list_of_int"}}, + "tools": [{"type": "function", "function": {"name": "return_list_of_int", "parameters": + {"properties": {"value": {"items": {"type": "integer"}, "title": "Value", "type": + "array"}}, "required": ["value"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '472' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UIQ1xvMMLLTUvNhJj3yWyzqzyq","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_831e067d82","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_sAyoZgSoEjkTm1ahQEljdEey","type":"function","function":{"name":"return_list_of_int","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UIQ1xvMMLLTUvNhJj3yWyzqzyq","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_831e067d82","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UIQ1xvMMLLTUvNhJj3yWyzqzyq","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_831e067d82","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"value"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UIQ1xvMMLLTUvNhJj3yWyzqzyq","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_831e067d82","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":["}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UIQ1xvMMLLTUvNhJj3yWyzqzyq","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_831e067d82","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"1"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UIQ1xvMMLLTUvNhJj3yWyzqzyq","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_831e067d82","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":","}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UIQ1xvMMLLTUvNhJj3yWyzqzyq","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_831e067d82","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"2"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UIQ1xvMMLLTUvNhJj3yWyzqzyq","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_831e067d82","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":","}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UIQ1xvMMLLTUvNhJj3yWyzqzyq","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_831e067d82","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"3"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UIQ1xvMMLLTUvNhJj3yWyzqzyq","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_831e067d82","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":","}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UIQ1xvMMLLTUvNhJj3yWyzqzyq","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_831e067d82","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"4"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UIQ1xvMMLLTUvNhJj3yWyzqzyq","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_831e067d82","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":","}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UIQ1xvMMLLTUvNhJj3yWyzqzyq","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_831e067d82","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"5"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UIQ1xvMMLLTUvNhJj3yWyzqzyq","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_831e067d82","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"]}"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UIQ1xvMMLLTUvNhJj3yWyzqzyq","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_831e067d82","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UIQ1xvMMLLTUvNhJj3yWyzqzyq","object":"chat.completion.chunk","created":1731749674,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_831e067d82","choices":[],"usage":{"prompt_tokens":57,"completion_tokens":13,"total_tokens":70,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367c6a58ab16f9-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:34 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '179' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '500' + x-ratelimit-limit-tokens: + - '30000' + x-ratelimit-remaining-requests: + - '499' + x-ratelimit-remaining-tokens: + - '29980' + x-ratelimit-reset-requests: + - 120ms + x-ratelimit-reset-tokens: + - 40ms + x-request-id: + - req_882f93dacaf13ac848b9529a66243bb7 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_retry_chat_model/test_retry_chat_model_acomplete_anthropic.yaml b/tests/chat_model/cassettes/test_retry_chat_model/test_retry_chat_model_acomplete_anthropic.yaml new file mode 100644 index 00000000..a35f133f --- /dev/null +++ b/tests/chat_model/cassettes/test_retry_chat_model/test_retry_chat_model_acomplete_anthropic.yaml @@ -0,0 +1,257 @@ +interactions: +- request: + body: '{"max_tokens": 1024, "messages": [{"role": "user", "content": [{"type": + "text", "text": "Return a country."}]}], "model": "claude-3-haiku-20240307", + "tools": [{"name": "return_country", "description": "", "input_schema": {"properties": + {"name": {"title": "Name", "type": "string"}}, "required": ["name"], "type": + "object"}}], "tool_choice": {"type": "tool", "name": "return_country"}, "stream": + true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '400' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - AsyncAnthropic/Python 0.39.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.39.0 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + x-stainless-stream-helper: + - messages + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_01VZ98VHjWT3SjSLzFEZY5fS","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":420,"output_tokens":20}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_01NV5SbdweQ2iUmb2HfSEwgJ","name":"return_country","input":{}} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\"name\": + \"Un"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"ited + S"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"tates\"}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":34} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3692313b5ccf2f-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:49:27 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_011Q394MNsaPdRbt3M9DRxKa + via: + - 1.1 google + status: + code: 200 + message: OK +- request: + body: '{"max_tokens": 1024, "messages": [{"role": "user", "content": [{"type": + "text", "text": "Return a country."}]}, {"role": "assistant", "content": [{"id": + "toolu_01NV5SbdweQ2iUmb2HfSEwgJ", "input": {"name": "United States"}, "name": + "return_country", "type": "tool_use"}]}, {"role": "user", "content": [{"type": + "tool_result", "tool_use_id": "toolu_01NV5SbdweQ2iUmb2HfSEwgJ", "content": "1 + validation error for Country\nname\n Value error, Country must be Ireland. + [type=value_error, input_value=''United States'', input_type=str]\n For further + information visit https://errors.pydantic.dev/2.9/v/value_error"}]}], "model": + "claude-3-haiku-20240307", "tools": [{"name": "return_country", "description": + "", "input_schema": {"properties": {"name": {"title": "Name", "type": "string"}}, + "required": ["name"], "type": "object"}}], "tool_choice": {"type": "tool", "name": + "return_country"}, "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '902' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - AsyncAnthropic/Python 0.39.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.39.0 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + x-stainless-stream-helper: + - messages + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_01GJwKwqyhTjf7ojYQkjq9E3","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":550,"output_tokens":20}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_018Z12VXTMhnvbNNvrEJetW2","name":"return_country","input":{}} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\"name\":"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":" + \"Ir"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"eland\"}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":33} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e369235aa3ccf2f-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:49:28 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_01H7dwLpn8fgBASN1nGRbSmp + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_retry_chat_model/test_retry_chat_model_acomplete_litellm_openai.yaml b/tests/chat_model/cassettes/test_retry_chat_model/test_retry_chat_model_acomplete_litellm_openai.yaml new file mode 100644 index 00000000..87b11758 --- /dev/null +++ b/tests/chat_model/cassettes/test_retry_chat_model/test_retry_chat_model_acomplete_litellm_openai.yaml @@ -0,0 +1,232 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Return a country."}], "model": + "gpt-4o-mini", "stream": true, "tool_choice": {"type": "function", "function": + {"name": "return_country"}}, "tools": [{"type": "function", "function": {"name": + "return_country", "parameters": {"properties": {"name": {"title": "Name", "type": + "string"}}, "required": ["name"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '371' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '1' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AUTwhFJhWQohwNWkFZ4g3gdxmE7bs","object":"chat.completion.chunk","created":1731828315,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_ZsPgGThV4XYMbjLcJjngBbUb","type":"function","function":{"name":"return_country","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwhFJhWQohwNWkFZ4g3gdxmE7bs","object":"chat.completion.chunk","created":1731828315,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwhFJhWQohwNWkFZ4g3gdxmE7bs","object":"chat.completion.chunk","created":1731828315,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"name"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwhFJhWQohwNWkFZ4g3gdxmE7bs","object":"chat.completion.chunk","created":1731828315,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwhFJhWQohwNWkFZ4g3gdxmE7bs","object":"chat.completion.chunk","created":1731828315,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Canada"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwhFJhWQohwNWkFZ4g3gdxmE7bs","object":"chat.completion.chunk","created":1731828315,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"}"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwhFJhWQohwNWkFZ4g3gdxmE7bs","object":"chat.completion.chunk","created":1731828315,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3dfc5abc25645e-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:25:15 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '159' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '10000' + x-ratelimit-limit-tokens: + - '200000' + x-ratelimit-remaining-requests: + - '9997' + x-ratelimit-remaining-tokens: + - '199978' + x-ratelimit-reset-requests: + - 24.784s + x-ratelimit-reset-tokens: + - 6ms + x-request-id: + - req_f8598a9c42d753bba944e8e4b8f405e6 + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"role": "user", "content": "Return a country."}, {"role": + "assistant", "content": null, "tool_calls": [{"id": "call_ZsPgGThV4XYMbjLcJjngBbUb", + "type": "function", "function": {"name": "return_country", "arguments": "{\"name\":\"Canada\"}"}}]}, + {"role": "tool", "tool_call_id": "call_ZsPgGThV4XYMbjLcJjngBbUb", "content": + "1 validation error for Country\nname\n Value error, Country must be Ireland. + [type=value_error, input_value=''Canada'', input_type=str]\n For further + information visit https://errors.pydantic.dev/2.9/v/value_error"}], "model": + "gpt-4o-mini", "stream": true, "tool_choice": {"type": "function", "function": + {"name": "return_country"}}, "tools": [{"type": "function", "function": {"name": + "return_country", "parameters": {"properties": {"name": {"title": "Name", "type": + "string"}}, "required": ["name"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '863' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AUTwhAs71Rws8mFQuhs3PAeRXzEn4","object":"chat.completion.chunk","created":1731828315,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_9b78b61c52","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_EMNqE0XUFpOKbZaSHqCbbo9H","type":"function","function":{"name":"return_country","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwhAs71Rws8mFQuhs3PAeRXzEn4","object":"chat.completion.chunk","created":1731828315,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_9b78b61c52","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwhAs71Rws8mFQuhs3PAeRXzEn4","object":"chat.completion.chunk","created":1731828315,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_9b78b61c52","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"name"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwhAs71Rws8mFQuhs3PAeRXzEn4","object":"chat.completion.chunk","created":1731828315,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_9b78b61c52","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwhAs71Rws8mFQuhs3PAeRXzEn4","object":"chat.completion.chunk","created":1731828315,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_9b78b61c52","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Ireland"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwhAs71Rws8mFQuhs3PAeRXzEn4","object":"chat.completion.chunk","created":1731828315,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_9b78b61c52","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"}"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwhAs71Rws8mFQuhs3PAeRXzEn4","object":"chat.completion.chunk","created":1731828315,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_9b78b61c52","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3dfc5cbdaa645e-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:25:15 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '317' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '10000' + x-ratelimit-limit-tokens: + - '200000' + x-ratelimit-remaining-requests: + - '9996' + x-ratelimit-remaining-tokens: + - '199922' + x-ratelimit-reset-requests: + - 33.112s + x-ratelimit-reset-tokens: + - 23ms + x-request-id: + - req_96c61728b21ad535d6bff2a9140a03a4 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_retry_chat_model/test_retry_chat_model_acomplete_openai.yaml b/tests/chat_model/cassettes/test_retry_chat_model/test_retry_chat_model_acomplete_openai.yaml new file mode 100644 index 00000000..2cb44e1e --- /dev/null +++ b/tests/chat_model/cassettes/test_retry_chat_model/test_retry_chat_model_acomplete_openai.yaml @@ -0,0 +1,239 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Return a country."}], "model": + "gpt-4o-mini", "parallel_tool_calls": false, "stream": true, "stream_options": + {"include_usage": true}, "tool_choice": {"type": "function", "function": {"name": + "return_country"}}, "tools": [{"type": "function", "function": {"name": "return_country", + "parameters": {"properties": {"name": {"title": "Name", "type": "string"}}, + "required": ["name"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '444' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UMOiC2xzUTxC9coAuiEVSmvmZM","object":"chat.completion.chunk","created":1731749678,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_lecShqIgNwQziEZxdH7XFzD3","type":"function","function":{"name":"return_country","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UMOiC2xzUTxC9coAuiEVSmvmZM","object":"chat.completion.chunk","created":1731749678,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UMOiC2xzUTxC9coAuiEVSmvmZM","object":"chat.completion.chunk","created":1731749678,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"name"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UMOiC2xzUTxC9coAuiEVSmvmZM","object":"chat.completion.chunk","created":1731749678,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UMOiC2xzUTxC9coAuiEVSmvmZM","object":"chat.completion.chunk","created":1731749678,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Country"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UMOiC2xzUTxC9coAuiEVSmvmZM","object":"chat.completion.chunk","created":1731749678,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"}"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UMOiC2xzUTxC9coAuiEVSmvmZM","object":"chat.completion.chunk","created":1731749678,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UMOiC2xzUTxC9coAuiEVSmvmZM","object":"chat.completion.chunk","created":1731749678,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[],"usage":{"prompt_tokens":53,"completion_tokens":5,"total_tokens":58,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367c81cd98f94b-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:38 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '174' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '10000' + x-ratelimit-limit-tokens: + - '200000' + x-ratelimit-remaining-requests: + - '9997' + x-ratelimit-remaining-tokens: + - '199977' + x-ratelimit-reset-requests: + - 25.227s + x-ratelimit-reset-tokens: + - 6ms + x-request-id: + - req_f5af46a001996c7a4c9db71df1c139eb + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"role": "user", "content": "Return a country."}, {"role": + "assistant", "content": null, "tool_calls": [{"id": "call_lecShqIgNwQziEZxdH7XFzD3", + "type": "function", "function": {"name": "return_country", "arguments": "{\"name\":\"Country\"}"}}]}, + {"role": "tool", "tool_call_id": "call_lecShqIgNwQziEZxdH7XFzD3", "content": + "1 validation error for Country\nname\n Value error, Country must be Ireland. + [type=value_error, input_value=''Country'', input_type=str]\n For further + information visit https://errors.pydantic.dev/2.9/v/value_error"}], "model": + "gpt-4o-mini", "parallel_tool_calls": false, "stream": true, "stream_options": + {"include_usage": true}, "tool_choice": {"type": "function", "function": {"name": + "return_country"}}, "tools": [{"type": "function", "function": {"name": "return_country", + "parameters": {"properties": {"name": {"title": "Name", "type": "string"}}, + "required": ["name"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '938' + content-type: + - application/json + cookie: + - __cf_bm=uHzlI0jqu.pSi2pAubFTNeq6fPmJz5tfvnN5J3Womqk-1731749678-1.0.1.1-u5hCbyxg3fWVYgwkfVYOGMCgd7Cm2OlCCQL98Har0RraLlM_vn7gSoMmFUltlt9qfAzivRRupv6_o5u_OPY9DQ; + _cfuvid=Z2QTUH8.iKU7gXBDaD1tU2oRe6RBI5J31Rmexwn3jgk-1731749678578-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - AsyncOpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - async:asyncio + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UMp4Sg8yg8VBLhdhUOO2XJh0ay","object":"chat.completion.chunk","created":1731749678,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_MWI0aMZXWYCYRPgKpVjpxnZu","type":"function","function":{"name":"return_country","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UMp4Sg8yg8VBLhdhUOO2XJh0ay","object":"chat.completion.chunk","created":1731749678,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UMp4Sg8yg8VBLhdhUOO2XJh0ay","object":"chat.completion.chunk","created":1731749678,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"name"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UMp4Sg8yg8VBLhdhUOO2XJh0ay","object":"chat.completion.chunk","created":1731749678,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UMp4Sg8yg8VBLhdhUOO2XJh0ay","object":"chat.completion.chunk","created":1731749678,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Ireland"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UMp4Sg8yg8VBLhdhUOO2XJh0ay","object":"chat.completion.chunk","created":1731749678,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"}"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UMp4Sg8yg8VBLhdhUOO2XJh0ay","object":"chat.completion.chunk","created":1731749678,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UMp4Sg8yg8VBLhdhUOO2XJh0ay","object":"chat.completion.chunk","created":1731749678,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[],"usage":{"prompt_tokens":125,"completion_tokens":5,"total_tokens":130,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367c839ed0f94b-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:38 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '133' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '10000' + x-ratelimit-limit-tokens: + - '200000' + x-ratelimit-remaining-requests: + - '9996' + x-ratelimit-remaining-tokens: + - '199922' + x-ratelimit-reset-requests: + - 33.576s + x-ratelimit-reset-tokens: + - 23ms + x-request-id: + - req_d2f9147adb2646dfd4f47a12389e0e1e + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_retry_chat_model/test_retry_chat_model_complete_anthropic.yaml b/tests/chat_model/cassettes/test_retry_chat_model/test_retry_chat_model_complete_anthropic.yaml new file mode 100644 index 00000000..adc04aae --- /dev/null +++ b/tests/chat_model/cassettes/test_retry_chat_model/test_retry_chat_model_complete_anthropic.yaml @@ -0,0 +1,260 @@ +interactions: +- request: + body: '{"max_tokens": 1024, "messages": [{"role": "user", "content": [{"type": + "text", "text": "Return a country."}]}], "model": "claude-3-haiku-20240307", + "tools": [{"name": "return_country", "description": "", "input_schema": {"properties": + {"name": {"title": "Name", "type": "string"}}, "required": ["name"], "type": + "object"}}], "tool_choice": {"type": "tool", "name": "return_country"}, "stream": + true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '400' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.39.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.39.0 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + x-stainless-stream-helper: + - messages + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_014GEw9nbwXfpJD1Fe4qRDnM","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":420,"output_tokens":19}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_01K9jd2baj8qyDtK6RufWKAQ","name":"return_country","input":{}} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\"nam"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"e\""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":": + \"Canada\"}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0} + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":33} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3692278c8624f7-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:49:25 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_01WxW4E852S5fmZZH5ZML24K + via: + - 1.1 google + status: + code: 200 + message: OK +- request: + body: '{"max_tokens": 1024, "messages": [{"role": "user", "content": [{"type": + "text", "text": "Return a country."}]}, {"role": "assistant", "content": [{"id": + "toolu_01K9jd2baj8qyDtK6RufWKAQ", "input": {"name": "Canada"}, "name": "return_country", + "type": "tool_use"}]}, {"role": "user", "content": [{"type": "tool_result", + "tool_use_id": "toolu_01K9jd2baj8qyDtK6RufWKAQ", "content": "1 validation error + for Country\nname\n Value error, Country must be Ireland. [type=value_error, + input_value=''Canada'', input_type=str]\n For further information visit https://errors.pydantic.dev/2.9/v/value_error"}]}], + "model": "claude-3-haiku-20240307", "tools": [{"name": "return_country", "description": + "", "input_schema": {"properties": {"name": {"title": "Name", "type": "string"}}, + "required": ["name"], "type": "object"}}], "tool_choice": {"type": "tool", "name": + "return_country"}, "stream": true}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + anthropic-version: + - '2023-06-01' + connection: + - keep-alive + content-length: + - '888' + content-type: + - application/json + host: + - api.anthropic.com + user-agent: + - Anthropic/Python 0.39.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 0.39.0 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + x-stainless-stream-helper: + - messages + method: POST + uri: https://api.anthropic.com/v1/messages + response: + body: + string: 'event: message_start + + data: {"type":"message_start","message":{"id":"msg_01UBgsmCLMpbdkhQ6eoXW7JT","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":548,"output_tokens":20}} } + + + event: content_block_start + + data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_015KjkrGeWBkPA5ftLSiCkJ2","name":"return_country","input":{}} } + + + event: ping + + data: {"type": "ping"} + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\"name\": + "} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"\"Ire"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"lan"} } + + + event: content_block_delta + + data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"d\"}"} } + + + event: content_block_stop + + data: {"type":"content_block_stop","index":0 } + + + event: message_delta + + data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":33} } + + + event: message_stop + + data: {"type":"message_stop" } + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e36922c1e7c24f7-SJC + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:49:26 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Robots-Tag: + - none + request-id: + - req_0142DmjkokQE8MX3zASJ8LrX + via: + - 1.1 google + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_retry_chat_model/test_retry_chat_model_complete_litellm_openai.yaml b/tests/chat_model/cassettes/test_retry_chat_model/test_retry_chat_model_complete_litellm_openai.yaml new file mode 100644 index 00000000..2e0df828 --- /dev/null +++ b/tests/chat_model/cassettes/test_retry_chat_model/test_retry_chat_model_complete_litellm_openai.yaml @@ -0,0 +1,232 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Return a country."}], "model": + "gpt-4o-mini", "stream": true, "tool_choice": {"type": "function", "function": + {"name": "return_country"}}, "tools": [{"type": "function", "function": {"name": + "return_country", "parameters": {"properties": {"name": {"title": "Name", "type": + "string"}}, "required": ["name"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '371' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AUTwgzqd1Ii0FWSoryyv3Vasgy8Eh","object":"chat.completion.chunk","created":1731828314,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_pZHNlBWDbuQmYbidOEik4lYu","type":"function","function":{"name":"return_country","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwgzqd1Ii0FWSoryyv3Vasgy8Eh","object":"chat.completion.chunk","created":1731828314,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwgzqd1Ii0FWSoryyv3Vasgy8Eh","object":"chat.completion.chunk","created":1731828314,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"name"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwgzqd1Ii0FWSoryyv3Vasgy8Eh","object":"chat.completion.chunk","created":1731828314,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwgzqd1Ii0FWSoryyv3Vasgy8Eh","object":"chat.completion.chunk","created":1731828314,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Country"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwgzqd1Ii0FWSoryyv3Vasgy8Eh","object":"chat.completion.chunk","created":1731828314,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"}"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwgzqd1Ii0FWSoryyv3Vasgy8Eh","object":"chat.completion.chunk","created":1731828314,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e3dfc539ebfce84-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:25:14 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '139' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '10000' + x-ratelimit-limit-tokens: + - '200000' + x-ratelimit-remaining-requests: + - '9999' + x-ratelimit-remaining-tokens: + - '199977' + x-ratelimit-reset-requests: + - 8.64s + x-ratelimit-reset-tokens: + - 6ms + x-request-id: + - req_1c81b5404787e8c0c0fa39a40a5add39 + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"role": "user", "content": "Return a country."}, {"role": + "assistant", "content": null, "tool_calls": [{"id": "call_pZHNlBWDbuQmYbidOEik4lYu", + "type": "function", "function": {"name": "return_country", "arguments": "{\"name\":\"Country\"}"}}]}, + {"role": "tool", "tool_call_id": "call_pZHNlBWDbuQmYbidOEik4lYu", "content": + "1 validation error for Country\nname\n Value error, Country must be Ireland. + [type=value_error, input_value=''Country'', input_type=str]\n For further + information visit https://errors.pydantic.dev/2.9/v/value_error"}], "model": + "gpt-4o-mini", "stream": true, "tool_choice": {"type": "function", "function": + {"name": "return_country"}}, "tools": [{"type": "function", "function": {"name": + "return_country", "parameters": {"properties": {"name": {"title": "Name", "type": + "string"}}, "required": ["name"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '865' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-raw-response: + - 'true' + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AUTwgV2Ef5xeCpenezTaQr3IFb6WY","object":"chat.completion.chunk","created":1731828314,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_L9h05hjrL8hqC935gkuWhRXN","type":"function","function":{"name":"return_country","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwgV2Ef5xeCpenezTaQr3IFb6WY","object":"chat.completion.chunk","created":1731828314,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwgV2Ef5xeCpenezTaQr3IFb6WY","object":"chat.completion.chunk","created":1731828314,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"name"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwgV2Ef5xeCpenezTaQr3IFb6WY","object":"chat.completion.chunk","created":1731828314,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwgV2Ef5xeCpenezTaQr3IFb6WY","object":"chat.completion.chunk","created":1731828314,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Ireland"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwgV2Ef5xeCpenezTaQr3IFb6WY","object":"chat.completion.chunk","created":1731828314,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"}"}}]},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-AUTwgV2Ef5xeCpenezTaQr3IFb6WY","object":"chat.completion.chunk","created":1731828314,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-RAY: + - 8e3dfc556828ce84-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sun, 17 Nov 2024 07:25:14 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + cf-cache-status: + - DYNAMIC + openai-processing-ms: + - '130' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '10000' + x-ratelimit-limit-tokens: + - '200000' + x-ratelimit-remaining-requests: + - '9998' + x-ratelimit-remaining-tokens: + - '199922' + x-ratelimit-reset-requests: + - 16.993s + x-ratelimit-reset-tokens: + - 23ms + x-request-id: + - req_cb0ee756dfff6d657b46133aae317271 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/cassettes/test_retry_chat_model/test_retry_chat_model_complete_openai.yaml b/tests/chat_model/cassettes/test_retry_chat_model/test_retry_chat_model_complete_openai.yaml new file mode 100644 index 00000000..eca411bf --- /dev/null +++ b/tests/chat_model/cassettes/test_retry_chat_model/test_retry_chat_model_complete_openai.yaml @@ -0,0 +1,239 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "Return a country."}], "model": + "gpt-4o-mini", "parallel_tool_calls": false, "stream": true, "stream_options": + {"include_usage": true}, "tool_choice": {"type": "function", "function": {"name": + "return_country"}}, "tools": [{"type": "function", "function": {"name": "return_country", + "parameters": {"properties": {"name": {"title": "Name", "type": "string"}}, + "required": ["name"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '444' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9ULww3MRjPquqNLMfEm0wRtvXCp","object":"chat.completion.chunk","created":1731749677,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_ugvIEdaAkA3EwKchrQL6sCtt","type":"function","function":{"name":"return_country","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9ULww3MRjPquqNLMfEm0wRtvXCp","object":"chat.completion.chunk","created":1731749677,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9ULww3MRjPquqNLMfEm0wRtvXCp","object":"chat.completion.chunk","created":1731749677,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"name"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9ULww3MRjPquqNLMfEm0wRtvXCp","object":"chat.completion.chunk","created":1731749677,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9ULww3MRjPquqNLMfEm0wRtvXCp","object":"chat.completion.chunk","created":1731749677,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Canada"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9ULww3MRjPquqNLMfEm0wRtvXCp","object":"chat.completion.chunk","created":1731749677,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"}"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9ULww3MRjPquqNLMfEm0wRtvXCp","object":"chat.completion.chunk","created":1731749677,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9ULww3MRjPquqNLMfEm0wRtvXCp","object":"chat.completion.chunk","created":1731749677,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_0ba0d124f1","choices":[],"usage":{"prompt_tokens":53,"completion_tokens":5,"total_tokens":58,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367c7d7c6fcf9f-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:37 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '161' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '10000' + x-ratelimit-limit-tokens: + - '200000' + x-ratelimit-remaining-requests: + - '9999' + x-ratelimit-remaining-tokens: + - '199978' + x-ratelimit-reset-requests: + - 8.64s + x-ratelimit-reset-tokens: + - 6ms + x-request-id: + - req_5b1cdde6bb1c37d9615f2a7f6322264f + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"role": "user", "content": "Return a country."}, {"role": + "assistant", "content": null, "tool_calls": [{"id": "call_ugvIEdaAkA3EwKchrQL6sCtt", + "type": "function", "function": {"name": "return_country", "arguments": "{\"name\":\"Canada\"}"}}]}, + {"role": "tool", "tool_call_id": "call_ugvIEdaAkA3EwKchrQL6sCtt", "content": + "1 validation error for Country\nname\n Value error, Country must be Ireland. + [type=value_error, input_value=''Canada'', input_type=str]\n For further + information visit https://errors.pydantic.dev/2.9/v/value_error"}], "model": + "gpt-4o-mini", "parallel_tool_calls": false, "stream": true, "stream_options": + {"include_usage": true}, "tool_choice": {"type": "function", "function": {"name": + "return_country"}}, "tools": [{"type": "function", "function": {"name": "return_country", + "parameters": {"properties": {"name": {"title": "Name", "type": "string"}}, + "required": ["name"], "type": "object"}}}]}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '936' + content-type: + - application/json + cookie: + - __cf_bm=IongOs.UaKxgqpxpk2cJio1t2ANoC2tmOxc3A6LF69Q-1731749677-1.0.1.1-l.m7XlTBhSnwT2YxmLrxCxFdERRQVe2bjNJTKpj.cnlBWlYXqfutVA7.lfFBsRZ5hIkqC92SBz2BmluvkOYDEw; + _cfuvid=xilQfC5pUNDO3wH0u9UbngFg3782S5FE7fn8T37Dhds-1731749677873-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.54.4 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.54.4 + x-stainless-retry-count: + - '0' + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.15 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-AU9UMCyEsQwtrRJ1NQD4DQkDoIDTn","object":"chat.completion.chunk","created":1731749678,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_9b78b61c52","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_Eyrvzk11kYJM0px7uwZFVr7m","type":"function","function":{"name":"return_country","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UMCyEsQwtrRJ1NQD4DQkDoIDTn","object":"chat.completion.chunk","created":1731749678,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_9b78b61c52","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UMCyEsQwtrRJ1NQD4DQkDoIDTn","object":"chat.completion.chunk","created":1731749678,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_9b78b61c52","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"name"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UMCyEsQwtrRJ1NQD4DQkDoIDTn","object":"chat.completion.chunk","created":1731749678,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_9b78b61c52","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UMCyEsQwtrRJ1NQD4DQkDoIDTn","object":"chat.completion.chunk","created":1731749678,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_9b78b61c52","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Ireland"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UMCyEsQwtrRJ1NQD4DQkDoIDTn","object":"chat.completion.chunk","created":1731749678,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_9b78b61c52","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"}"}}]},"logprobs":null,"finish_reason":null}],"usage":null} + + + data: {"id":"chatcmpl-AU9UMCyEsQwtrRJ1NQD4DQkDoIDTn","object":"chat.completion.chunk","created":1731749678,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_9b78b61c52","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null} + + + data: {"id":"chatcmpl-AU9UMCyEsQwtrRJ1NQD4DQkDoIDTn","object":"chat.completion.chunk","created":1731749678,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"fp_9b78b61c52","choices":[],"usage":{"prompt_tokens":125,"completion_tokens":5,"total_tokens":130,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8e367c7f3e0dcf9f-SJC + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Sat, 16 Nov 2024 09:34:38 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + access-control-expose-headers: + - X-Request-ID + alt-svc: + - h3=":443"; ma=86400 + openai-processing-ms: + - '255' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '10000' + x-ratelimit-limit-tokens: + - '200000' + x-ratelimit-remaining-requests: + - '9998' + x-ratelimit-remaining-tokens: + - '199922' + x-ratelimit-reset-requests: + - 17.001s + x-ratelimit-reset-tokens: + - 23ms + x-request-id: + - req_2740ae04afa64140db7a7b0f3dd2516e + status: + code: 200 + message: OK +version: 1 diff --git a/tests/chat_model/test_anthropic_chat_model.py b/tests/chat_model/test_anthropic_chat_model.py index b5c65979..d296bd94 100644 --- a/tests/chat_model/test_anthropic_chat_model.py +++ b/tests/chat_model/test_anthropic_chat_model.py @@ -132,7 +132,6 @@ def minus(a: int, b: int) -> int: ("List three fruits", [list[str]], list), ], ) -@pytest.mark.asyncio @pytest.mark.anthropic async def test_anthropic_chat_model_acomplete( prompt, output_types, expected_output_type @@ -144,7 +143,6 @@ async def test_anthropic_chat_model_acomplete( assert isinstance(message.content, expected_output_type) -@pytest.mark.asyncio @pytest.mark.anthropic async def test_anthropic_chat_model_acomplete_usage(): chat_model = AnthropicChatModel("claude-3-haiku-20240307") @@ -157,7 +155,6 @@ async def test_anthropic_chat_model_acomplete_usage(): assert message.usage.output_tokens > 0 -@pytest.mark.asyncio @pytest.mark.anthropic async def test_anthropic_chat_model_acomplete_usage_structured_output(): chat_model = AnthropicChatModel("claude-3-haiku-20240307") @@ -169,7 +166,6 @@ async def test_anthropic_chat_model_acomplete_usage_structured_output(): assert message.usage.output_tokens > 0 -@pytest.mark.asyncio @pytest.mark.anthropic async def test_anthropic_chat_model_acomplete_raises_tool_schema_parse_error(): def raise_error(v): @@ -186,7 +182,6 @@ class Test(BaseModel): ) -@pytest.mark.asyncio @pytest.mark.anthropic async def test_anthropic_chat_model_acomplete_function_call(): def plus(a: int, b: int) -> int: @@ -202,7 +197,6 @@ def plus(a: int, b: int) -> int: assert isinstance(message.content, FunctionCall) -@pytest.mark.asyncio @pytest.mark.anthropic async def test_anthropic_chat_model_acomplete_async_parallel_function_call(): def plus(a: int, b: int) -> int: diff --git a/tests/chat_model/test_litellm_chat_model.py b/tests/chat_model/test_litellm_chat_model.py index d7766a77..34fc2e5f 100644 --- a/tests/chat_model/test_litellm_chat_model.py +++ b/tests/chat_model/test_litellm_chat_model.py @@ -1,3 +1,4 @@ +import asyncio from collections.abc import Iterator from typing import Annotated, Any @@ -27,7 +28,7 @@ ) @pytest.mark.litellm_openai def test_litellm_chat_model_complete_openai(prompt, output_types, expected_output_type): - chat_model = LitellmChatModel("gpt-3.5-turbo") + chat_model = LitellmChatModel("gpt-4o") message = chat_model.complete( messages=[UserMessage(prompt)], output_types=output_types ) @@ -51,7 +52,7 @@ def _add_call_to_list(kwargs, completion_response, start_time, end_time): @pytest.mark.litellm_openai def test_litellm_chat_model_metadata(litellm_success_callback_calls): """Test that provided metadata is passed to the litellm success callback.""" - chat_model = LitellmChatModel("gpt-3.5-turbo", metadata={"foo": "bar"}) + chat_model = LitellmChatModel("gpt-4o", metadata={"foo": "bar"}) assert chat_model.metadata == {"foo": "bar"} chat_model.complete(messages=[UserMessage("Say hello!")]) # There are multiple callback calls due to streaming @@ -63,7 +64,7 @@ def test_litellm_chat_model_metadata(litellm_success_callback_calls): @pytest.mark.litellm_openai def test_litellm_chat_model_custom_llm_provider(litellm_success_callback_calls): """Test that provided custom_llm_provider is passed to the litellm success callback.""" - chat_model = LitellmChatModel("gpt-3.5-turbo", custom_llm_provider="openai") + chat_model = LitellmChatModel("gpt-4o", custom_llm_provider="openai") assert chat_model.custom_llm_provider == "openai" chat_model.complete(messages=[UserMessage("Say hello!")]) callback_call = litellm_success_callback_calls[-1] @@ -78,7 +79,7 @@ def raise_error(v): class Test(BaseModel): value: Annotated[int, AfterValidator(raise_error)] - chat_model = LitellmChatModel("gpt-3.5-turbo") + chat_model = LitellmChatModel("gpt-4o") with pytest.raises(ToolSchemaParseError): chat_model.complete( messages=[UserMessage("Return a test value of 42.")], @@ -103,33 +104,36 @@ async def async_log_success_event( litellm.callbacks = original_success_callback # type: ignore[assignment] -@pytest.mark.asyncio @pytest.mark.litellm_openai async def test_litellm_chat_model_metadata_async(litellm_async_success_callback_calls): """Test that provided metadata is passed to the litellm success callback.""" - chat_model = LitellmChatModel("gpt-3.5-turbo", metadata={"foo": "bar"}) + chat_model = LitellmChatModel("gpt-4o", metadata={"foo": "bar"}) assert chat_model.metadata == {"foo": "bar"} await chat_model.acomplete(messages=[UserMessage("Say hello!")]) + # Sleep to allow the callback to be called + await asyncio.sleep(1) # There are multiple callback calls due to streaming # Take the last one because the first is occasionally from another test callback_call = litellm_async_success_callback_calls[-1] assert callback_call["kwargs"]["litellm_params"]["metadata"] == {"foo": "bar"} -@pytest.mark.asyncio @pytest.mark.litellm_openai async def test_litellm_chat_model_custom_llm_provider_async( litellm_async_success_callback_calls, ): """Test that provided custom_llm_provider is passed to the litellm success callback.""" - chat_model = LitellmChatModel("gpt-3.5-turbo", custom_llm_provider="openai") + chat_model = LitellmChatModel("gpt-4o", custom_llm_provider="openai") assert chat_model.custom_llm_provider == "openai" await chat_model.acomplete(messages=[UserMessage("Say hello!")]) + # Sleep to allow the callback to be called + await asyncio.sleep(1) + # There are multiple callback calls due to streaming + # Take the last one because the first is occasionally from another test callback_call = litellm_async_success_callback_calls[-1] assert callback_call["kwargs"]["litellm_params"]["custom_llm_provider"] == "openai" -@pytest.mark.asyncio @pytest.mark.litellm_openai async def test_litellm_chat_model_acomplete_raises_tool_schema_parse_error(): def raise_error(v): @@ -138,7 +142,7 @@ def raise_error(v): class Test(BaseModel): value: Annotated[int, AfterValidator(raise_error)] - chat_model = LitellmChatModel("gpt-3.5-turbo") + chat_model = LitellmChatModel("gpt-4o") with pytest.raises(ToolSchemaParseError): await chat_model.acomplete( messages=[UserMessage("Return a test value of 42.")], @@ -212,15 +216,36 @@ def minus(a: int, b: int) -> int: ("prompt", "output_types", "expected_output_type"), [ ("Say hello!", [str], str), - ("Return True.", [bool], bool), - ("Return [1, 2, 3, 4, 5]", [list[int]], list), - ('Return ["apple", "banana"]', [list[str]], list), + pytest.param( + "Return True.", + [bool], + bool, + marks=pytest.mark.skip( + reason="Skip until Ollama supports streamed tool calls" + ), + ), + pytest.param( + "Return [1, 2, 3, 4, 5]", + [list[int]], + list, + marks=pytest.mark.skip( + reason="Skip until Ollama supports streamed tool calls" + ), + ), + pytest.param( + 'Return ["apple", "banana"]', + [list[str]], + list, + marks=pytest.mark.skip( + reason="Skip until Ollama supports streamed tool calls" + ), + ), ], ) @pytest.mark.litellm_ollama def test_litellm_chat_model_complete_ollama(prompt, output_types, expected_output_type): chat_model = LitellmChatModel( - "ollama_chat/llama3", api_base="http://localhost:11434" + "ollama_chat/llama3.1", api_base="http://localhost:11434" ) message = chat_model.complete( messages=[UserMessage(prompt)], output_types=output_types @@ -237,12 +262,11 @@ def test_litellm_chat_model_complete_ollama(prompt, output_types, expected_outpu ("List three fruits", [list[str]], list), ], ) -@pytest.mark.asyncio @pytest.mark.litellm_openai async def test_litellm_chat_model_acomplete_openai( prompt, output_types, expected_output_type ): - chat_model = LitellmChatModel("gpt-3.5-turbo") + chat_model = LitellmChatModel("gpt-4o") message = await chat_model.acomplete( messages=[UserMessage(prompt)], output_types=output_types ) @@ -263,7 +287,6 @@ async def test_litellm_chat_model_acomplete_openai( ), ], ) -@pytest.mark.asyncio @pytest.mark.litellm_anthropic async def test_litellm_chat_model_acomplete_anthropic( prompt, output_types, expected_output_type @@ -275,7 +298,6 @@ async def test_litellm_chat_model_acomplete_anthropic( assert isinstance(message.content, expected_output_type) -@pytest.mark.asyncio @pytest.mark.litellm_anthropic async def test_litellm_chat_model_acomplete_anthropic_function_call(): def plus(a: int, b: int) -> int: @@ -291,7 +313,6 @@ def plus(a: int, b: int) -> int: assert isinstance(message.content, FunctionCall) -@pytest.mark.asyncio @pytest.mark.litellm_anthropic async def test_litellm_chat_model_acomplete_anthropic_async_parallel_function_call(): def plus(a: int, b: int) -> int: @@ -318,18 +339,38 @@ def minus(a: int, b: int) -> int: ("prompt", "output_types", "expected_output_type"), [ ("Say hello!", [str], str), - ("Return True.", [bool], bool), - ("Return [1, 2, 3, 4, 5]", [list[int]], list), - ('Return ["apple", "banana"]', [list[str]], list), + pytest.param( + "Return True.", + [bool], + bool, + marks=pytest.mark.skip( + reason="Skip until Ollama supports streamed tool calls" + ), + ), + pytest.param( + "Return [1, 2, 3, 4, 5]", + [list[int]], + list, + marks=pytest.mark.skip( + reason="Skip until Ollama supports streamed tool calls" + ), + ), + pytest.param( + 'Return ["apple", "banana"]', + [list[str]], + list, + marks=pytest.mark.skip( + reason="Skip until Ollama supports streamed tool calls" + ), + ), ], ) -@pytest.mark.asyncio @pytest.mark.litellm_ollama async def test_litellm_chat_model_acomplete_ollama( prompt, output_types, expected_output_type ): chat_model = LitellmChatModel( - "ollama_chat/llama3", api_base="http://localhost:11434" + "ollama_chat/llama3.1", api_base="http://localhost:11434" ) message = await chat_model.acomplete( messages=[UserMessage(prompt)], output_types=output_types diff --git a/tests/chat_model/test_mistral_chat_model.py b/tests/chat_model/test_mistral_chat_model.py index 499a84d3..f89f0a82 100644 --- a/tests/chat_model/test_mistral_chat_model.py +++ b/tests/chat_model/test_mistral_chat_model.py @@ -132,7 +132,6 @@ class Quote(BaseModel): ("List three fruits", [list[str]], list), ], ) -@pytest.mark.asyncio @pytest.mark.mistral async def test_mistral_chat_model_acomplete(prompt, output_types, expected_output_type): chat_model = MistralChatModel("mistral-large-latest") @@ -142,7 +141,6 @@ async def test_mistral_chat_model_acomplete(prompt, output_types, expected_outpu assert isinstance(message.content, expected_output_type) -@pytest.mark.asyncio @pytest.mark.mistral async def test_mistral_chat_model_acomplete_usage(): chat_model = MistralChatModel("mistral-large-latest") @@ -155,7 +153,6 @@ async def test_mistral_chat_model_acomplete_usage(): assert message.usage.output_tokens > 0 -@pytest.mark.asyncio @pytest.mark.mistral async def test_mistral_chat_model_acomplete_usage_structured_output(): chat_model = MistralChatModel("mistral-large-latest") @@ -167,7 +164,6 @@ async def test_mistral_chat_model_acomplete_usage_structured_output(): assert message.usage.output_tokens > 0 -@pytest.mark.asyncio @pytest.mark.mistral async def test_mistral_chat_model_acomplete_function_call(): def plus(a: int, b: int) -> int: @@ -183,7 +179,6 @@ def plus(a: int, b: int) -> int: assert isinstance(message.content, FunctionCall) -@pytest.mark.asyncio @pytest.mark.mistral async def test_mistral_chat_model_acomplete_async_parallel_function_call(): def plus(a: int, b: int) -> int: diff --git a/tests/chat_model/test_openai_chat_model.py b/tests/chat_model/test_openai_chat_model.py index ae7518d0..26f06efe 100644 --- a/tests/chat_model/test_openai_chat_model.py +++ b/tests/chat_model/test_openai_chat_model.py @@ -133,23 +133,23 @@ def test_openai_chat_model_api_key(monkeypatch): monkeypatch.delenv("OPENAI_API_KEY") with pytest.raises(openai.OpenAIError): - chat_model = OpenaiChatModel("gpt-3.5-turbo") + chat_model = OpenaiChatModel("gpt-4o") - chat_model = OpenaiChatModel("gpt-3.5-turbo", api_key=openai_api_key) + chat_model = OpenaiChatModel("gpt-4o", api_key=openai_api_key) message = chat_model.complete(messages=[UserMessage("Say hello!")]) assert isinstance(message.content, str) @pytest.mark.openai def test_openai_chat_model_complete_base_url(): - chat_model = OpenaiChatModel("gpt-3.5-turbo", base_url="https://api.openai.com/v1") + chat_model = OpenaiChatModel("gpt-4o", base_url="https://api.openai.com/v1") message = chat_model.complete(messages=[UserMessage("Say hello!")]) assert isinstance(message.content, str) @pytest.mark.openai def test_openai_chat_model_complete_seed(): - chat_model = OpenaiChatModel("gpt-3.5-turbo", seed=42) + chat_model = OpenaiChatModel("gpt-4o", seed=42) message1 = chat_model.complete(messages=[UserMessage("Say hello!")]) message2 = chat_model.complete(messages=[UserMessage("Say hello!")]) assert message1.content == message2.content @@ -188,7 +188,7 @@ def plus(a: int, b: int) -> int: @pytest.mark.openai def test_openai_chat_model_complete_usage(): - chat_model = OpenaiChatModel("gpt-3.5-turbo") + chat_model = OpenaiChatModel("gpt-4o") message = chat_model.complete( messages=[UserMessage("Say hello!")], output_types=[StreamedStr] ) @@ -200,7 +200,7 @@ def test_openai_chat_model_complete_usage(): @pytest.mark.openai def test_openai_chat_model_complete_usage_structured_output(): - chat_model = OpenaiChatModel("gpt-3.5-turbo") + chat_model = OpenaiChatModel("gpt-4o") message = chat_model.complete( messages=[UserMessage("Count to 5")], output_types=[list[int]] ) @@ -211,7 +211,7 @@ def test_openai_chat_model_complete_usage_structured_output(): @pytest.mark.openai def test_openai_chat_model_complete_no_structured_output_error(): - chat_model = OpenaiChatModel("gpt-3.5-turbo") + chat_model = OpenaiChatModel("gpt-4o") # Should not raise StructuredOutputError because forced to make tool call message: Message[int | bool] = chat_model.complete( messages=[ @@ -230,7 +230,7 @@ def raise_error(v): class Test(BaseModel): value: Annotated[int, AfterValidator(raise_error)] - chat_model = OpenaiChatModel("gpt-3.5-turbo") + chat_model = OpenaiChatModel("gpt-4o") with pytest.raises(ToolSchemaParseError): chat_model.complete( messages=[UserMessage("Return a test value of 42.")], @@ -238,10 +238,9 @@ class Test(BaseModel): ) -@pytest.mark.asyncio @pytest.mark.openai async def test_openai_chat_model_acomplete_usage(): - chat_model = OpenaiChatModel("gpt-3.5-turbo") + chat_model = OpenaiChatModel("gpt-4o") message = await chat_model.acomplete( messages=[UserMessage("Say hello!")], output_types=[AsyncStreamedStr] ) @@ -251,10 +250,9 @@ async def test_openai_chat_model_acomplete_usage(): assert message.usage.output_tokens > 0 -@pytest.mark.asyncio @pytest.mark.openai async def test_openai_chat_model_acomplete_usage_structured_output(): - chat_model = OpenaiChatModel("gpt-3.5-turbo") + chat_model = OpenaiChatModel("gpt-4o") message = await chat_model.acomplete( messages=[UserMessage("Count to 5")], output_types=[list[int]] ) @@ -263,7 +261,6 @@ async def test_openai_chat_model_acomplete_usage_structured_output(): assert message.usage.output_tokens > 0 -@pytest.mark.asyncio @pytest.mark.openai async def test_openai_chat_model_acomplete_raises_tool_schema_parse_error(): def raise_error(v): @@ -272,7 +269,7 @@ def raise_error(v): class Test(BaseModel): value: Annotated[int, AfterValidator(raise_error)] - chat_model = OpenaiChatModel("gpt-3.5-turbo") + chat_model = OpenaiChatModel("gpt-4o") with pytest.raises(ToolSchemaParseError): await chat_model.acomplete( messages=[UserMessage("Return a test value of 42.")], @@ -284,5 +281,5 @@ def test_openai_chat_model_azure_omits_stream_options(monkeypatch): monkeypatch.setenv("AZURE_OPENAI_API_KEY", "test") monkeypatch.setenv("AZURE_OPENAI_ENDPOINT", "test") monkeypatch.setenv("OPENAI_API_VERSION", "test") - chat_model = OpenaiChatModel("gpt-3.5-turbo", api_type="azure") + chat_model = OpenaiChatModel("gpt-4o", api_type="azure") assert chat_model._get_stream_options() == openai.NOT_GIVEN diff --git a/tests/chat_model/test_retry_chat_model.py b/tests/chat_model/test_retry_chat_model.py index 604033ef..4c8e8212 100644 --- a/tests/chat_model/test_retry_chat_model.py +++ b/tests/chat_model/test_retry_chat_model.py @@ -30,7 +30,6 @@ class Country(BaseModel): assert message.content.name == "Ireland" -@pytest.mark.asyncio @pytest.mark.openai async def test_retry_chat_model_acomplete_openai(): def assert_is_ireland(v): @@ -73,7 +72,6 @@ class Country(BaseModel): assert message.content.name == "Ireland" -@pytest.mark.asyncio @pytest.mark.anthropic async def test_retry_chat_model_acomplete_anthropic(): def assert_is_ireland(v): @@ -116,7 +114,6 @@ class Country(BaseModel): assert message.content.name == "Ireland" -@pytest.mark.asyncio @pytest.mark.litellm_openai async def test_retry_chat_model_acomplete_litellm_openai(): def assert_is_ireland(v): diff --git a/tests/conftest.py b/tests/conftest.py index b88b2bcc..79570d8b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,7 +1,54 @@ +from typing import Any + import pytest from dotenv import load_dotenv @pytest.fixture(autouse=True, scope="session") def _load_dotenv(): + """Load .env file so API keys are available when rewriting VCR cassettes""" + # Set default values so tests can run using existing cassettes without env vars + load_dotenv(".env.template") load_dotenv() + + +@pytest.fixture(autouse=True, scope="session") +def vcr_config(): + def before_record_response(response: dict[str, Any]) -> dict[str, Any]: + filter_response_headers = [ + "openai-organization", + "Set-Cookie", + ] + for response_header in filter_response_headers: + response["headers"].pop(response_header, None) + return response + + return { + "filter_headers": [ + # openai + "authorization", + "openai-organization", + # anthropic + "x-api-key", + # litellm_openai + "cookie", + ], + "before_record_response": before_record_response, + } + + +def pytest_collection_modifyitems( + session: pytest.Session, config: pytest.Config, items: list[pytest.Item] +) -> None: + llm_markers = [ + "anthropic", + "litellm_anthropic", + "litellm_ollama", + "litellm_openai", + "mistral", + "openai", + ] + for item in items: + # Apply vcr marker to all LLM tests + if any(marker in item.keywords for marker in llm_markers): + item.add_marker(pytest.mark.vcr) diff --git a/tests/test_backend.py b/tests/test_backend.py index 842010cb..a0db208a 100644 --- a/tests/test_backend.py +++ b/tests/test_backend.py @@ -81,7 +81,7 @@ def test_backend_litellm_chat_model(monkeypatch): @pytest.mark.openai def test_openai_chat_model_completion(): model = OpenaiChatModel( - model="gpt-3.5-turbo", + model="gpt-4o", max_tokens=5, temperature=0.5, ) diff --git a/tests/test_chat.py b/tests/test_chat.py index 5a6091a7..549d396d 100644 --- a/tests/test_chat.py +++ b/tests/test_chat.py @@ -56,7 +56,6 @@ def test_chat_submit(): assert isinstance(chat2.messages[1], AssistantMessage) -@pytest.mark.asyncio @pytest.mark.openai async def test_chat_asubmit(): chat1 = Chat( @@ -116,7 +115,6 @@ def plus(a: int, b: int) -> int: chat = chat.exec_function_call() -@pytest.mark.asyncio async def test_aexec_function_call_async_function(): async def aplus(a: int, b: int) -> int: return a + b @@ -134,7 +132,6 @@ async def aplus(a: int, b: int) -> int: assert chat.messages[2] == FunctionResultMessage(3, aplus_1_2) -@pytest.mark.asyncio async def test_aexec_function_call_not_async_function(): def plus(a: int, b: int) -> int: return a + b @@ -152,7 +149,6 @@ def plus(a: int, b: int) -> int: assert chat.messages[2] == FunctionResultMessage(3, plus_1_2) -@pytest.mark.asyncio async def test_aexec_function_call_async_parallel_function_call(): def plus(a: int, b: int) -> int: return a + b @@ -176,7 +172,6 @@ def plus(a: int, b: int) -> int: assert chat.messages[3] == FunctionResultMessage(7, plus_3_4) -@pytest.mark.asyncio async def test_aexec_function_call_raises(): async def aplus(a: int, b: int) -> int: return a + b diff --git a/tests/test_chatprompt.py b/tests/test_chatprompt.py index 5784a9f4..f0ead6de 100644 --- a/tests/test_chatprompt.py +++ b/tests/test_chatprompt.py @@ -122,7 +122,6 @@ def func(one: int) -> str: assert getdoc(func) == "This is the docstring." -@pytest.mark.asyncio async def test_asyncchatpromptfunction_call(): mock_model = AsyncMock() mock_model.acomplete.return_value = AssistantMessage(content="Hello!") @@ -143,7 +142,6 @@ async def say_hello(name: str) -> str | bool: ... assert mock_model.acomplete.call_args.kwargs["stop"] == ["stop"] -@pytest.mark.asyncio async def test_async_chatprompt_decorator_docstring(): @chatprompt(UserMessage("This is a user message.")) async def func(one: int) -> str: diff --git a/tests/test_function_call.py b/tests/test_function_call.py index d05afd37..1a87f3fb 100644 --- a/tests/test_function_call.py +++ b/tests/test_function_call.py @@ -69,7 +69,6 @@ def test_function_call_arguments(function_call, arguments): assert function_call.arguments == arguments -@pytest.mark.asyncio async def test_function_call_async_function(): async def async_plus(a: int, b: int) -> int: return a + b @@ -100,7 +99,6 @@ def test_parallel_function_call_iter(): assert list(parallel_function_call) == function_calls -@pytest.mark.asyncio async def test_async_parallel_function_call_call(): function_calls: list[FunctionCall[int | Awaitable[int]]] = [ FunctionCall(plus, a=1, b=2), @@ -113,7 +111,6 @@ async def test_async_parallel_function_call_call(): assert result == (3, 7) -@pytest.mark.asyncio async def test_async_parallel_function_call_aiter(): function_calls: list[FunctionCall[int | Awaitable[int]]] = [ FunctionCall(plus, a=1, b=2), diff --git a/tests/test_function_schema.py b/tests/test_function_schema.py index 534e9919..02c081af 100644 --- a/tests/test_function_schema.py +++ b/tests/test_function_schema.py @@ -161,7 +161,6 @@ def test_any_function_schema_parse_args(type_, args_str, expected_args): @pytest.mark.parametrize( ("type_", "args_str", "expected_args"), any_function_schema_args_test_cases ) -@pytest.mark.asyncio async def test_any_function_schema_aparse_args(type_, args_str, expected_args): parsed_args = await AnyFunctionSchema(type_).aparse_args(async_iter(args_str)) assert parsed_args == expected_args @@ -348,7 +347,6 @@ def test_async_iterable_function_schema(type_, json_schema): ("type_", "args_str", "expected_args"), async_iterable_function_schema_args_test_cases, ) -@pytest.mark.asyncio async def test_async_iterable_function_schema_aparse_args( type_, args_str, expected_args ): @@ -363,7 +361,6 @@ async def test_async_iterable_function_schema_aparse_args( ("type_", "expected_args_str", "args"), async_iterable_function_schema_args_test_cases, ) -@pytest.mark.asyncio async def test_async_iterable_function_schema_aserialize_args( type_, expected_args_str, args ): diff --git a/tests/test_prompt_chain.py b/tests/test_prompt_chain.py index b10cab63..63796f41 100644 --- a/tests/test_prompt_chain.py +++ b/tests/test_prompt_chain.py @@ -50,7 +50,6 @@ def make_function_call() -> str: ... assert mock_function.call_count == 1 -@pytest.mark.asyncio @pytest.mark.openai async def test_async_prompt_chain(): async def get_current_weather(location, unit="fahrenheit"): @@ -72,7 +71,6 @@ async def describe_weather(city: str) -> str: ... assert isinstance(output, str) -@pytest.mark.asyncio async def test_async_prompt_chain_max_calls(): mock_function = Mock() mock_function.__name__ = "mock_function_name" diff --git a/tests/test_prompt_function.py b/tests/test_prompt_function.py index 8da3fa7f..e0a186d7 100644 --- a/tests/test_prompt_function.py +++ b/tests/test_prompt_function.py @@ -203,7 +203,6 @@ def get_country() -> Country: ... assert country.name == "Ireland" -@pytest.mark.asyncio async def test_async_promptfunction_call(): mock_model = AsyncMock() mock_model.acomplete.return_value = AssistantMessage(content="Hello!") @@ -224,7 +223,6 @@ async def say_hello(name: str) -> str | bool: ... assert mock_model.acomplete.call_args.kwargs["stop"] == ["stop"] -@pytest.mark.asyncio @pytest.mark.openai async def test_async_decorator_return_str(): @prompt("What is the capital of {country}? Name only. No punctuation.") @@ -235,7 +233,6 @@ async def get_capital(country: str) -> str: ... assert isinstance(output, str) -@pytest.mark.asyncio @pytest.mark.openai async def test_async_decorator_return_async_streamed_str(): @prompt("What is the capital of {country}?") @@ -245,7 +242,6 @@ async def get_capital(country: str) -> AsyncStreamedStr: ... assert isinstance(output, AsyncStreamedStr) -@pytest.mark.asyncio @pytest.mark.openai async def test_async_decorator_max_retries(): def assert_is_ireland(v): @@ -264,7 +260,6 @@ async def get_country() -> Country: ... assert country.name == "Ireland" -@pytest.mark.asyncio @pytest.mark.openai async def test_async_decorator_return_function_call(): def plus(a: int, b: int) -> int: @@ -279,7 +274,6 @@ async def sum_ab(a: int, b: int) -> FunctionCall[int]: ... assert isinstance(func_result, int) -@pytest.mark.asyncio @pytest.mark.openai async def test_async_decorator_return_async_function_call(): async def async_plus(a: int, b: int) -> int: @@ -293,7 +287,6 @@ async def sum_ab(a: int, b: int) -> FunctionCall[Awaitable[int]]: ... assert isinstance(await output(), int) -@pytest.mark.asyncio @pytest.mark.openai async def test_decorator_return_async_parallel_function_call(): def plus(a: int, b: int) -> int: @@ -325,6 +318,6 @@ def say_hello_gpt4() -> str: ... assert say_hello.model.model == get_settings().openai_model # type: ignore[attr-defined] - with OpenaiChatModel("gpt-3.5-turbo"): - assert say_hello.model.model == "gpt-3.5-turbo" # type: ignore[attr-defined] + with OpenaiChatModel("gpt-4o"): + assert say_hello.model.model == "gpt-4o" # type: ignore[attr-defined] assert say_hello_gpt4.model.model == "gpt-4" # type: ignore[attr-defined] diff --git a/tests/test_streaming.py b/tests/test_streaming.py index 574a233c..57414504 100644 --- a/tests/test_streaming.py +++ b/tests/test_streaming.py @@ -20,7 +20,6 @@ ) -@pytest.mark.asyncio async def test_async_iter(): output = async_iter(["Hello", " World"]) assert isinstance(output, AsyncIterator) @@ -34,7 +33,6 @@ def test_apply(): assert items == [0, 1, 2] -@pytest.mark.asyncio async def test_aapply(): items: list[int] = [] aiterable = aapply(items.append, async_iter(range(3))) @@ -49,7 +47,6 @@ async def test_aapply(): (azip(async_iter([1, 2, 3]), async_iter([4, 5, 6])), [(1, 4), (2, 5), (3, 6)]), ], ) -@pytest.mark.asyncio async def test_azip(aiterable, expected): assert [x async for x in aiterable] == expected @@ -74,7 +71,6 @@ def test_peek(iterator, expected_first, expected_remaining): (async_iter([1]), 1, [1]), ], ) -@pytest.mark.asyncio async def test_apeek(aiterator, expected_first, expected_remaining): first, remaining = await apeek(aiterator) assert first == expected_first @@ -89,7 +85,6 @@ async def test_apeek(aiterator, expected_first, expected_remaining): (lambda x: x < 0, async_iter(range(5)), [0, 1, 2, 3, 4]), ], ) -@pytest.mark.asyncio async def test_adropwhile(predicate, input, expected): assert [x async for x in adropwhile(predicate, input)] == expected @@ -102,7 +97,6 @@ async def test_adropwhile(predicate, input, expected): (lambda x: x < 0, async_iter(range(5)), []), ], ) -@pytest.mark.asyncio async def test_atakewhile(predicate, input, expected): assert [x async for x in atakewhile(predicate, input)] == expected @@ -114,7 +108,6 @@ async def test_atakewhile(predicate, input, expected): (async_iter([1, 1, 2]), lambda x: x, [(1, [1, 1]), (2, [2])]), ], ) -@pytest.mark.asyncio async def test_agroupby(aiterable, key, expected): assert [ (k, [x async for x in g]) async for k, g in agroupby(aiterable, key) @@ -137,7 +130,6 @@ def test_iter_streamed_json_array(input, expected): @pytest.mark.parametrize(("input", "expected"), iter_streamed_json_array_test_cases) -@pytest.mark.asyncio async def test_aiter_streamed_json_array(input, expected): assert [x async for x in aiter_streamed_json_array(async_iter(input))] == expected @@ -164,7 +156,6 @@ def test_iter_cached_iterable(input, expected): (range(3), [0, 1, 2]), ], ) -@pytest.mark.asyncio async def test_aiter_cached_async_iterable(input, expected): cached_aiterable = CachedAsyncIterable(async_iter(input)) assert [x async for x in cached_aiterable] == list(expected) @@ -190,7 +181,6 @@ def test_streamed_str_truncate(): assert streamed_str.truncate(length=99) == "First Second Third" -@pytest.mark.asyncio async def test_async_streamed_str_iter(): aiter_chunks = async_iter(["Hello", " World"]) async_streamed_str = AsyncStreamedStr(aiter_chunks) @@ -199,13 +189,11 @@ async def test_async_streamed_str_iter(): assert [chunk async for chunk in async_streamed_str] == ["Hello", " World"] -@pytest.mark.asyncio async def test_async_streamed_str_to_string(): async_streamed_str = AsyncStreamedStr(async_iter(["Hello", " World"])) assert await async_streamed_str.to_string() == "Hello World" -@pytest.mark.asyncio async def test_async_streamed_str_truncate(): async_streamed_str = AsyncStreamedStr(async_iter(["First", " Second", " Third"])) assert await async_streamed_str.truncate(length=12) == "First [...]" diff --git a/uv.lock b/uv.lock index 8009e59b..9a171fc6 100644 --- a/uv.lock +++ b/uv.lock @@ -1,10 +1,14 @@ version = 1 requires-python = ">=3.10" resolution-markers = [ - "python_full_version < '3.11'", - "python_full_version == '3.11.*'", - "python_full_version == '3.12.*'", - "python_full_version >= '3.13'", + "python_full_version < '3.11' and platform_python_implementation == 'PyPy'", + "python_full_version < '3.11' and platform_python_implementation != 'PyPy'", + "python_full_version == '3.11.*' and platform_python_implementation == 'PyPy'", + "python_full_version == '3.11.*' and platform_python_implementation != 'PyPy'", + "python_full_version == '3.12.*' and platform_python_implementation == 'PyPy'", + "python_full_version == '3.12.*' and platform_python_implementation != 'PyPy'", + "python_full_version >= '3.13' and platform_python_implementation == 'PyPy'", + "python_full_version >= '3.13' and platform_python_implementation != 'PyPy'", ] [[package]] @@ -887,6 +891,24 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374", size = 5892 }, ] +[[package]] +name = "inline-snapshot" +version = "0.14.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "asttokens" }, + { name = "black" }, + { name = "click" }, + { name = "executing" }, + { name = "rich" }, + { name = "tomli", marker = "python_full_version < '3.11'" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/45/a9/b6b9db4f2ef1e3261460701a429f8248e517cb8d18e27ff05f4690ac0a73/inline_snapshot-0.14.0.tar.gz", hash = "sha256:54fdf7831055d06a2423054875d640102865a164cc8291a8086e44dd9b4fd316", size = 209662 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/5e/a3/8ca14974625632d56d7e9f899d76d15dc4acd94ec15c179ca528beadeb4a/inline_snapshot-0.14.0-py3-none-any.whl", hash = "sha256:dc246d28b720f6050404b72cc1d171b0671e1494249197753d23771ff228748c", size = 31807 }, +] + [[package]] name = "ipykernel" version = "6.29.5" @@ -1388,6 +1410,7 @@ litellm = [ [package.dev-dependencies] dev = [ { name = "anthropic" }, + { name = "inline-snapshot" }, { name = "litellm" }, { name = "logfire" }, { name = "mypy" }, @@ -1395,6 +1418,7 @@ dev = [ { name = "pytest-asyncio" }, { name = "pytest-clarity" }, { name = "pytest-cov" }, + { name = "pytest-recording" }, { name = "python-dotenv" }, { name = "ruff" }, ] @@ -1425,6 +1449,7 @@ requires-dist = [ [package.metadata.requires-dev] dev = [ { name = "anthropic" }, + { name = "inline-snapshot", specifier = ">=0.14.0" }, { name = "litellm" }, { name = "logfire", specifier = ">=0.46.1,<0.50.0" }, { name = "mypy" }, @@ -1432,6 +1457,7 @@ dev = [ { name = "pytest-asyncio", specifier = ">=0.18.0" }, { name = "pytest-clarity", specifier = ">=0.1.0" }, { name = "pytest-cov", specifier = ">=4.0.0" }, + { name = "pytest-recording", specifier = ">=0.13.2" }, { name = "python-dotenv", specifier = ">=1.0.1" }, { name = "ruff", specifier = ">=0.3" }, ] @@ -2519,6 +2545,19 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/36/3b/48e79f2cd6a61dbbd4807b4ed46cb564b4fd50a76166b1c4ea5c1d9e2371/pytest_cov-6.0.0-py3-none-any.whl", hash = "sha256:eee6f1b9e61008bd34975a4d5bab25801eb31898b032dd55addc93e96fcaaa35", size = 22949 }, ] +[[package]] +name = "pytest-recording" +version = "0.13.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pytest" }, + { name = "vcrpy" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/fe/2a/ea6b8036ae01979eae02d8ad5a7da14dec90d9176b613e49fb8d134c78fc/pytest_recording-0.13.2.tar.gz", hash = "sha256:000c3babbb466681457fd65b723427c1779a0c6c17d9e381c3142a701e124877", size = 25270 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/72/52/8e67a969e9fad3fa5ec4eab9f2a7348ff04692065c7deda21d76e9112703/pytest_recording-0.13.2-py3-none-any.whl", hash = "sha256:3820fe5743d1ac46e807989e11d073cb776a60bdc544cf43ebca454051b22d13", size = 12783 }, +] + [[package]] name = "python-dateutil" version = "2.9.0.post0" @@ -2808,7 +2847,8 @@ dependencies = [ { name = "certifi" }, { name = "charset-normalizer" }, { name = "idna" }, - { name = "urllib3" }, + { name = "urllib3", version = "1.26.20", source = { registry = "https://pypi.org/simple" }, marker = "platform_python_implementation == 'PyPy'" }, + { name = "urllib3", version = "2.2.3", source = { registry = "https://pypi.org/simple" }, marker = "platform_python_implementation != 'PyPy'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/63/70/2bf7780ad2d390a8d301ad0b550f1581eadbd9a20f896afe06353c2a2913/requests-2.32.3.tar.gz", hash = "sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760", size = 131218 } wheels = [ @@ -3218,15 +3258,52 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/e7/00/3fca040d7cf8a32776d3d81a00c8ee7457e00f80c649f1e4a863c8321ae9/uri_template-1.3.0-py3-none-any.whl", hash = "sha256:a44a133ea12d44a0c0f06d7d42a52d71282e77e2f937d8abd5655b8d56fc1363", size = 11140 }, ] +[[package]] +name = "urllib3" +version = "1.26.20" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version < '3.11' and platform_python_implementation == 'PyPy'", + "python_full_version == '3.11.*' and platform_python_implementation == 'PyPy'", + "python_full_version == '3.12.*' and platform_python_implementation == 'PyPy'", + "python_full_version >= '3.13' and platform_python_implementation == 'PyPy'", +] +sdist = { url = "https://files.pythonhosted.org/packages/e4/e8/6ff5e6bc22095cfc59b6ea711b687e2b7ed4bdb373f7eeec370a97d7392f/urllib3-1.26.20.tar.gz", hash = "sha256:40c2dc0c681e47eb8f90e7e27bf6ff7df2e677421fd46756da1161c39ca70d32", size = 307380 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/33/cf/8435d5a7159e2a9c83a95896ed596f68cf798005fe107cc655b5c5c14704/urllib3-1.26.20-py2.py3-none-any.whl", hash = "sha256:0ed14ccfbf1c30a9072c7ca157e4319b70d65f623e91e7b32fadb2853431016e", size = 144225 }, +] + [[package]] name = "urllib3" version = "2.2.3" source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version < '3.11' and platform_python_implementation != 'PyPy'", + "python_full_version == '3.11.*' and platform_python_implementation != 'PyPy'", + "python_full_version == '3.12.*' and platform_python_implementation != 'PyPy'", + "python_full_version >= '3.13' and platform_python_implementation != 'PyPy'", +] sdist = { url = "https://files.pythonhosted.org/packages/ed/63/22ba4ebfe7430b76388e7cd448d5478814d3032121827c12a2cc287e2260/urllib3-2.2.3.tar.gz", hash = "sha256:e7d814a81dad81e6caf2ec9fdedb284ecc9c73076b62654547cc64ccdcae26e9", size = 300677 } wheels = [ { url = "https://files.pythonhosted.org/packages/ce/d9/5f4c13cecde62396b0d3fe530a50ccea91e7dfc1ccf0e09c228841bb5ba8/urllib3-2.2.3-py3-none-any.whl", hash = "sha256:ca899ca043dcb1bafa3e262d73aa25c465bfb49e0bd9dd5d59f1d0acba2f8fac", size = 126338 }, ] +[[package]] +name = "vcrpy" +version = "6.0.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pyyaml" }, + { name = "urllib3", version = "1.26.20", source = { registry = "https://pypi.org/simple" }, marker = "platform_python_implementation == 'PyPy'" }, + { name = "urllib3", version = "2.2.3", source = { registry = "https://pypi.org/simple" }, marker = "platform_python_implementation != 'PyPy'" }, + { name = "wrapt" }, + { name = "yarl" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/16/4e/fff59599826793f9e3460c22c0af0377abb27dc9781a7d5daca8cb03da25/vcrpy-6.0.2.tar.gz", hash = "sha256:88e13d9111846745898411dbc74a75ce85870af96dd320d75f1ee33158addc09", size = 85472 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/da/ed/25d19705791d3fccc84423d564695421a75b4e08e8ab15a004a49068742d/vcrpy-6.0.2-py2.py3-none-any.whl", hash = "sha256:40370223861181bc76a5e5d4b743a95058bb1ad516c3c08570316ab592f56cad", size = 42431 }, +] + [[package]] name = "watchdog" version = "6.0.0"