Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3f4eada

Browse files
authoredJan 7, 2025··
refactor(vertex): remove deprecated HTTP client options (#808)
chore(vertex): remove deprecated HTTP client options
2 parents 1fc034d + 5a80668 commit 3f4eada

File tree

2 files changed

+11
-66
lines changed

2 files changed

+11
-66
lines changed
 

‎src/anthropic/lib/bedrock/_client.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ def _prepare_options(input_options: FinalRequestOptions) -> FinalRequestOptions:
5555
else:
5656
options.url = f"/model/{model}/invoke"
5757

58-
if options.url.startswith('/v1/messages/batches'):
59-
raise AnthropicError('The Batch API is not supported in Bedrock yet')
60-
61-
if options.url == '/v1/messages/count_tokens':
62-
raise AnthropicError('Token counting is not supported in Bedrock yet')
58+
if options.url.startswith("/v1/messages/batches"):
59+
raise AnthropicError("The Batch API is not supported in Bedrock yet")
60+
61+
if options.url == "/v1/messages/count_tokens":
62+
raise AnthropicError("Token counting is not supported in Bedrock yet")
6363

6464
return options
6565

‎src/anthropic/lib/vertex/_client.py

+6-61
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from ... import _exceptions
1010
from ._auth import load_auth, refresh_auth
1111
from ._beta import Beta, AsyncBeta
12-
from ..._types import NOT_GIVEN, NotGiven, Transport, ProxiesTypes, AsyncTransport
12+
from ..._types import NOT_GIVEN, NotGiven
1313
from ..._utils import is_dict, asyncify, is_given
1414
from ..._compat import model_copy, typed_cached_property
1515
from ..._models import FinalRequestOptions
@@ -18,12 +18,9 @@
1818
from ..._exceptions import AnthropicError, APIStatusError
1919
from ..._base_client import (
2020
DEFAULT_MAX_RETRIES,
21-
DEFAULT_CONNECTION_LIMITS,
2221
BaseClient,
2322
SyncAPIClient,
2423
AsyncAPIClient,
25-
SyncHttpxClientWrapper,
26-
AsyncHttpxClientWrapper,
2724
)
2825
from ...resources.messages import Messages, AsyncMessages
2926

@@ -102,12 +99,6 @@ def __init__(
10299
default_query: Mapping[str, object] | None = None,
103100
# Configure a custom httpx client. See the [httpx documentation](https://www.python-httpx.org/api/#client) for more details.
104101
http_client: httpx.Client | None = None,
105-
# See httpx documentation for [custom transports](https://www.python-httpx.org/advanced/#custom-transports)
106-
transport: Transport | None = None,
107-
# See httpx documentation for [proxies](https://www.python-httpx.org/advanced/#http-proxying)
108-
proxies: ProxiesTypes | None = None,
109-
# See httpx documentation for [limits](https://www.python-httpx.org/advanced/#pool-limit-configuration)
110-
connection_pool_limits: httpx.Limits | None = None,
111102
_strict_response_validation: bool = False,
112103
) -> None:
113104
if not is_given(region):
@@ -130,9 +121,6 @@ def __init__(
130121
custom_headers=default_headers,
131122
custom_query=default_query,
132123
http_client=http_client,
133-
transport=transport,
134-
proxies=proxies,
135-
limits=connection_pool_limits,
136124
_strict_response_validation=_strict_response_validation,
137125
)
138126

@@ -186,7 +174,6 @@ def copy(
186174
base_url: str | httpx.URL | None = None,
187175
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
188176
http_client: httpx.Client | None = None,
189-
connection_pool_limits: httpx.Limits | None = None,
190177
max_retries: int | NotGiven = NOT_GIVEN,
191178
default_headers: Mapping[str, str] | None = None,
192179
set_default_headers: Mapping[str, str] | None = None,
@@ -215,23 +202,7 @@ def copy(
215202
elif set_default_query is not None:
216203
params = set_default_query
217204

218-
if connection_pool_limits is not None:
219-
if http_client is not None:
220-
raise ValueError("The 'http_client' argument is mutually exclusive with 'connection_pool_limits'")
221-
222-
if not isinstance(self._client, SyncHttpxClientWrapper):
223-
raise ValueError(
224-
"A custom HTTP client has been set and is mutually exclusive with the 'connection_pool_limits' argument"
225-
)
226-
227-
http_client = None
228-
else:
229-
if self._limits is not DEFAULT_CONNECTION_LIMITS:
230-
connection_pool_limits = self._limits
231-
else:
232-
connection_pool_limits = None
233-
234-
http_client = http_client or self._client
205+
http_client = http_client or self._client
235206

236207
return self.__class__(
237208
region=region if is_given(region) else self.region,
@@ -270,12 +241,6 @@ def __init__(
270241
default_query: Mapping[str, object] | None = None,
271242
# Configure a custom httpx client. See the [httpx documentation](https://www.python-httpx.org/api/#client) for more details.
272243
http_client: httpx.AsyncClient | None = None,
273-
# See httpx documentation for [custom transports](https://www.python-httpx.org/advanced/#custom-transports)
274-
transport: AsyncTransport | None = None,
275-
# See httpx documentation for [proxies](https://www.python-httpx.org/advanced/#http-proxying)
276-
proxies: ProxiesTypes | None = None,
277-
# See httpx documentation for [limits](https://www.python-httpx.org/advanced/#pool-limit-configuration)
278-
connection_pool_limits: httpx.Limits | None = None,
279244
_strict_response_validation: bool = False,
280245
) -> None:
281246
if not is_given(region):
@@ -298,9 +263,6 @@ def __init__(
298263
custom_headers=default_headers,
299264
custom_query=default_query,
300265
http_client=http_client,
301-
transport=transport,
302-
proxies=proxies,
303-
limits=connection_pool_limits,
304266
_strict_response_validation=_strict_response_validation,
305267
)
306268

@@ -354,7 +316,6 @@ def copy(
354316
base_url: str | httpx.URL | None = None,
355317
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
356318
http_client: httpx.AsyncClient | None = None,
357-
connection_pool_limits: httpx.Limits | None = None,
358319
max_retries: int | NotGiven = NOT_GIVEN,
359320
default_headers: Mapping[str, str] | None = None,
360321
set_default_headers: Mapping[str, str] | None = None,
@@ -383,23 +344,7 @@ def copy(
383344
elif set_default_query is not None:
384345
params = set_default_query
385346

386-
if connection_pool_limits is not None:
387-
if http_client is not None:
388-
raise ValueError("The 'http_client' argument is mutually exclusive with 'connection_pool_limits'")
389-
390-
if not isinstance(self._client, AsyncHttpxClientWrapper):
391-
raise ValueError(
392-
"A custom HTTP client has been set and is mutually exclusive with the 'connection_pool_limits' argument"
393-
)
394-
395-
http_client = None
396-
else:
397-
if self._limits is not DEFAULT_CONNECTION_LIMITS:
398-
connection_pool_limits = self._limits
399-
else:
400-
connection_pool_limits = None
401-
402-
http_client = http_client or self._client
347+
http_client = http_client or self._client
403348

404349
return self.__class__(
405350
region=region if is_given(region) else self.region,
@@ -449,7 +394,7 @@ def _prepare_options(input_options: FinalRequestOptions, *, project_id: str | No
449394

450395
options.url = f"/projects/{project_id}/locations/{region}/publishers/anthropic/models/count-tokens:rawPredict"
451396

452-
if options.url.startswith('/v1/messages/batches'):
453-
raise AnthropicError('The Batch API is not supported in the Vertex client yet')
454-
397+
if options.url.startswith("/v1/messages/batches"):
398+
raise AnthropicError("The Batch API is not supported in the Vertex client yet")
399+
455400
return options

0 commit comments

Comments
 (0)
Please sign in to comment.