diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 157f0355..559b4513 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.36.0" + ".": "0.36.1" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 2523c283..150fc433 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 9 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-aedee7570aa925baba404fc5bd3c8c1fffe8845517e492751db9b175c5cae9da.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-b629ddf1f1f1473462fc9bdb605abd5b7be51c3ba91c34750cd46e8404aec356.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index f1912caf..49da0564 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## 0.36.1 (2024-10-15) + +Full Changelog: [v0.36.0...v0.36.1](https://github.com/anthropics/anthropic-sdk-python/compare/v0.36.0...v0.36.1) + +### Bug Fixes + +* allow header params to override default headers ([#690](https://github.com/anthropics/anthropic-sdk-python/issues/690)) ([56f195f](https://github.com/anthropics/anthropic-sdk-python/commit/56f195ff1a67f2ba6e546ad897cbb0fe39f36a3b)) +* **beta:** merge betas param with the default value ([#695](https://github.com/anthropics/anthropic-sdk-python/issues/695)) ([f52eac9](https://github.com/anthropics/anthropic-sdk-python/commit/f52eac9357c0c496f1307def2628376d8a36e5ba)) + + +### Chores + +* **internal:** update spec URL ([#694](https://github.com/anthropics/anthropic-sdk-python/issues/694)) ([1b437cc](https://github.com/anthropics/anthropic-sdk-python/commit/1b437cc40f2e02e59df06744cc1458ee0cae202a)) + ## 0.36.0 (2024-10-08) Full Changelog: [v0.35.0...v0.36.0](https://github.com/anthropics/anthropic-sdk-python/compare/v0.35.0...v0.36.0) diff --git a/pyproject.toml b/pyproject.toml index 365529f1..d883c8a5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "anthropic" -version = "0.36.0" +version = "0.36.1" description = "The official Python library for the anthropic API" dynamic = ["readme"] license = "MIT" diff --git a/src/anthropic/_version.py b/src/anthropic/_version.py index a96f7f1b..182c4e87 100644 --- a/src/anthropic/_version.py +++ b/src/anthropic/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "anthropic" -__version__ = "0.36.0" # x-release-please-version +__version__ = "0.36.1" # x-release-please-version diff --git a/src/anthropic/resources/beta/messages/batches.py b/src/anthropic/resources/beta/messages/batches.py index 6fed43b2..a6729ac1 100644 --- a/src/anthropic/resources/beta/messages/batches.py +++ b/src/anthropic/resources/beta/messages/batches.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import List, Iterable +from itertools import chain import httpx @@ -81,11 +82,17 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ - extra_headers = {"anthropic-beta": "message-batches-2024-09-24", **(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 {})} return self._post( "/v1/messages/batches?beta=true", body=maybe_transform({"requests": requests}, batch_create_params.BatchCreateParams), @@ -128,11 +135,17 @@ 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 = {"anthropic-beta": "message-batches-2024-09-24", **(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 {})} return self._get( f"/v1/messages/batches/{message_batch_id}?beta=true", options=make_request_options( @@ -179,11 +192,17 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - extra_headers = {"anthropic-beta": "message-batches-2024-09-24", **(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 {})} return self._get_api_list( "/v1/messages/batches?beta=true", page=SyncPage[BetaMessageBatch], @@ -236,11 +255,17 @@ 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 = {"anthropic-beta": "message-batches-2024-09-24", **(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 {})} return self._post( f"/v1/messages/batches/{message_batch_id}/cancel?beta=true", options=make_request_options( @@ -290,12 +315,18 @@ def results( f"No `results_url` for the given batch; Has it finished processing? {batch.processing_status}" ) - extra_headers = {"anthropic-beta": "message-batches-2024-09-24", **(extra_headers or {})} 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 {})} return self._get( batch.results_url, options=make_request_options( @@ -358,11 +389,17 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ - extra_headers = {"anthropic-beta": "message-batches-2024-09-24", **(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 {})} return await self._post( "/v1/messages/batches?beta=true", body=await async_maybe_transform({"requests": requests}, batch_create_params.BatchCreateParams), @@ -405,11 +442,17 @@ 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 = {"anthropic-beta": "message-batches-2024-09-24", **(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 {})} return await self._get( f"/v1/messages/batches/{message_batch_id}?beta=true", options=make_request_options( @@ -456,11 +499,17 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - extra_headers = {"anthropic-beta": "message-batches-2024-09-24", **(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 {})} return self._get_api_list( "/v1/messages/batches?beta=true", page=AsyncPage[BetaMessageBatch], @@ -513,11 +562,17 @@ 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 = {"anthropic-beta": "message-batches-2024-09-24", **(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 {})} return await self._post( f"/v1/messages/batches/{message_batch_id}/cancel?beta=true", options=make_request_options( @@ -567,12 +622,18 @@ async def results( f"No `results_url` for the given batch; Has it finished processing? {batch.processing_status}" ) - extra_headers = {"anthropic-beta": "message-batches-2024-09-24", **(extra_headers or {})} 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 {})} return await self._get( batch.results_url, options=make_request_options( diff --git a/src/anthropic/resources/beta/prompt_caching/messages.py b/src/anthropic/resources/beta/prompt_caching/messages.py index 3a7d8af4..7be54a3b 100644 --- a/src/anthropic/resources/beta/prompt_caching/messages.py +++ b/src/anthropic/resources/beta/prompt_caching/messages.py @@ -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 @@ -878,11 +879,17 @@ def create( ) -> PromptCachingBetaMessage | Stream[RawPromptCachingBetaMessageStreamEvent]: if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT: timeout = 600 - extra_headers = {"anthropic-beta": "prompt-caching-2024-07-31", **(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), ["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 {})} return self._post( "/v1/messages?beta=prompt_caching", body=maybe_transform( @@ -1808,11 +1815,17 @@ async def create( ) -> PromptCachingBetaMessage | AsyncStream[RawPromptCachingBetaMessageStreamEvent]: if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT: timeout = 600 - extra_headers = {"anthropic-beta": "prompt-caching-2024-07-31", **(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), ["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 {})} return await self._post( "/v1/messages?beta=prompt_caching", body=await async_maybe_transform(