anthropic 0.70.0__py3-none-any.whl → 0.71.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.
Files changed (50) hide show
  1. anthropic/_base_client.py +6 -2
  2. anthropic/_version.py +1 -1
  3. anthropic/lib/__init__.py +1 -0
  4. anthropic/lib/_files.py +42 -0
  5. anthropic/pagination.py +117 -1
  6. anthropic/resources/beta/__init__.py +14 -0
  7. anthropic/resources/beta/beta.py +32 -0
  8. anthropic/resources/beta/messages/messages.py +140 -122
  9. anthropic/resources/beta/skills/__init__.py +33 -0
  10. anthropic/resources/beta/skills/skills.py +680 -0
  11. anthropic/resources/beta/skills/versions.py +658 -0
  12. anthropic/resources/completions.py +36 -42
  13. anthropic/resources/messages/messages.py +92 -98
  14. anthropic/types/anthropic_beta_param.py +1 -0
  15. anthropic/types/beta/__init__.py +9 -0
  16. anthropic/types/beta/beta_container.py +5 -0
  17. anthropic/types/beta/beta_container_params.py +18 -0
  18. anthropic/types/beta/beta_message.py +4 -1
  19. anthropic/types/beta/beta_raw_message_delta_event.py +1 -1
  20. anthropic/types/beta/beta_skill.py +18 -0
  21. anthropic/types/beta/beta_skill_params.py +18 -0
  22. anthropic/types/beta/beta_thinking_config_enabled_param.py +1 -1
  23. anthropic/types/beta/message_count_tokens_params.py +14 -10
  24. anthropic/types/beta/message_create_params.py +25 -19
  25. anthropic/types/beta/messages/batch_create_params.py +1 -0
  26. anthropic/types/beta/skill_create_params.py +31 -0
  27. anthropic/types/beta/skill_create_response.py +49 -0
  28. anthropic/types/beta/skill_delete_response.py +19 -0
  29. anthropic/types/beta/skill_list_params.py +38 -0
  30. anthropic/types/beta/skill_list_response.py +49 -0
  31. anthropic/types/beta/skill_retrieve_response.py +49 -0
  32. anthropic/types/beta/skills/__init__.py +10 -0
  33. anthropic/types/beta/skills/version_create_params.py +24 -0
  34. anthropic/types/beta/skills/version_create_response.py +49 -0
  35. anthropic/types/beta/skills/version_delete_response.py +19 -0
  36. anthropic/types/beta/skills/version_list_params.py +25 -0
  37. anthropic/types/beta/skills/version_list_response.py +49 -0
  38. anthropic/types/beta/skills/version_retrieve_response.py +49 -0
  39. anthropic/types/completion_create_params.py +5 -6
  40. anthropic/types/message_count_tokens_params.py +9 -9
  41. anthropic/types/message_create_params.py +13 -15
  42. anthropic/types/messages/batch_create_params.py +1 -0
  43. anthropic/types/model.py +0 -3
  44. anthropic/types/model_param.py +0 -3
  45. anthropic/types/stop_reason.py +1 -3
  46. anthropic/types/thinking_config_enabled_param.py +1 -1
  47. {anthropic-0.70.0.dist-info → anthropic-0.71.1.dist-info}/METADATA +2 -2
  48. {anthropic-0.70.0.dist-info → anthropic-0.71.1.dist-info}/RECORD +50 -30
  49. {anthropic-0.70.0.dist-info → anthropic-0.71.1.dist-info}/WHEEL +0 -0
  50. {anthropic-0.70.0.dist-info → anthropic-0.71.1.dist-info}/licenses/LICENSE +0 -0
anthropic/_base_client.py CHANGED
@@ -843,6 +843,8 @@ class _DefaultHttpxClient(httpx.Client):
843
843
  arg: kwargs[arg] for arg in ("verify", "cert", "trust_env", "http1", "http2", "limits") if arg in kwargs
844
844
  }
845
845
 
846
+ transport_kwargs["socket_options"] = socket_options
847
+
846
848
  proxy_mounts = {
847
849
  key: None if proxy is None else HTTPTransport(proxy=proxy, **transport_kwargs)
848
850
  for key, proxy in proxy_map.items()
@@ -854,7 +856,7 @@ class _DefaultHttpxClient(httpx.Client):
854
856
  kwargs["mounts"] = proxy_mounts
855
857
 
856
858
  # Sets the default transport so that HTTPX won't automatically configure proxies.
857
- kwargs["transport"] = kwargs.get("transport", default_transport)
859
+ kwargs["transport"] = default_transport
858
860
 
859
861
  super().__init__(**kwargs)
860
862
 
@@ -1404,6 +1406,8 @@ class _DefaultAsyncHttpxClient(httpx.AsyncClient):
1404
1406
  arg: kwargs[arg] for arg in ("verify", "cert", "trust_env", "http1", "http2", "limits") if arg in kwargs
1405
1407
  }
1406
1408
 
1409
+ transport_kwargs["socket_options"] = socket_options
1410
+
1407
1411
  proxy_mounts = {
1408
1412
  key: None if proxy is None else AsyncHTTPTransport(proxy=proxy, **transport_kwargs)
1409
1413
  for key, proxy in proxy_map.items()
@@ -1415,7 +1419,7 @@ class _DefaultAsyncHttpxClient(httpx.AsyncClient):
1415
1419
  kwargs["mounts"] = proxy_mounts
1416
1420
 
1417
1421
  # Sets the default transport so that HTTPX won't automatically configure proxies.
1418
- kwargs["transport"] = kwargs.get("transport", default_transport)
1422
+ kwargs["transport"] = default_transport
1419
1423
 
1420
1424
  super().__init__(**kwargs)
1421
1425
 
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.70.0" # x-release-please-version
4
+ __version__ = "0.71.1" # x-release-please-version
anthropic/lib/__init__.py CHANGED
@@ -0,0 +1 @@
1
+ from ._files import files_from_dir as files_from_dir, async_files_from_dir as async_files_from_dir
@@ -0,0 +1,42 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ from pathlib import Path
5
+
6
+ import anyio
7
+
8
+ from .._types import FileTypes
9
+
10
+
11
+ def files_from_dir(directory: str | os.PathLike[str]) -> list[FileTypes]:
12
+ path = Path(directory)
13
+
14
+ files: list[FileTypes] = []
15
+ _collect_files(path, path.parent, files)
16
+ return files
17
+
18
+
19
+ def _collect_files(directory: Path, relative_to: Path, files: list[FileTypes]) -> None:
20
+ for path in directory.iterdir():
21
+ if path.is_dir():
22
+ _collect_files(path, relative_to, files)
23
+ continue
24
+
25
+ files.append((str(path.relative_to(relative_to)), path.read_bytes()))
26
+
27
+
28
+ async def async_files_from_dir(directory: str | os.PathLike[str]) -> list[FileTypes]:
29
+ path = anyio.Path(directory)
30
+
31
+ files: list[FileTypes] = []
32
+ await _async_collect_files(path, path.parent, files)
33
+ return files
34
+
35
+
36
+ async def _async_collect_files(directory: anyio.Path, relative_to: anyio.Path, files: list[FileTypes]) -> None:
37
+ async for path in directory.iterdir():
38
+ if await path.is_dir():
39
+ await _async_collect_files(path, relative_to, files)
40
+ continue
41
+
42
+ files.append((str(path.relative_to(relative_to)), await path.read_bytes()))
anthropic/pagination.py CHANGED
@@ -5,7 +5,7 @@ from typing_extensions import override
5
5
 
6
6
  from ._base_client import BasePage, PageInfo, BaseSyncPage, BaseAsyncPage
7
7
 
8
- __all__ = ["SyncPage", "AsyncPage"]
8
+ __all__ = ["SyncPage", "AsyncPage", "SyncTokenPage", "AsyncTokenPage", "SyncPageCursor", "AsyncPageCursor"]
9
9
 
10
10
  _T = TypeVar("_T")
11
11
 
@@ -82,3 +82,119 @@ class AsyncPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
82
82
  return None
83
83
 
84
84
  return PageInfo(params={"after_id": last_id})
85
+
86
+
87
+ class SyncTokenPage(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
88
+ data: List[_T]
89
+ has_more: Optional[bool] = None
90
+ next_page: Optional[str] = None
91
+
92
+ @override
93
+ def _get_page_items(self) -> List[_T]:
94
+ data = self.data
95
+ if not data:
96
+ return []
97
+ return data
98
+
99
+ @override
100
+ def has_next_page(self) -> bool:
101
+ has_more = self.has_more
102
+ if has_more is not None and has_more is False:
103
+ return False
104
+
105
+ return super().has_next_page()
106
+
107
+ @override
108
+ def next_page_info(self) -> Optional[PageInfo]:
109
+ next_page = self.next_page
110
+ if not next_page:
111
+ return None
112
+
113
+ return PageInfo(params={"page_token": next_page})
114
+
115
+
116
+ class AsyncTokenPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
117
+ data: List[_T]
118
+ has_more: Optional[bool] = None
119
+ next_page: Optional[str] = None
120
+
121
+ @override
122
+ def _get_page_items(self) -> List[_T]:
123
+ data = self.data
124
+ if not data:
125
+ return []
126
+ return data
127
+
128
+ @override
129
+ def has_next_page(self) -> bool:
130
+ has_more = self.has_more
131
+ if has_more is not None and has_more is False:
132
+ return False
133
+
134
+ return super().has_next_page()
135
+
136
+ @override
137
+ def next_page_info(self) -> Optional[PageInfo]:
138
+ next_page = self.next_page
139
+ if not next_page:
140
+ return None
141
+
142
+ return PageInfo(params={"page_token": next_page})
143
+
144
+
145
+ class SyncPageCursor(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
146
+ data: List[_T]
147
+ has_more: Optional[bool] = None
148
+ next_page: Optional[str] = None
149
+
150
+ @override
151
+ def _get_page_items(self) -> List[_T]:
152
+ data = self.data
153
+ if not data:
154
+ return []
155
+ return data
156
+
157
+ @override
158
+ def has_next_page(self) -> bool:
159
+ has_more = self.has_more
160
+ if has_more is not None and has_more is False:
161
+ return False
162
+
163
+ return super().has_next_page()
164
+
165
+ @override
166
+ def next_page_info(self) -> Optional[PageInfo]:
167
+ next_page = self.next_page
168
+ if not next_page:
169
+ return None
170
+
171
+ return PageInfo(params={"page": next_page})
172
+
173
+
174
+ class AsyncPageCursor(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
175
+ data: List[_T]
176
+ has_more: Optional[bool] = None
177
+ next_page: Optional[str] = None
178
+
179
+ @override
180
+ def _get_page_items(self) -> List[_T]:
181
+ data = self.data
182
+ if not data:
183
+ return []
184
+ return data
185
+
186
+ @override
187
+ def has_next_page(self) -> bool:
188
+ has_more = self.has_more
189
+ if has_more is not None and has_more is False:
190
+ return False
191
+
192
+ return super().has_next_page()
193
+
194
+ @override
195
+ def next_page_info(self) -> Optional[PageInfo]:
196
+ next_page = self.next_page
197
+ if not next_page:
198
+ return None
199
+
200
+ return PageInfo(params={"page": next_page})
@@ -24,6 +24,14 @@ from .models import (
24
24
  ModelsWithStreamingResponse,
25
25
  AsyncModelsWithStreamingResponse,
26
26
  )
27
+ from .skills import (
28
+ Skills,
29
+ AsyncSkills,
30
+ SkillsWithRawResponse,
31
+ AsyncSkillsWithRawResponse,
32
+ SkillsWithStreamingResponse,
33
+ AsyncSkillsWithStreamingResponse,
34
+ )
27
35
  from .messages import (
28
36
  Messages,
29
37
  AsyncMessages,
@@ -52,6 +60,12 @@ __all__ = [
52
60
  "AsyncFilesWithRawResponse",
53
61
  "FilesWithStreamingResponse",
54
62
  "AsyncFilesWithStreamingResponse",
63
+ "Skills",
64
+ "AsyncSkills",
65
+ "SkillsWithRawResponse",
66
+ "AsyncSkillsWithRawResponse",
67
+ "SkillsWithStreamingResponse",
68
+ "AsyncSkillsWithStreamingResponse",
55
69
  "Beta",
56
70
  "AsyncBeta",
57
71
  "BetaWithRawResponse",
@@ -20,6 +20,14 @@ from .models import (
20
20
  )
21
21
  from ..._compat import cached_property
22
22
  from ..._resource import SyncAPIResource, AsyncAPIResource
23
+ from .skills.skills import (
24
+ Skills,
25
+ AsyncSkills,
26
+ SkillsWithRawResponse,
27
+ AsyncSkillsWithRawResponse,
28
+ SkillsWithStreamingResponse,
29
+ AsyncSkillsWithStreamingResponse,
30
+ )
23
31
  from .messages.messages import (
24
32
  Messages,
25
33
  AsyncMessages,
@@ -45,6 +53,10 @@ class Beta(SyncAPIResource):
45
53
  def files(self) -> Files:
46
54
  return Files(self._client)
47
55
 
56
+ @cached_property
57
+ def skills(self) -> Skills:
58
+ return Skills(self._client)
59
+
48
60
  @cached_property
49
61
  def with_raw_response(self) -> BetaWithRawResponse:
50
62
  """
@@ -78,6 +90,10 @@ class AsyncBeta(AsyncAPIResource):
78
90
  def files(self) -> AsyncFiles:
79
91
  return AsyncFiles(self._client)
80
92
 
93
+ @cached_property
94
+ def skills(self) -> AsyncSkills:
95
+ return AsyncSkills(self._client)
96
+
81
97
  @cached_property
82
98
  def with_raw_response(self) -> AsyncBetaWithRawResponse:
83
99
  """
@@ -114,6 +130,10 @@ class BetaWithRawResponse:
114
130
  def files(self) -> FilesWithRawResponse:
115
131
  return FilesWithRawResponse(self._beta.files)
116
132
 
133
+ @cached_property
134
+ def skills(self) -> SkillsWithRawResponse:
135
+ return SkillsWithRawResponse(self._beta.skills)
136
+
117
137
 
118
138
  class AsyncBetaWithRawResponse:
119
139
  def __init__(self, beta: AsyncBeta) -> None:
@@ -131,6 +151,10 @@ class AsyncBetaWithRawResponse:
131
151
  def files(self) -> AsyncFilesWithRawResponse:
132
152
  return AsyncFilesWithRawResponse(self._beta.files)
133
153
 
154
+ @cached_property
155
+ def skills(self) -> AsyncSkillsWithRawResponse:
156
+ return AsyncSkillsWithRawResponse(self._beta.skills)
157
+
134
158
 
135
159
  class BetaWithStreamingResponse:
136
160
  def __init__(self, beta: Beta) -> None:
@@ -148,6 +172,10 @@ class BetaWithStreamingResponse:
148
172
  def files(self) -> FilesWithStreamingResponse:
149
173
  return FilesWithStreamingResponse(self._beta.files)
150
174
 
175
+ @cached_property
176
+ def skills(self) -> SkillsWithStreamingResponse:
177
+ return SkillsWithStreamingResponse(self._beta.skills)
178
+
151
179
 
152
180
  class AsyncBetaWithStreamingResponse:
153
181
  def __init__(self, beta: AsyncBeta) -> None:
@@ -164,3 +192,7 @@ class AsyncBetaWithStreamingResponse:
164
192
  @cached_property
165
193
  def files(self) -> AsyncFilesWithStreamingResponse:
166
194
  return AsyncFilesWithStreamingResponse(self._beta.files)
195
+
196
+ @cached_property
197
+ def skills(self) -> AsyncSkillsWithStreamingResponse:
198
+ return AsyncSkillsWithStreamingResponse(self._beta.skills)