Skip to content

Commit

Permalink
fix(beta): merge betas param with the default value (#695)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stainless Bot committed Oct 14, 2024
1 parent 1b437cc commit f52eac9
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 13 deletions.
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 @@ -82,7 +83,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 @@ -129,7 +136,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 @@ -180,7 +193,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 @@ -237,7 +256,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 @@ -292,7 +317,13 @@ def results(

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 @@ -569,7 +624,13 @@ async def results(

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 @@ -4,6 +4,7 @@

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

import httpx
Expand Down Expand Up @@ -879,7 +880,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 @@ -1809,7 +1816,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

0 comments on commit f52eac9

Please sign in to comment.