anthropic 0.58.2__py3-none-any.whl → 0.60.0__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 CHANGED
@@ -704,7 +704,7 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
704
704
  expected_time = maximum_time * max_tokens / 128_000
705
705
  if expected_time > default_time or (max_nonstreaming_tokens and max_tokens > max_nonstreaming_tokens):
706
706
  raise ValueError(
707
- "Streaming is strongly recommended for operations that may take longer than 10 minutes. "
707
+ "Streaming is required for operations that may take longer than 10 minutes. "
708
708
  + "See https://github.com/anthropics/anthropic-sdk-python#long-requests for more details",
709
709
  )
710
710
  return Timeout(
anthropic/_models.py CHANGED
@@ -224,14 +224,18 @@ class BaseModel(pydantic.BaseModel):
224
224
  else:
225
225
  fields_values[name] = field_get_default(field)
226
226
 
227
+ extra_field_type = _get_extra_fields_type(__cls)
228
+
227
229
  _extra = {}
228
230
  for key, value in values.items():
229
231
  if key not in model_fields:
232
+ parsed = construct_type(value=value, type_=extra_field_type) if extra_field_type is not None else value
233
+
230
234
  if PYDANTIC_V2:
231
- _extra[key] = value
235
+ _extra[key] = parsed
232
236
  else:
233
237
  _fields_set.add(key)
234
- fields_values[key] = value
238
+ fields_values[key] = parsed
235
239
 
236
240
  object.__setattr__(m, "__dict__", fields_values)
237
241
 
@@ -386,6 +390,23 @@ def _construct_field(value: object, field: FieldInfo, key: str) -> object:
386
390
  return construct_type(value=value, type_=type_, metadata=getattr(field, "metadata", None))
387
391
 
388
392
 
393
+ def _get_extra_fields_type(cls: type[pydantic.BaseModel]) -> type | None:
394
+ if not PYDANTIC_V2:
395
+ # TODO
396
+ return None
397
+
398
+ schema = cls.__pydantic_core_schema__
399
+ if schema["type"] == "model":
400
+ fields = schema["schema"]
401
+ if fields["type"] == "model-fields":
402
+ extras = fields.get("extras_schema")
403
+ if extras and "cls" in extras:
404
+ # mypy can't narrow the type
405
+ return extras["cls"] # type: ignore[no-any-return]
406
+
407
+ return None
408
+
409
+
389
410
  def is_basemodel(type_: type) -> bool:
390
411
  """Returns whether or not the given type is either a `BaseModel` or a union of `BaseModel`"""
391
412
  if is_union(type_):
@@ -455,7 +476,7 @@ def construct_type(*, value: object, type_: object, metadata: Optional[List[Any]
455
476
  type_ = type_.__value__ # type: ignore[unreachable]
456
477
 
457
478
  # unwrap `Annotated[T, ...]` -> `T`
458
- if metadata is not None:
479
+ if metadata is not None and len(metadata) > 0:
459
480
  meta: tuple[Any, ...] = tuple(metadata)
460
481
  elif is_annotated_type(type_):
461
482
  meta = get_args(type_)[1:]
anthropic/_version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "anthropic"
4
- __version__ = "0.58.2" # x-release-please-version
4
+ __version__ = "0.60.0" # x-release-please-version
@@ -13,6 +13,8 @@ __all__ = ["Messages", "AsyncMessages"]
13
13
 
14
14
  class Messages(SyncAPIResource):
15
15
  create = FirstPartyMessagesAPI.create
16
+ stream = FirstPartyMessagesAPI.stream
17
+ count_tokens = FirstPartyMessagesAPI.count_tokens
16
18
 
17
19
  @cached_property
18
20
  def with_raw_response(self) -> MessagesWithRawResponse:
@@ -36,6 +38,8 @@ class Messages(SyncAPIResource):
36
38
 
37
39
  class AsyncMessages(AsyncAPIResource):
38
40
  create = FirstPartyAsyncMessagesAPI.create
41
+ stream = FirstPartyAsyncMessagesAPI.stream
42
+ count_tokens = FirstPartyAsyncMessagesAPI.count_tokens
39
43
 
40
44
  @cached_property
41
45
  def with_raw_response(self) -> AsyncMessagesWithRawResponse:
anthropic/types/model.py CHANGED
@@ -22,10 +22,7 @@ Model: TypeAlias = Union[
22
22
  "claude-4-opus-20250514",
23
23
  "claude-3-opus-latest",
24
24
  "claude-3-opus-20240229",
25
- "claude-3-sonnet-20240229",
26
25
  "claude-3-haiku-20240307",
27
- "claude-2.1",
28
- "claude-2.0",
29
26
  ],
30
27
  str,
31
28
  ]
@@ -24,10 +24,7 @@ ModelParam: TypeAlias = Union[
24
24
  "claude-4-opus-20250514",
25
25
  "claude-3-opus-latest",
26
26
  "claude-3-opus-20240229",
27
- "claude-3-sonnet-20240229",
28
27
  "claude-3-haiku-20240307",
29
- "claude-2.1",
30
- "claude-2.0",
31
28
  ],
32
29
  str,
33
30
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: anthropic
3
- Version: 0.58.2
3
+ Version: 0.60.0
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
@@ -1,18 +1,18 @@
1
1
  anthropic/__init__.py,sha256=_3qHjlaUTyCm_xLr3HAcWvxMuKwKJtVRR1TkwU9WEYE,2845
2
- anthropic/_base_client.py,sha256=pF41xe4VsXrplq61mZw7jm3UxuJ0ysNm3mIwwODVtl8,72736
2
+ anthropic/_base_client.py,sha256=LhenlHQa5Plve7VlV-G-JFA6rEQooRRuEhagRk8Xj6g,72724
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=FExEQr8HSiXnN1P9VTueZIKFbZ3qNeeA4BlBCPemqM8,30671
9
+ anthropic/_models.py,sha256=VEovOb5ek_pfb-KvxfBpCYYUszw2KMUT6x_zzUzCLzk,31387
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=GVRhP92EPnCdxzU58ixXvu5VU_fmwOiQq6L7CsxUYoY,162
15
+ anthropic/_version.py,sha256=KhuHnm-Rfa7b-qw4-BEkvW3x5Uzeh06Uxlq2zPvpX_w,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
@@ -47,7 +47,7 @@ anthropic/lib/streaming/_types.py,sha256=CrR4948IWgUF7L9O0ase2QwbpiQ1JeiYXrRyVi7
47
47
  anthropic/lib/vertex/__init__.py,sha256=A8vuK1qVPtmKr1_LQgPuDRVA6I4xm_ye2aPdAa4yGsI,102
48
48
  anthropic/lib/vertex/_auth.py,sha256=Kyt_hbUc-DPlkvds4__OLR8FLPpoDas6bXhZTECxO3Y,1644
49
49
  anthropic/lib/vertex/_beta.py,sha256=8kXsUUIGstf6dZfiZtm6s9OWEueuSgra8dPvkaUacy4,3323
50
- anthropic/lib/vertex/_beta_messages.py,sha256=ClPL21UrRbJ9M10G8PcRla_Fu9GoWN_420FUuw91bmY,3197
50
+ anthropic/lib/vertex/_beta_messages.py,sha256=4fsV2F6TzB14DuHLo9k8i95vymcbixIPjsplqpsHfac,3399
51
51
  anthropic/lib/vertex/_client.py,sha256=bvemByz7HdwDIHMojcvBUN7khsI32jFglgtRVDH5o04,16619
52
52
  anthropic/resources/__init__.py,sha256=H0t_V-A_u6bIVmbAUpY9ZfgqoNIjIfyNpZz7hAiErIA,1583
53
53
  anthropic/resources/completions.py,sha256=lrht7C7OY4tNEHXGYUVkciCmnMXwYcte4myEQ7T75LI,37132
@@ -112,10 +112,10 @@ anthropic/types/message_stop_event.py,sha256=rtYh1F-b9xilu8s_RdaHijP7kf3om6FvK9c
112
112
  anthropic/types/message_stream_event.py,sha256=OspCo1IFpItyJDr4Ta16o8DQmTsgVWSmeNg4BhfMM0M,285
113
113
  anthropic/types/message_tokens_count.py,sha256=JmkcWw9nZAUgr2WY5G4Mwqs2jcnMuZXh920MlUkvY70,329
114
114
  anthropic/types/metadata_param.py,sha256=p6j8bWh3FfI3PB-vJjU4JhRukP2NZdrcE2gQixw5zgw,594
115
- anthropic/types/model.py,sha256=qGByP0e8rhW5KCng371UiR-X2QoCjKos_2BqInA1Aac,875
115
+ anthropic/types/model.py,sha256=SahaHoHnqIh71yKDM0_zsNJVJjqXESmxHYnEMWaIxJ4,795
116
116
  anthropic/types/model_info.py,sha256=JrqNQwWcOiC5ItKTZqRfeAQhPWzi0AyzzOTF6AdE-ss,646
117
117
  anthropic/types/model_list_params.py,sha256=O2GJOAHr6pB7yGAJhLjcwsDJ8ACtE1GrOrI2JDkj0w8,974
118
- anthropic/types/model_param.py,sha256=kGmDl7pCzLPhUF6x9zhd6ad5rfmJFF6TH_9UzFnwXZs,921
118
+ anthropic/types/model_param.py,sha256=EFUM-xa-i8TNOjU9UCd22gJhnzk2ZARWHVS07ZRjDLs,841
119
119
  anthropic/types/plain_text_source_param.py,sha256=zdzLMfSQZH2_9Z8ssVc5hLG1w_AuFZ2Z3E17lEntAzg,382
120
120
  anthropic/types/raw_content_block_delta.py,sha256=T1i1gSGq9u9obYbxgXYAwux-WIRqSRWJW9tBjBDXoP8,611
121
121
  anthropic/types/raw_content_block_delta_event.py,sha256=XKpY_cCljZ6NFtVCt5R38imPbnZAbFyQVIB5d4K4ZgY,393
@@ -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.58.2.dist-info/METADATA,sha256=-EgWJXMXAOa4CQH9xvSUTnyL_hxENE2Kr1c07yPBUFU,27053
326
- anthropic-0.58.2.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
327
- anthropic-0.58.2.dist-info/licenses/LICENSE,sha256=i_lphP-Lz65-SMrnalKeiiUxe6ngKr9_08xk_flWV6Y,1056
328
- anthropic-0.58.2.dist-info/RECORD,,
325
+ anthropic-0.60.0.dist-info/METADATA,sha256=WI6r68K57TrPbEYymhONSUXu-iqFDfDnOk5ZlKi9Ps4,27053
326
+ anthropic-0.60.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
327
+ anthropic-0.60.0.dist-info/licenses/LICENSE,sha256=i_lphP-Lz65-SMrnalKeiiUxe6ngKr9_08xk_flWV6Y,1056
328
+ anthropic-0.60.0.dist-info/RECORD,,