anthropic 0.57.1__py3-none-any.whl → 0.58.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- anthropic/_base_client.py +9 -2
- anthropic/_models.py +7 -4
- anthropic/_version.py +1 -1
- {anthropic-0.57.1.dist-info → anthropic-0.58.1.dist-info}/METADATA +7 -6
- {anthropic-0.57.1.dist-info → anthropic-0.58.1.dist-info}/RECORD +7 -7
- {anthropic-0.57.1.dist-info → anthropic-0.58.1.dist-info}/WHEEL +0 -0
- {anthropic-0.57.1.dist-info → anthropic-0.58.1.dist-info}/licenses/LICENSE +0 -0
anthropic/_base_client.py
CHANGED
|
@@ -542,6 +542,15 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
|
|
|
542
542
|
# work around https://github.com/encode/httpx/discussions/2880
|
|
543
543
|
kwargs["extensions"] = {"sni_hostname": prepared_url.host.replace("_", "-")}
|
|
544
544
|
|
|
545
|
+
is_body_allowed = options.method.lower() != "get"
|
|
546
|
+
|
|
547
|
+
if is_body_allowed:
|
|
548
|
+
kwargs["json"] = json_data if is_given(json_data) else None
|
|
549
|
+
kwargs["files"] = files
|
|
550
|
+
else:
|
|
551
|
+
headers.pop("Content-Type", None)
|
|
552
|
+
kwargs.pop("data", None)
|
|
553
|
+
|
|
545
554
|
# TODO: report this error to httpx
|
|
546
555
|
return self._client.build_request( # pyright: ignore[reportUnknownMemberType]
|
|
547
556
|
headers=headers,
|
|
@@ -553,8 +562,6 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
|
|
|
553
562
|
# so that passing a `TypedDict` doesn't cause an error.
|
|
554
563
|
# https://github.com/microsoft/pyright/issues/3526#event-6715453066
|
|
555
564
|
params=self.qs.stringify(cast(Mapping[str, Any], params)) if params else None,
|
|
556
|
-
json=json_data if is_given(json_data) else None,
|
|
557
|
-
files=files,
|
|
558
565
|
**kwargs,
|
|
559
566
|
)
|
|
560
567
|
|
anthropic/_models.py
CHANGED
|
@@ -5,6 +5,7 @@ import inspect
|
|
|
5
5
|
from typing import TYPE_CHECKING, Any, Type, Union, Generic, TypeVar, Callable, Optional, cast
|
|
6
6
|
from datetime import date, datetime
|
|
7
7
|
from typing_extensions import (
|
|
8
|
+
List,
|
|
8
9
|
Unpack,
|
|
9
10
|
Literal,
|
|
10
11
|
ClassVar,
|
|
@@ -382,7 +383,7 @@ def _construct_field(value: object, field: FieldInfo, key: str) -> object:
|
|
|
382
383
|
if type_ is None:
|
|
383
384
|
raise RuntimeError(f"Unexpected field type is None for {key}")
|
|
384
385
|
|
|
385
|
-
return construct_type(value=value, type_=type_)
|
|
386
|
+
return construct_type(value=value, type_=type_, metadata=getattr(field, "metadata", None))
|
|
386
387
|
|
|
387
388
|
|
|
388
389
|
def is_basemodel(type_: type) -> bool:
|
|
@@ -436,7 +437,7 @@ def construct_type_unchecked(*, value: object, type_: type[_T]) -> _T:
|
|
|
436
437
|
return cast(_T, construct_type(value=value, type_=type_))
|
|
437
438
|
|
|
438
439
|
|
|
439
|
-
def construct_type(*, value: object, type_: object) -> object:
|
|
440
|
+
def construct_type(*, value: object, type_: object, metadata: Optional[List[Any]] = None) -> object:
|
|
440
441
|
"""Loose coercion to the expected type with construction of nested values.
|
|
441
442
|
|
|
442
443
|
If the given value does not match the expected type then it is returned as-is.
|
|
@@ -454,8 +455,10 @@ def construct_type(*, value: object, type_: object) -> object:
|
|
|
454
455
|
type_ = type_.__value__ # type: ignore[unreachable]
|
|
455
456
|
|
|
456
457
|
# unwrap `Annotated[T, ...]` -> `T`
|
|
457
|
-
if
|
|
458
|
-
meta: tuple[Any, ...] =
|
|
458
|
+
if metadata is not None:
|
|
459
|
+
meta: tuple[Any, ...] = tuple(metadata)
|
|
460
|
+
elif is_annotated_type(type_):
|
|
461
|
+
meta = get_args(type_)[1:]
|
|
459
462
|
type_ = extract_type_arg(type_, 0)
|
|
460
463
|
else:
|
|
461
464
|
meta = tuple()
|
anthropic/_version.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: anthropic
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.58.1
|
|
4
4
|
Summary: The official Python library for the anthropic API
|
|
5
5
|
Project-URL: Homepage, https://github.com/anthropics/anthropic-sdk-python
|
|
6
6
|
Project-URL: Repository, https://github.com/anthropics/anthropic-sdk-python
|
|
@@ -18,6 +18,7 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.10
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.11
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
22
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
23
|
Classifier: Typing :: Typed
|
|
23
24
|
Requires-Python: >=3.8
|
|
@@ -30,7 +31,7 @@ Requires-Dist: sniffio
|
|
|
30
31
|
Requires-Dist: typing-extensions<5,>=4.10
|
|
31
32
|
Provides-Extra: aiohttp
|
|
32
33
|
Requires-Dist: aiohttp; extra == 'aiohttp'
|
|
33
|
-
Requires-Dist: httpx-aiohttp>=0.1.
|
|
34
|
+
Requires-Dist: httpx-aiohttp>=0.1.8; extra == 'aiohttp'
|
|
34
35
|
Provides-Extra: bedrock
|
|
35
36
|
Requires-Dist: boto3>=1.28.57; extra == 'bedrock'
|
|
36
37
|
Requires-Dist: botocore>=1.31.57; extra == 'bedrock'
|
|
@@ -40,7 +41,8 @@ Description-Content-Type: text/markdown
|
|
|
40
41
|
|
|
41
42
|
# Anthropic Python API library
|
|
42
43
|
|
|
43
|
-
|
|
44
|
+
<!-- prettier-ignore -->
|
|
45
|
+
[)](https://pypi.org/project/anthropic/)
|
|
44
46
|
|
|
45
47
|
The Anthropic Python library provides convenient access to the Anthropic REST API from any Python 3.8+
|
|
46
48
|
application. It includes type definitions for all request params and response fields,
|
|
@@ -134,7 +136,6 @@ pip install anthropic[aiohttp]
|
|
|
134
136
|
Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:
|
|
135
137
|
|
|
136
138
|
```python
|
|
137
|
-
import os
|
|
138
139
|
import asyncio
|
|
139
140
|
from anthropic import DefaultAioHttpClient
|
|
140
141
|
from anthropic import AsyncAnthropic
|
|
@@ -142,7 +143,7 @@ from anthropic import AsyncAnthropic
|
|
|
142
143
|
|
|
143
144
|
async def main() -> None:
|
|
144
145
|
async with AsyncAnthropic(
|
|
145
|
-
api_key=
|
|
146
|
+
api_key="my-anthropic-api-key",
|
|
146
147
|
http_client=DefaultAioHttpClient(),
|
|
147
148
|
) as client:
|
|
148
149
|
message = await client.messages.create(
|
|
@@ -329,7 +330,7 @@ message = client.messages.create(
|
|
|
329
330
|
"content": "Hello!",
|
|
330
331
|
}
|
|
331
332
|
],
|
|
332
|
-
model="anthropic.claude-sonnet-4-20250514-
|
|
333
|
+
model="anthropic.claude-sonnet-4-20250514-v1:0",
|
|
333
334
|
)
|
|
334
335
|
print(message)
|
|
335
336
|
```
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
anthropic/__init__.py,sha256=_3qHjlaUTyCm_xLr3HAcWvxMuKwKJtVRR1TkwU9WEYE,2845
|
|
2
|
-
anthropic/_base_client.py,sha256=
|
|
2
|
+
anthropic/_base_client.py,sha256=pF41xe4VsXrplq61mZw7jm3UxuJ0ysNm3mIwwODVtl8,72736
|
|
3
3
|
anthropic/_client.py,sha256=kZlulmKAcSG7WdzYCUdXFFfATn5ZP1PO7gHQbqAe2Dc,22827
|
|
4
4
|
anthropic/_compat.py,sha256=VWemUKbj6DDkQ-O4baSpHVLJafotzeXmCQGJugfVTIw,6580
|
|
5
5
|
anthropic/_constants.py,sha256=dZ53c7dQnlC6xcGkes61-8goAEIOwzTfsmcBfzdU9Ho,756
|
|
6
6
|
anthropic/_exceptions.py,sha256=bkSqVWxtRdRb31H7MIvtxfh5mo_Xf7Ib3nPTOmAOmGs,4073
|
|
7
7
|
anthropic/_files.py,sha256=rfm6t3u1wPlq2X5l3qnymAmDY8caH9V_lickXC24o6I,3627
|
|
8
8
|
anthropic/_legacy_response.py,sha256=QsroQ_9LHI8tSoPEvbIXXB44SvLJXaXQX7khjZpnqfE,17235
|
|
9
|
-
anthropic/_models.py,sha256=
|
|
9
|
+
anthropic/_models.py,sha256=FExEQr8HSiXnN1P9VTueZIKFbZ3qNeeA4BlBCPemqM8,30671
|
|
10
10
|
anthropic/_qs.py,sha256=AOkSz4rHtK4YI3ZU_kzea-zpwBUgEY8WniGmTPyEimc,4846
|
|
11
11
|
anthropic/_resource.py,sha256=FYEOzfhB-XWTR2gyTmQuuFoecRiVXxe_SpjZlQQGytU,1080
|
|
12
12
|
anthropic/_response.py,sha256=1Y7-OrGn1lOwvZ_SmMlwT9Nb2i9A1RYw2Q4-F1cwPSU,30542
|
|
13
13
|
anthropic/_streaming.py,sha256=vn8K5KgfO3Bv9NE8nwHIQEjEhkQeVE6YMnGqiJlCgqE,14023
|
|
14
14
|
anthropic/_types.py,sha256=WeAcP68yMpfs3hNEltM_k2nYMiG4xda4cFdf5kHbjP8,6299
|
|
15
|
-
anthropic/_version.py,sha256=
|
|
15
|
+
anthropic/_version.py,sha256=41vDeJQRm8pDlElSAvItp5QUAOJrg_etSPWP4RkrWpY,162
|
|
16
16
|
anthropic/pagination.py,sha256=hW6DOtNbwwQrNQ8wn4PJj7WB2y_37szSDQeUBnunQ40,2202
|
|
17
17
|
anthropic/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
18
|
anthropic/_decoders/jsonl.py,sha256=KDLw-Frjo7gRup5qDp_BWkXIZ-mFZU5vFDz0WBhEKcs,3510
|
|
@@ -322,7 +322,7 @@ anthropic/types/shared/not_found_error.py,sha256=R6OsCvAmsf_SB2TwoX6E63o049qZMaA
|
|
|
322
322
|
anthropic/types/shared/overloaded_error.py,sha256=PlyhHt3wmzcnynSfkWbfP4XkLoWsPa9B39V3CyAdgx8,282
|
|
323
323
|
anthropic/types/shared/permission_error.py,sha256=nuyxtLXOiEkYEbFRXiAWjxU6XtdyjkAaXQ2NgMB3pjw,282
|
|
324
324
|
anthropic/types/shared/rate_limit_error.py,sha256=eYULATjXa6KKdqeBauest7RzuN-bhGsY5BWwH9eYv4c,280
|
|
325
|
-
anthropic-0.
|
|
326
|
-
anthropic-0.
|
|
327
|
-
anthropic-0.
|
|
328
|
-
anthropic-0.
|
|
325
|
+
anthropic-0.58.1.dist-info/METADATA,sha256=YNj_q2J5kWJ_A9DomoxmU_zhzkqwdfz0Z4KnUhyZRkk,27053
|
|
326
|
+
anthropic-0.58.1.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
|
327
|
+
anthropic-0.58.1.dist-info/licenses/LICENSE,sha256=i_lphP-Lz65-SMrnalKeiiUxe6ngKr9_08xk_flWV6Y,1056
|
|
328
|
+
anthropic-0.58.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|