Skip to content

Commit da3b931

Browse files
feat(api): fix shared UserLocation and error code types
1 parent 304e2e8 commit da3b931

9 files changed

+53
-73
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 34
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic%2Fanthropic-5387c517ad6a3b9790063962c2956476b24a17d163c68c8d091367f6db8cf4ed.yml
33
openapi_spec_hash: 13d3d0a8e62a955b8b4df99c18d387d0
4-
config_hash: eff77494ec74be23289ed0ea22e7e847
4+
config_hash: 4e204fead5f0af80eb9effa1d1e34dca

api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ from anthropic.types import (
156156
URLImageSource,
157157
URLPDFSource,
158158
Usage,
159+
UserLocation,
159160
WebFetchBlock,
160161
WebFetchBlockParam,
161162
WebFetchTool20250910,
@@ -175,6 +176,7 @@ from anthropic.types import (
175176
WebSearchToolResultBlockParam,
176177
WebSearchToolResultBlockParamContent,
177178
WebSearchToolResultError,
179+
WebSearchToolResultErrorCode,
178180
MessageStreamEvent,
179181
MessageStartEvent,
180182
MessageDeltaEvent,

src/anthropic/types/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
from .message_start_event import MessageStartEvent as MessageStartEvent
6868
from .output_config_param import OutputConfigParam as OutputConfigParam
6969
from .text_citation_param import TextCitationParam as TextCitationParam
70+
from .user_location_param import UserLocationParam as UserLocationParam
7071
from .anthropic_beta_param import AnthropicBetaParam as AnthropicBetaParam
7172
from .beta_not_found_error import BetaNotFoundError as BetaNotFoundError
7273
from .document_block_param import DocumentBlockParam as DocumentBlockParam
@@ -159,6 +160,7 @@
159160
from .server_tool_caller_20260120_param import ServerToolCaller20260120Param as ServerToolCaller20260120Param
160161
from .web_fetch_tool_result_block_param import WebFetchToolResultBlockParam as WebFetchToolResultBlockParam
161162
from .web_fetch_tool_result_error_block import WebFetchToolResultErrorBlock as WebFetchToolResultErrorBlock
163+
from .web_search_tool_result_error_code import WebSearchToolResultErrorCode as WebSearchToolResultErrorCode
162164
from .code_execution_tool_20250522_param import CodeExecutionTool20250522Param as CodeExecutionTool20250522Param
163165
from .code_execution_tool_20250825_param import CodeExecutionTool20250825Param as CodeExecutionTool20250825Param
164166
from .code_execution_tool_20260120_param import CodeExecutionTool20260120Param as CodeExecutionTool20260120Param
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing import Optional
6+
from typing_extensions import Literal, Required, TypedDict
7+
8+
__all__ = ["UserLocationParam"]
9+
10+
11+
class UserLocationParam(TypedDict, total=False):
12+
type: Required[Literal["approximate"]]
13+
14+
city: Optional[str]
15+
"""The city of the user."""
16+
17+
country: Optional[str]
18+
"""
19+
The two letter
20+
[ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the
21+
user.
22+
"""
23+
24+
region: Optional[str]
25+
"""The region of the user."""
26+
27+
timezone: Optional[str]
28+
"""The [IANA timezone](https://nodatime.org/TimeZones) of the user."""

src/anthropic/types/web_search_tool_20250305_param.py

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,10 @@
66
from typing_extensions import Literal, Required, TypedDict
77

88
from .._types import SequenceNotStr
9+
from .user_location_param import UserLocationParam
910
from .cache_control_ephemeral_param import CacheControlEphemeralParam
1011

11-
__all__ = ["WebSearchTool20250305Param", "UserLocation"]
12-
13-
14-
class UserLocation(TypedDict, total=False):
15-
"""Parameters for the user's location.
16-
17-
Used to provide more relevant search results.
18-
"""
19-
20-
type: Required[Literal["approximate"]]
21-
22-
city: Optional[str]
23-
"""The city of the user."""
24-
25-
country: Optional[str]
26-
"""
27-
The two letter
28-
[ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the
29-
user.
30-
"""
31-
32-
region: Optional[str]
33-
"""The region of the user."""
34-
35-
timezone: Optional[str]
36-
"""The [IANA timezone](https://nodatime.org/TimeZones) of the user."""
12+
__all__ = ["WebSearchTool20250305Param"]
3713

3814

3915
class WebSearchTool20250305Param(TypedDict, total=False):
@@ -74,7 +50,7 @@ class WebSearchTool20250305Param(TypedDict, total=False):
7450
strict: bool
7551
"""When true, guarantees schema validation on tool names and inputs"""
7652

77-
user_location: Optional[UserLocation]
53+
user_location: Optional[UserLocationParam]
7854
"""Parameters for the user's location.
7955
8056
Used to provide more relevant search results.

src/anthropic/types/web_search_tool_20260209_param.py

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,10 @@
66
from typing_extensions import Literal, Required, TypedDict
77

88
from .._types import SequenceNotStr
9+
from .user_location_param import UserLocationParam
910
from .cache_control_ephemeral_param import CacheControlEphemeralParam
1011

11-
__all__ = ["WebSearchTool20260209Param", "UserLocation"]
12-
13-
14-
class UserLocation(TypedDict, total=False):
15-
"""Parameters for the user's location.
16-
17-
Used to provide more relevant search results.
18-
"""
19-
20-
type: Required[Literal["approximate"]]
21-
22-
city: Optional[str]
23-
"""The city of the user."""
24-
25-
country: Optional[str]
26-
"""
27-
The two letter
28-
[ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the
29-
user.
30-
"""
31-
32-
region: Optional[str]
33-
"""The region of the user."""
34-
35-
timezone: Optional[str]
36-
"""The [IANA timezone](https://nodatime.org/TimeZones) of the user."""
12+
__all__ = ["WebSearchTool20260209Param"]
3713

3814

3915
class WebSearchTool20260209Param(TypedDict, total=False):
@@ -74,7 +50,7 @@ class WebSearchTool20260209Param(TypedDict, total=False):
7450
strict: bool
7551
"""When true, guarantees schema validation on tool names and inputs"""
7652

77-
user_location: Optional[UserLocation]
53+
user_location: Optional[UserLocationParam]
7854
"""Parameters for the user's location.
7955
8056
Used to provide more relevant search results.

src/anthropic/types/web_search_tool_request_error_param.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,12 @@
44

55
from typing_extensions import Literal, Required, TypedDict
66

7+
from .web_search_tool_result_error_code import WebSearchToolResultErrorCode
8+
79
__all__ = ["WebSearchToolRequestErrorParam"]
810

911

1012
class WebSearchToolRequestErrorParam(TypedDict, total=False):
11-
error_code: Required[
12-
Literal[
13-
"invalid_tool_input",
14-
"unavailable",
15-
"max_uses_exceeded",
16-
"too_many_requests",
17-
"query_too_long",
18-
"request_too_large",
19-
]
20-
]
13+
error_code: Required[WebSearchToolResultErrorCode]
2114

2215
type: Required[Literal["web_search_tool_result_error"]]

src/anthropic/types/web_search_tool_result_error.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,12 @@
33
from typing_extensions import Literal
44

55
from .._models import BaseModel
6+
from .web_search_tool_result_error_code import WebSearchToolResultErrorCode
67

78
__all__ = ["WebSearchToolResultError"]
89

910

1011
class WebSearchToolResultError(BaseModel):
11-
error_code: Literal[
12-
"invalid_tool_input",
13-
"unavailable",
14-
"max_uses_exceeded",
15-
"too_many_requests",
16-
"query_too_long",
17-
"request_too_large",
18-
]
12+
error_code: WebSearchToolResultErrorCode
1913

2014
type: Literal["web_search_tool_result_error"]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing_extensions import Literal, TypeAlias
4+
5+
__all__ = ["WebSearchToolResultErrorCode"]
6+
7+
WebSearchToolResultErrorCode: TypeAlias = Literal[
8+
"invalid_tool_input", "unavailable", "max_uses_exceeded", "too_many_requests", "query_too_long", "request_too_large"
9+
]

0 commit comments

Comments
 (0)