Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(beta): merge betas param with the default value #695

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 9
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-c7baafa4b7d58ae2b830c0d5b89248e98421c8a7cf135b7e62e6e215fa94c7f4.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-b629ddf1f1f1473462fc9bdb605abd5b7be51c3ba91c34750cd46e8404aec356.yml
81 changes: 71 additions & 10 deletions src/anthropic/resources/beta/messages/batches.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

from typing import List, Iterable
from itertools import chain

import httpx

Expand Down Expand Up @@ -90,7 +91,13 @@ def create(
timeout: Override the client-level default timeout for this request, in seconds
"""
extra_headers = {
**strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else NOT_GIVEN}),
**strip_not_given(
{
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["message-batches-2024-09-24"]))
if is_given(betas)
else NOT_GIVEN
}
),
**(extra_headers or {}),
}
extra_headers = {"anthropic-beta": "message-batches-2024-09-24", **(extra_headers or {})}
Expand Down Expand Up @@ -137,7 +144,13 @@ def retrieve(
if not message_batch_id:
raise ValueError(f"Expected a non-empty value for `message_batch_id` but received {message_batch_id!r}")
extra_headers = {
**strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else NOT_GIVEN}),
**strip_not_given(
{
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["message-batches-2024-09-24"]))
if is_given(betas)
else NOT_GIVEN
}
),
**(extra_headers or {}),
}
extra_headers = {"anthropic-beta": "message-batches-2024-09-24", **(extra_headers or {})}
Expand Down Expand Up @@ -188,7 +201,13 @@ def list(
timeout: Override the client-level default timeout for this request, in seconds
"""
extra_headers = {
**strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else NOT_GIVEN}),
**strip_not_given(
{
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["message-batches-2024-09-24"]))
if is_given(betas)
else NOT_GIVEN
}
),
**(extra_headers or {}),
}
extra_headers = {"anthropic-beta": "message-batches-2024-09-24", **(extra_headers or {})}
Expand Down Expand Up @@ -245,7 +264,13 @@ def cancel(
if not message_batch_id:
raise ValueError(f"Expected a non-empty value for `message_batch_id` but received {message_batch_id!r}")
extra_headers = {
**strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else NOT_GIVEN}),
**strip_not_given(
{
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["message-batches-2024-09-24"]))
if is_given(betas)
else NOT_GIVEN
}
),
**(extra_headers or {}),
}
extra_headers = {"anthropic-beta": "message-batches-2024-09-24", **(extra_headers or {})}
Expand Down Expand Up @@ -293,7 +318,13 @@ def results(
raise ValueError(f"Expected a non-empty value for `message_batch_id` but received {message_batch_id!r}")
extra_headers = {"Accept": "application/binary", **(extra_headers or {})}
extra_headers = {
**strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else NOT_GIVEN}),
**strip_not_given(
{
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["message-batches-2024-09-24"]))
if is_given(betas)
else NOT_GIVEN
}
),
**(extra_headers or {}),
}
extra_headers = {"anthropic-beta": "message-batches-2024-09-24", **(extra_headers or {})}
Expand Down Expand Up @@ -359,7 +390,13 @@ async def create(
timeout: Override the client-level default timeout for this request, in seconds
"""
extra_headers = {
**strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else NOT_GIVEN}),
**strip_not_given(
{
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["message-batches-2024-09-24"]))
if is_given(betas)
else NOT_GIVEN
}
),
**(extra_headers or {}),
}
extra_headers = {"anthropic-beta": "message-batches-2024-09-24", **(extra_headers or {})}
Expand Down Expand Up @@ -406,7 +443,13 @@ async def retrieve(
if not message_batch_id:
raise ValueError(f"Expected a non-empty value for `message_batch_id` but received {message_batch_id!r}")
extra_headers = {
**strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else NOT_GIVEN}),
**strip_not_given(
{
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["message-batches-2024-09-24"]))
if is_given(betas)
else NOT_GIVEN
}
),
**(extra_headers or {}),
}
extra_headers = {"anthropic-beta": "message-batches-2024-09-24", **(extra_headers or {})}
Expand Down Expand Up @@ -457,7 +500,13 @@ def list(
timeout: Override the client-level default timeout for this request, in seconds
"""
extra_headers = {
**strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else NOT_GIVEN}),
**strip_not_given(
{
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["message-batches-2024-09-24"]))
if is_given(betas)
else NOT_GIVEN
}
),
**(extra_headers or {}),
}
extra_headers = {"anthropic-beta": "message-batches-2024-09-24", **(extra_headers or {})}
Expand Down Expand Up @@ -514,7 +563,13 @@ async def cancel(
if not message_batch_id:
raise ValueError(f"Expected a non-empty value for `message_batch_id` but received {message_batch_id!r}")
extra_headers = {
**strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else NOT_GIVEN}),
**strip_not_given(
{
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["message-batches-2024-09-24"]))
if is_given(betas)
else NOT_GIVEN
}
),
**(extra_headers or {}),
}
extra_headers = {"anthropic-beta": "message-batches-2024-09-24", **(extra_headers or {})}
Expand Down Expand Up @@ -562,7 +617,13 @@ async def results(
raise ValueError(f"Expected a non-empty value for `message_batch_id` but received {message_batch_id!r}")
extra_headers = {"Accept": "application/binary", **(extra_headers or {})}
extra_headers = {
**strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else NOT_GIVEN}),
**strip_not_given(
{
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["message-batches-2024-09-24"]))
if is_given(betas)
else NOT_GIVEN
}
),
**(extra_headers or {}),
}
extra_headers = {"anthropic-beta": "message-batches-2024-09-24", **(extra_headers or {})}
Expand Down
17 changes: 15 additions & 2 deletions src/anthropic/resources/beta/prompt_caching/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

from typing import List, Union, Iterable
from itertools import chain
from typing_extensions import Literal, overload

import httpx
Expand Down Expand Up @@ -877,7 +878,13 @@ def create(
if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
timeout = 600
extra_headers = {
**strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else NOT_GIVEN}),
**strip_not_given(
{
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["prompt-caching-2024-07-31"]))
if is_given(betas)
else NOT_GIVEN
}
),
**(extra_headers or {}),
}
extra_headers = {"anthropic-beta": "prompt-caching-2024-07-31", **(extra_headers or {})}
Expand Down Expand Up @@ -1748,7 +1755,13 @@ async def create(
if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
timeout = 600
extra_headers = {
**strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else NOT_GIVEN}),
**strip_not_given(
{
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["prompt-caching-2024-07-31"]))
if is_given(betas)
else NOT_GIVEN
}
),
**(extra_headers or {}),
}
extra_headers = {"anthropic-beta": "prompt-caching-2024-07-31", **(extra_headers or {})}
Expand Down