anthropic 0.64.0__py3-none-any.whl → 0.65.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/_models.py +1 -1
- anthropic/_types.py +35 -1
- anthropic/_utils/__init__.py +1 -0
- anthropic/_utils/_transform.py +6 -0
- anthropic/_utils/_typing.py +5 -0
- anthropic/_version.py +1 -1
- anthropic/lib/streaming/_beta_messages.py +0 -1
- anthropic/resources/beta/messages/messages.py +19 -203
- anthropic/resources/completions.py +9 -9
- anthropic/resources/messages/messages.py +20 -204
- anthropic/types/beta/__init__.py +53 -0
- anthropic/types/beta/beta_bash_code_execution_output_block.py +13 -0
- anthropic/types/beta/beta_bash_code_execution_output_block_param.py +13 -0
- anthropic/types/beta/beta_bash_code_execution_result_block.py +21 -0
- anthropic/types/beta/beta_bash_code_execution_result_block_param.py +22 -0
- anthropic/types/beta/beta_bash_code_execution_tool_result_block.py +20 -0
- anthropic/types/beta/beta_bash_code_execution_tool_result_block_param.py +25 -0
- anthropic/types/beta/beta_bash_code_execution_tool_result_error.py +15 -0
- anthropic/types/beta/beta_bash_code_execution_tool_result_error_param.py +17 -0
- anthropic/types/beta/beta_code_execution_tool_20250825_param.py +23 -0
- anthropic/types/beta/beta_content_block.py +4 -0
- anthropic/types/beta/beta_content_block_param.py +4 -0
- anthropic/types/beta/beta_raw_content_block_start_event.py +4 -0
- anthropic/types/beta/beta_request_mcp_server_tool_configuration_param.py +4 -2
- anthropic/types/beta/beta_server_tool_use_block.py +1 -1
- anthropic/types/beta/beta_server_tool_use_block_param.py +1 -1
- anthropic/types/beta/beta_text_editor_code_execution_create_result_block.py +13 -0
- anthropic/types/beta/beta_text_editor_code_execution_create_result_block_param.py +13 -0
- anthropic/types/beta/beta_text_editor_code_execution_str_replace_result_block.py +22 -0
- anthropic/types/beta/beta_text_editor_code_execution_str_replace_result_block_param.py +24 -0
- anthropic/types/beta/beta_text_editor_code_execution_tool_result_block.py +27 -0
- anthropic/types/beta/beta_text_editor_code_execution_tool_result_block_param.py +34 -0
- anthropic/types/beta/beta_text_editor_code_execution_tool_result_error.py +18 -0
- anthropic/types/beta/beta_text_editor_code_execution_tool_result_error_param.py +18 -0
- anthropic/types/beta/beta_text_editor_code_execution_view_result_block.py +22 -0
- anthropic/types/beta/beta_text_editor_code_execution_view_result_block_param.py +22 -0
- anthropic/types/beta/beta_tool_param.py +3 -2
- anthropic/types/beta/beta_tool_union_param.py +2 -0
- anthropic/types/beta/beta_web_search_tool_20250305_param.py +4 -3
- anthropic/types/beta/message_count_tokens_params.py +3 -24
- anthropic/types/beta/message_create_params.py +3 -25
- anthropic/types/beta_error_response.py +3 -0
- anthropic/types/completion_create_params.py +2 -1
- anthropic/types/message_count_tokens_params.py +1 -24
- anthropic/types/message_create_params.py +4 -26
- anthropic/types/shared/error_response.py +3 -0
- anthropic/types/tool_param.py +3 -2
- anthropic/types/web_search_tool_20250305_param.py +4 -3
- {anthropic-0.64.0.dist-info → anthropic-0.65.0.dist-info}/METADATA +1 -1
- {anthropic-0.64.0.dist-info → anthropic-0.65.0.dist-info}/RECORD +52 -33
- {anthropic-0.64.0.dist-info → anthropic-0.65.0.dist-info}/WHEEL +0 -0
- {anthropic-0.64.0.dist-info → anthropic-0.65.0.dist-info}/licenses/LICENSE +0 -0
anthropic/_models.py
CHANGED
|
@@ -320,7 +320,7 @@ class BaseModel(pydantic.BaseModel):
|
|
|
320
320
|
exclude_none=exclude_none,
|
|
321
321
|
)
|
|
322
322
|
|
|
323
|
-
return cast(dict[str, Any], json_safe(dumped)) if mode == "json" else dumped
|
|
323
|
+
return cast("dict[str, Any]", json_safe(dumped)) if mode == "json" else dumped
|
|
324
324
|
|
|
325
325
|
@override
|
|
326
326
|
def model_dump_json(
|
anthropic/_types.py
CHANGED
|
@@ -13,10 +13,21 @@ from typing import (
|
|
|
13
13
|
Mapping,
|
|
14
14
|
TypeVar,
|
|
15
15
|
Callable,
|
|
16
|
+
Iterator,
|
|
16
17
|
Optional,
|
|
17
18
|
Sequence,
|
|
18
19
|
)
|
|
19
|
-
from typing_extensions import
|
|
20
|
+
from typing_extensions import (
|
|
21
|
+
Set,
|
|
22
|
+
Literal,
|
|
23
|
+
Protocol,
|
|
24
|
+
TypeAlias,
|
|
25
|
+
TypedDict,
|
|
26
|
+
SupportsIndex,
|
|
27
|
+
overload,
|
|
28
|
+
override,
|
|
29
|
+
runtime_checkable,
|
|
30
|
+
)
|
|
20
31
|
|
|
21
32
|
import httpx
|
|
22
33
|
import pydantic
|
|
@@ -219,3 +230,26 @@ class _GenericAlias(Protocol):
|
|
|
219
230
|
class HttpxSendArgs(TypedDict, total=False):
|
|
220
231
|
auth: httpx.Auth
|
|
221
232
|
follow_redirects: bool
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
_T_co = TypeVar("_T_co", covariant=True)
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
if TYPE_CHECKING:
|
|
239
|
+
# This works because str.__contains__ does not accept object (either in typeshed or at runtime)
|
|
240
|
+
# https://github.com/hauntsaninja/useful_types/blob/5e9710f3875107d068e7679fd7fec9cfab0eff3b/useful_types/__init__.py#L285
|
|
241
|
+
class SequenceNotStr(Protocol[_T_co]):
|
|
242
|
+
@overload
|
|
243
|
+
def __getitem__(self, index: SupportsIndex, /) -> _T_co: ...
|
|
244
|
+
@overload
|
|
245
|
+
def __getitem__(self, index: slice, /) -> Sequence[_T_co]: ...
|
|
246
|
+
def __contains__(self, value: object, /) -> bool: ...
|
|
247
|
+
def __len__(self) -> int: ...
|
|
248
|
+
def __iter__(self) -> Iterator[_T_co]: ...
|
|
249
|
+
def index(self, value: Any, start: int = 0, stop: int = ..., /) -> int: ...
|
|
250
|
+
def count(self, value: Any, /) -> int: ...
|
|
251
|
+
def __reversed__(self) -> Iterator[_T_co]: ...
|
|
252
|
+
else:
|
|
253
|
+
# just point this to a normal `Sequence` at runtime to avoid having to special case
|
|
254
|
+
# deserializing our custom sequence type
|
|
255
|
+
SequenceNotStr = Sequence
|
anthropic/_utils/__init__.py
CHANGED
|
@@ -38,6 +38,7 @@ from ._typing import (
|
|
|
38
38
|
extract_type_arg as extract_type_arg,
|
|
39
39
|
is_iterable_type as is_iterable_type,
|
|
40
40
|
is_required_type as is_required_type,
|
|
41
|
+
is_sequence_type as is_sequence_type,
|
|
41
42
|
is_annotated_type as is_annotated_type,
|
|
42
43
|
is_type_alias_type as is_type_alias_type,
|
|
43
44
|
strip_annotated_type as strip_annotated_type,
|
anthropic/_utils/_transform.py
CHANGED
|
@@ -16,6 +16,7 @@ from ._utils import (
|
|
|
16
16
|
lru_cache,
|
|
17
17
|
is_mapping,
|
|
18
18
|
is_iterable,
|
|
19
|
+
is_sequence,
|
|
19
20
|
)
|
|
20
21
|
from .._files import is_base64_file_input
|
|
21
22
|
from ._typing import (
|
|
@@ -24,6 +25,7 @@ from ._typing import (
|
|
|
24
25
|
extract_type_arg,
|
|
25
26
|
is_iterable_type,
|
|
26
27
|
is_required_type,
|
|
28
|
+
is_sequence_type,
|
|
27
29
|
is_annotated_type,
|
|
28
30
|
strip_annotated_type,
|
|
29
31
|
)
|
|
@@ -184,6 +186,8 @@ def _transform_recursive(
|
|
|
184
186
|
(is_list_type(stripped_type) and is_list(data))
|
|
185
187
|
# Iterable[T]
|
|
186
188
|
or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
|
|
189
|
+
# Sequence[T]
|
|
190
|
+
or (is_sequence_type(stripped_type) and is_sequence(data) and not isinstance(data, str))
|
|
187
191
|
):
|
|
188
192
|
# dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
|
|
189
193
|
# intended as an iterable, so we don't transform it.
|
|
@@ -346,6 +350,8 @@ async def _async_transform_recursive(
|
|
|
346
350
|
(is_list_type(stripped_type) and is_list(data))
|
|
347
351
|
# Iterable[T]
|
|
348
352
|
or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
|
|
353
|
+
# Sequence[T]
|
|
354
|
+
or (is_sequence_type(stripped_type) and is_sequence(data) and not isinstance(data, str))
|
|
349
355
|
):
|
|
350
356
|
# dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
|
|
351
357
|
# intended as an iterable, so we don't transform it.
|
anthropic/_utils/_typing.py
CHANGED
|
@@ -26,6 +26,11 @@ def is_list_type(typ: type) -> bool:
|
|
|
26
26
|
return (get_origin(typ) or typ) == list
|
|
27
27
|
|
|
28
28
|
|
|
29
|
+
def is_sequence_type(typ: type) -> bool:
|
|
30
|
+
origin = get_origin(typ) or typ
|
|
31
|
+
return origin == typing_extensions.Sequence or origin == typing.Sequence or origin == _c_abc.Sequence
|
|
32
|
+
|
|
33
|
+
|
|
29
34
|
def is_iterable_type(typ: type) -> bool:
|
|
30
35
|
"""If the given type is `typing.Iterable[T]`"""
|
|
31
36
|
origin = get_origin(typ) or typ
|
anthropic/_version.py
CHANGED
|
@@ -245,7 +245,6 @@ class BetaAsyncMessageStream:
|
|
|
245
245
|
f".get_final_text() can only be called when the API returns a `text` content block.\nThe API returned {','.join([b.type for b in message.content])} content block type(s) that you can access by calling get_final_message().content"
|
|
246
246
|
)
|
|
247
247
|
|
|
248
|
-
|
|
249
248
|
return "".join(text_blocks)
|
|
250
249
|
|
|
251
250
|
async def until_done(self) -> None:
|
|
@@ -19,7 +19,7 @@ from .batches import (
|
|
|
19
19
|
BatchesWithStreamingResponse,
|
|
20
20
|
AsyncBatchesWithStreamingResponse,
|
|
21
21
|
)
|
|
22
|
-
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
|
|
22
|
+
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
|
|
23
23
|
from ...._utils import is_given, required_args, maybe_transform, strip_not_given, async_maybe_transform
|
|
24
24
|
from ...._compat import cached_property
|
|
25
25
|
from ...._resource import SyncAPIResource, AsyncAPIResource
|
|
@@ -85,7 +85,7 @@ class Messages(SyncAPIResource):
|
|
|
85
85
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | NotGiven = NOT_GIVEN,
|
|
86
86
|
metadata: BetaMetadataParam | NotGiven = NOT_GIVEN,
|
|
87
87
|
service_tier: Literal["auto", "standard_only"] | NotGiven = NOT_GIVEN,
|
|
88
|
-
stop_sequences:
|
|
88
|
+
stop_sequences: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
|
|
89
89
|
stream: Literal[False] | NotGiven = NOT_GIVEN,
|
|
90
90
|
system: Union[str, Iterable[BetaTextBlockParam]] | NotGiven = NOT_GIVEN,
|
|
91
91
|
temperature: float | NotGiven = NOT_GIVEN,
|
|
@@ -177,30 +177,7 @@ class Messages(SyncAPIResource):
|
|
|
177
177
|
{ "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
|
|
178
178
|
```
|
|
179
179
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
```json
|
|
183
|
-
{
|
|
184
|
-
"role": "user",
|
|
185
|
-
"content": [
|
|
186
|
-
{
|
|
187
|
-
"type": "image",
|
|
188
|
-
"source": {
|
|
189
|
-
"type": "base64",
|
|
190
|
-
"media_type": "image/jpeg",
|
|
191
|
-
"data": "/9j/4AAQSkZJRg..."
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
{ "type": "text", "text": "What is in this image?" }
|
|
195
|
-
]
|
|
196
|
-
}
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
We currently support the `base64` source type for images, and the `image/jpeg`,
|
|
200
|
-
`image/png`, `image/gif`, and `image/webp` media types.
|
|
201
|
-
|
|
202
|
-
See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
|
|
203
|
-
more input examples.
|
|
180
|
+
See [input examples](https://docs.anthropic.com/en/api/messages-examples).
|
|
204
181
|
|
|
205
182
|
Note that if you want to include a
|
|
206
183
|
[system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
|
|
@@ -386,7 +363,7 @@ class Messages(SyncAPIResource):
|
|
|
386
363
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | NotGiven = NOT_GIVEN,
|
|
387
364
|
metadata: BetaMetadataParam | NotGiven = NOT_GIVEN,
|
|
388
365
|
service_tier: Literal["auto", "standard_only"] | NotGiven = NOT_GIVEN,
|
|
389
|
-
stop_sequences:
|
|
366
|
+
stop_sequences: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
|
|
390
367
|
system: Union[str, Iterable[BetaTextBlockParam]] | NotGiven = NOT_GIVEN,
|
|
391
368
|
temperature: float | NotGiven = NOT_GIVEN,
|
|
392
369
|
thinking: BetaThinkingConfigParam | NotGiven = NOT_GIVEN,
|
|
@@ -477,30 +454,7 @@ class Messages(SyncAPIResource):
|
|
|
477
454
|
{ "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
|
|
478
455
|
```
|
|
479
456
|
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
```json
|
|
483
|
-
{
|
|
484
|
-
"role": "user",
|
|
485
|
-
"content": [
|
|
486
|
-
{
|
|
487
|
-
"type": "image",
|
|
488
|
-
"source": {
|
|
489
|
-
"type": "base64",
|
|
490
|
-
"media_type": "image/jpeg",
|
|
491
|
-
"data": "/9j/4AAQSkZJRg..."
|
|
492
|
-
}
|
|
493
|
-
},
|
|
494
|
-
{ "type": "text", "text": "What is in this image?" }
|
|
495
|
-
]
|
|
496
|
-
}
|
|
497
|
-
```
|
|
498
|
-
|
|
499
|
-
We currently support the `base64` source type for images, and the `image/jpeg`,
|
|
500
|
-
`image/png`, `image/gif`, and `image/webp` media types.
|
|
501
|
-
|
|
502
|
-
See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
|
|
503
|
-
more input examples.
|
|
457
|
+
See [input examples](https://docs.anthropic.com/en/api/messages-examples).
|
|
504
458
|
|
|
505
459
|
Note that if you want to include a
|
|
506
460
|
[system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
|
|
@@ -686,7 +640,7 @@ class Messages(SyncAPIResource):
|
|
|
686
640
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | NotGiven = NOT_GIVEN,
|
|
687
641
|
metadata: BetaMetadataParam | NotGiven = NOT_GIVEN,
|
|
688
642
|
service_tier: Literal["auto", "standard_only"] | NotGiven = NOT_GIVEN,
|
|
689
|
-
stop_sequences:
|
|
643
|
+
stop_sequences: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
|
|
690
644
|
system: Union[str, Iterable[BetaTextBlockParam]] | NotGiven = NOT_GIVEN,
|
|
691
645
|
temperature: float | NotGiven = NOT_GIVEN,
|
|
692
646
|
thinking: BetaThinkingConfigParam | NotGiven = NOT_GIVEN,
|
|
@@ -777,30 +731,7 @@ class Messages(SyncAPIResource):
|
|
|
777
731
|
{ "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
|
|
778
732
|
```
|
|
779
733
|
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
```json
|
|
783
|
-
{
|
|
784
|
-
"role": "user",
|
|
785
|
-
"content": [
|
|
786
|
-
{
|
|
787
|
-
"type": "image",
|
|
788
|
-
"source": {
|
|
789
|
-
"type": "base64",
|
|
790
|
-
"media_type": "image/jpeg",
|
|
791
|
-
"data": "/9j/4AAQSkZJRg..."
|
|
792
|
-
}
|
|
793
|
-
},
|
|
794
|
-
{ "type": "text", "text": "What is in this image?" }
|
|
795
|
-
]
|
|
796
|
-
}
|
|
797
|
-
```
|
|
798
|
-
|
|
799
|
-
We currently support the `base64` source type for images, and the `image/jpeg`,
|
|
800
|
-
`image/png`, `image/gif`, and `image/webp` media types.
|
|
801
|
-
|
|
802
|
-
See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
|
|
803
|
-
more input examples.
|
|
734
|
+
See [input examples](https://docs.anthropic.com/en/api/messages-examples).
|
|
804
735
|
|
|
805
736
|
Note that if you want to include a
|
|
806
737
|
[system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
|
|
@@ -985,7 +916,7 @@ class Messages(SyncAPIResource):
|
|
|
985
916
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | NotGiven = NOT_GIVEN,
|
|
986
917
|
metadata: BetaMetadataParam | NotGiven = NOT_GIVEN,
|
|
987
918
|
service_tier: Literal["auto", "standard_only"] | NotGiven = NOT_GIVEN,
|
|
988
|
-
stop_sequences:
|
|
919
|
+
stop_sequences: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
|
|
989
920
|
stream: Literal[False] | Literal[True] | NotGiven = NOT_GIVEN,
|
|
990
921
|
system: Union[str, Iterable[BetaTextBlockParam]] | NotGiven = NOT_GIVEN,
|
|
991
922
|
temperature: float | NotGiven = NOT_GIVEN,
|
|
@@ -1061,7 +992,7 @@ class Messages(SyncAPIResource):
|
|
|
1061
992
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | NotGiven = NOT_GIVEN,
|
|
1062
993
|
metadata: BetaMetadataParam | NotGiven = NOT_GIVEN,
|
|
1063
994
|
service_tier: Literal["auto", "standard_only"] | NotGiven = NOT_GIVEN,
|
|
1064
|
-
stop_sequences:
|
|
995
|
+
stop_sequences: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
|
|
1065
996
|
system: Union[str, Iterable[BetaTextBlockParam]] | NotGiven = NOT_GIVEN,
|
|
1066
997
|
temperature: float | NotGiven = NOT_GIVEN,
|
|
1067
998
|
thinking: BetaThinkingConfigParam | NotGiven = NOT_GIVEN,
|
|
@@ -1208,30 +1139,7 @@ class Messages(SyncAPIResource):
|
|
|
1208
1139
|
{ "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
|
|
1209
1140
|
```
|
|
1210
1141
|
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
```json
|
|
1214
|
-
{
|
|
1215
|
-
"role": "user",
|
|
1216
|
-
"content": [
|
|
1217
|
-
{
|
|
1218
|
-
"type": "image",
|
|
1219
|
-
"source": {
|
|
1220
|
-
"type": "base64",
|
|
1221
|
-
"media_type": "image/jpeg",
|
|
1222
|
-
"data": "/9j/4AAQSkZJRg..."
|
|
1223
|
-
}
|
|
1224
|
-
},
|
|
1225
|
-
{ "type": "text", "text": "What is in this image?" }
|
|
1226
|
-
]
|
|
1227
|
-
}
|
|
1228
|
-
```
|
|
1229
|
-
|
|
1230
|
-
We currently support the `base64` source type for images, and the `image/jpeg`,
|
|
1231
|
-
`image/png`, `image/gif`, and `image/webp` media types.
|
|
1232
|
-
|
|
1233
|
-
See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
|
|
1234
|
-
more input examples.
|
|
1142
|
+
See [input examples](https://docs.anthropic.com/en/api/messages-examples).
|
|
1235
1143
|
|
|
1236
1144
|
Note that if you want to include a
|
|
1237
1145
|
[system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
|
|
@@ -1418,7 +1326,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
1418
1326
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | NotGiven = NOT_GIVEN,
|
|
1419
1327
|
metadata: BetaMetadataParam | NotGiven = NOT_GIVEN,
|
|
1420
1328
|
service_tier: Literal["auto", "standard_only"] | NotGiven = NOT_GIVEN,
|
|
1421
|
-
stop_sequences:
|
|
1329
|
+
stop_sequences: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
|
|
1422
1330
|
stream: Literal[False] | NotGiven = NOT_GIVEN,
|
|
1423
1331
|
system: Union[str, Iterable[BetaTextBlockParam]] | NotGiven = NOT_GIVEN,
|
|
1424
1332
|
temperature: float | NotGiven = NOT_GIVEN,
|
|
@@ -1510,30 +1418,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
1510
1418
|
{ "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
|
|
1511
1419
|
```
|
|
1512
1420
|
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
```json
|
|
1516
|
-
{
|
|
1517
|
-
"role": "user",
|
|
1518
|
-
"content": [
|
|
1519
|
-
{
|
|
1520
|
-
"type": "image",
|
|
1521
|
-
"source": {
|
|
1522
|
-
"type": "base64",
|
|
1523
|
-
"media_type": "image/jpeg",
|
|
1524
|
-
"data": "/9j/4AAQSkZJRg..."
|
|
1525
|
-
}
|
|
1526
|
-
},
|
|
1527
|
-
{ "type": "text", "text": "What is in this image?" }
|
|
1528
|
-
]
|
|
1529
|
-
}
|
|
1530
|
-
```
|
|
1531
|
-
|
|
1532
|
-
We currently support the `base64` source type for images, and the `image/jpeg`,
|
|
1533
|
-
`image/png`, `image/gif`, and `image/webp` media types.
|
|
1534
|
-
|
|
1535
|
-
See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
|
|
1536
|
-
more input examples.
|
|
1421
|
+
See [input examples](https://docs.anthropic.com/en/api/messages-examples).
|
|
1537
1422
|
|
|
1538
1423
|
Note that if you want to include a
|
|
1539
1424
|
[system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
|
|
@@ -1719,7 +1604,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
1719
1604
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | NotGiven = NOT_GIVEN,
|
|
1720
1605
|
metadata: BetaMetadataParam | NotGiven = NOT_GIVEN,
|
|
1721
1606
|
service_tier: Literal["auto", "standard_only"] | NotGiven = NOT_GIVEN,
|
|
1722
|
-
stop_sequences:
|
|
1607
|
+
stop_sequences: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
|
|
1723
1608
|
system: Union[str, Iterable[BetaTextBlockParam]] | NotGiven = NOT_GIVEN,
|
|
1724
1609
|
temperature: float | NotGiven = NOT_GIVEN,
|
|
1725
1610
|
thinking: BetaThinkingConfigParam | NotGiven = NOT_GIVEN,
|
|
@@ -1810,30 +1695,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
1810
1695
|
{ "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
|
|
1811
1696
|
```
|
|
1812
1697
|
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
```json
|
|
1816
|
-
{
|
|
1817
|
-
"role": "user",
|
|
1818
|
-
"content": [
|
|
1819
|
-
{
|
|
1820
|
-
"type": "image",
|
|
1821
|
-
"source": {
|
|
1822
|
-
"type": "base64",
|
|
1823
|
-
"media_type": "image/jpeg",
|
|
1824
|
-
"data": "/9j/4AAQSkZJRg..."
|
|
1825
|
-
}
|
|
1826
|
-
},
|
|
1827
|
-
{ "type": "text", "text": "What is in this image?" }
|
|
1828
|
-
]
|
|
1829
|
-
}
|
|
1830
|
-
```
|
|
1831
|
-
|
|
1832
|
-
We currently support the `base64` source type for images, and the `image/jpeg`,
|
|
1833
|
-
`image/png`, `image/gif`, and `image/webp` media types.
|
|
1834
|
-
|
|
1835
|
-
See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
|
|
1836
|
-
more input examples.
|
|
1698
|
+
See [input examples](https://docs.anthropic.com/en/api/messages-examples).
|
|
1837
1699
|
|
|
1838
1700
|
Note that if you want to include a
|
|
1839
1701
|
[system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
|
|
@@ -2019,7 +1881,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2019
1881
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | NotGiven = NOT_GIVEN,
|
|
2020
1882
|
metadata: BetaMetadataParam | NotGiven = NOT_GIVEN,
|
|
2021
1883
|
service_tier: Literal["auto", "standard_only"] | NotGiven = NOT_GIVEN,
|
|
2022
|
-
stop_sequences:
|
|
1884
|
+
stop_sequences: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
|
|
2023
1885
|
system: Union[str, Iterable[BetaTextBlockParam]] | NotGiven = NOT_GIVEN,
|
|
2024
1886
|
temperature: float | NotGiven = NOT_GIVEN,
|
|
2025
1887
|
thinking: BetaThinkingConfigParam | NotGiven = NOT_GIVEN,
|
|
@@ -2110,30 +1972,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2110
1972
|
{ "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
|
|
2111
1973
|
```
|
|
2112
1974
|
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
```json
|
|
2116
|
-
{
|
|
2117
|
-
"role": "user",
|
|
2118
|
-
"content": [
|
|
2119
|
-
{
|
|
2120
|
-
"type": "image",
|
|
2121
|
-
"source": {
|
|
2122
|
-
"type": "base64",
|
|
2123
|
-
"media_type": "image/jpeg",
|
|
2124
|
-
"data": "/9j/4AAQSkZJRg..."
|
|
2125
|
-
}
|
|
2126
|
-
},
|
|
2127
|
-
{ "type": "text", "text": "What is in this image?" }
|
|
2128
|
-
]
|
|
2129
|
-
}
|
|
2130
|
-
```
|
|
2131
|
-
|
|
2132
|
-
We currently support the `base64` source type for images, and the `image/jpeg`,
|
|
2133
|
-
`image/png`, `image/gif`, and `image/webp` media types.
|
|
2134
|
-
|
|
2135
|
-
See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
|
|
2136
|
-
more input examples.
|
|
1975
|
+
See [input examples](https://docs.anthropic.com/en/api/messages-examples).
|
|
2137
1976
|
|
|
2138
1977
|
Note that if you want to include a
|
|
2139
1978
|
[system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
|
|
@@ -2318,7 +2157,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2318
2157
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | NotGiven = NOT_GIVEN,
|
|
2319
2158
|
metadata: BetaMetadataParam | NotGiven = NOT_GIVEN,
|
|
2320
2159
|
service_tier: Literal["auto", "standard_only"] | NotGiven = NOT_GIVEN,
|
|
2321
|
-
stop_sequences:
|
|
2160
|
+
stop_sequences: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
|
|
2322
2161
|
stream: Literal[False] | Literal[True] | NotGiven = NOT_GIVEN,
|
|
2323
2162
|
system: Union[str, Iterable[BetaTextBlockParam]] | NotGiven = NOT_GIVEN,
|
|
2324
2163
|
temperature: float | NotGiven = NOT_GIVEN,
|
|
@@ -2394,7 +2233,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2394
2233
|
container: Optional[str] | NotGiven = NOT_GIVEN,
|
|
2395
2234
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | NotGiven = NOT_GIVEN,
|
|
2396
2235
|
service_tier: Literal["auto", "standard_only"] | NotGiven = NOT_GIVEN,
|
|
2397
|
-
stop_sequences:
|
|
2236
|
+
stop_sequences: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
|
|
2398
2237
|
system: Union[str, Iterable[BetaTextBlockParam]] | NotGiven = NOT_GIVEN,
|
|
2399
2238
|
temperature: float | NotGiven = NOT_GIVEN,
|
|
2400
2239
|
thinking: BetaThinkingConfigParam | NotGiven = NOT_GIVEN,
|
|
@@ -2539,30 +2378,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2539
2378
|
{ "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
|
|
2540
2379
|
```
|
|
2541
2380
|
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
```json
|
|
2545
|
-
{
|
|
2546
|
-
"role": "user",
|
|
2547
|
-
"content": [
|
|
2548
|
-
{
|
|
2549
|
-
"type": "image",
|
|
2550
|
-
"source": {
|
|
2551
|
-
"type": "base64",
|
|
2552
|
-
"media_type": "image/jpeg",
|
|
2553
|
-
"data": "/9j/4AAQSkZJRg..."
|
|
2554
|
-
}
|
|
2555
|
-
},
|
|
2556
|
-
{ "type": "text", "text": "What is in this image?" }
|
|
2557
|
-
]
|
|
2558
|
-
}
|
|
2559
|
-
```
|
|
2560
|
-
|
|
2561
|
-
We currently support the `base64` source type for images, and the `image/jpeg`,
|
|
2562
|
-
`image/png`, `image/gif`, and `image/webp` media types.
|
|
2563
|
-
|
|
2564
|
-
See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
|
|
2565
|
-
more input examples.
|
|
2381
|
+
See [input examples](https://docs.anthropic.com/en/api/messages-examples).
|
|
2566
2382
|
|
|
2567
2383
|
Note that if you want to include a
|
|
2568
2384
|
[system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
|
|
@@ -9,7 +9,7 @@ import httpx
|
|
|
9
9
|
|
|
10
10
|
from .. import _legacy_response
|
|
11
11
|
from ..types import completion_create_params
|
|
12
|
-
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
|
|
12
|
+
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
|
|
13
13
|
from .._utils import is_given, required_args, maybe_transform, strip_not_given, async_maybe_transform
|
|
14
14
|
from .._compat import cached_property
|
|
15
15
|
from .._resource import SyncAPIResource, AsyncAPIResource
|
|
@@ -53,7 +53,7 @@ class Completions(SyncAPIResource):
|
|
|
53
53
|
model: ModelParam,
|
|
54
54
|
prompt: str,
|
|
55
55
|
metadata: MetadataParam | NotGiven = NOT_GIVEN,
|
|
56
|
-
stop_sequences:
|
|
56
|
+
stop_sequences: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
|
|
57
57
|
stream: Literal[False] | NotGiven = NOT_GIVEN,
|
|
58
58
|
temperature: float | NotGiven = NOT_GIVEN,
|
|
59
59
|
top_k: int | NotGiven = NOT_GIVEN,
|
|
@@ -161,7 +161,7 @@ class Completions(SyncAPIResource):
|
|
|
161
161
|
prompt: str,
|
|
162
162
|
stream: Literal[True],
|
|
163
163
|
metadata: MetadataParam | NotGiven = NOT_GIVEN,
|
|
164
|
-
stop_sequences:
|
|
164
|
+
stop_sequences: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
|
|
165
165
|
temperature: float | NotGiven = NOT_GIVEN,
|
|
166
166
|
top_k: int | NotGiven = NOT_GIVEN,
|
|
167
167
|
top_p: float | NotGiven = NOT_GIVEN,
|
|
@@ -268,7 +268,7 @@ class Completions(SyncAPIResource):
|
|
|
268
268
|
prompt: str,
|
|
269
269
|
stream: bool,
|
|
270
270
|
metadata: MetadataParam | NotGiven = NOT_GIVEN,
|
|
271
|
-
stop_sequences:
|
|
271
|
+
stop_sequences: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
|
|
272
272
|
temperature: float | NotGiven = NOT_GIVEN,
|
|
273
273
|
top_k: int | NotGiven = NOT_GIVEN,
|
|
274
274
|
top_p: float | NotGiven = NOT_GIVEN,
|
|
@@ -374,7 +374,7 @@ class Completions(SyncAPIResource):
|
|
|
374
374
|
model: ModelParam,
|
|
375
375
|
prompt: str,
|
|
376
376
|
metadata: MetadataParam | NotGiven = NOT_GIVEN,
|
|
377
|
-
stop_sequences:
|
|
377
|
+
stop_sequences: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
|
|
378
378
|
stream: Literal[False] | Literal[True] | NotGiven = NOT_GIVEN,
|
|
379
379
|
temperature: float | NotGiven = NOT_GIVEN,
|
|
380
380
|
top_k: int | NotGiven = NOT_GIVEN,
|
|
@@ -448,7 +448,7 @@ class AsyncCompletions(AsyncAPIResource):
|
|
|
448
448
|
model: ModelParam,
|
|
449
449
|
prompt: str,
|
|
450
450
|
metadata: MetadataParam | NotGiven = NOT_GIVEN,
|
|
451
|
-
stop_sequences:
|
|
451
|
+
stop_sequences: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
|
|
452
452
|
stream: Literal[False] | NotGiven = NOT_GIVEN,
|
|
453
453
|
temperature: float | NotGiven = NOT_GIVEN,
|
|
454
454
|
top_k: int | NotGiven = NOT_GIVEN,
|
|
@@ -556,7 +556,7 @@ class AsyncCompletions(AsyncAPIResource):
|
|
|
556
556
|
prompt: str,
|
|
557
557
|
stream: Literal[True],
|
|
558
558
|
metadata: MetadataParam | NotGiven = NOT_GIVEN,
|
|
559
|
-
stop_sequences:
|
|
559
|
+
stop_sequences: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
|
|
560
560
|
temperature: float | NotGiven = NOT_GIVEN,
|
|
561
561
|
top_k: int | NotGiven = NOT_GIVEN,
|
|
562
562
|
top_p: float | NotGiven = NOT_GIVEN,
|
|
@@ -663,7 +663,7 @@ class AsyncCompletions(AsyncAPIResource):
|
|
|
663
663
|
prompt: str,
|
|
664
664
|
stream: bool,
|
|
665
665
|
metadata: MetadataParam | NotGiven = NOT_GIVEN,
|
|
666
|
-
stop_sequences:
|
|
666
|
+
stop_sequences: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
|
|
667
667
|
temperature: float | NotGiven = NOT_GIVEN,
|
|
668
668
|
top_k: int | NotGiven = NOT_GIVEN,
|
|
669
669
|
top_p: float | NotGiven = NOT_GIVEN,
|
|
@@ -769,7 +769,7 @@ class AsyncCompletions(AsyncAPIResource):
|
|
|
769
769
|
model: ModelParam,
|
|
770
770
|
prompt: str,
|
|
771
771
|
metadata: MetadataParam | NotGiven = NOT_GIVEN,
|
|
772
|
-
stop_sequences:
|
|
772
|
+
stop_sequences: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
|
|
773
773
|
stream: Literal[False] | Literal[True] | NotGiven = NOT_GIVEN,
|
|
774
774
|
temperature: float | NotGiven = NOT_GIVEN,
|
|
775
775
|
top_k: int | NotGiven = NOT_GIVEN,
|