|
3 | 3 | from typing import Dict, List, Union, Optional
|
4 | 4 | from typing_extensions import Literal, Annotated, TypeAlias
|
5 | 5 |
|
| 6 | +from . import web_search_tool |
6 | 7 | from ..._utils import PropertyInfo
|
7 | 8 | from ..._models import BaseModel
|
8 | 9 | from .custom_tool import CustomTool
|
9 | 10 | from .computer_tool import ComputerTool
|
10 | 11 | from .function_tool import FunctionTool
|
11 |
| -from .web_search_tool import WebSearchTool |
12 | 12 | from .file_search_tool import FileSearchTool
|
13 | 13 |
|
14 | 14 | __all__ = [
|
15 | 15 | "Tool",
|
| 16 | + "WebSearchTool", |
| 17 | + "WebSearchToolFilters", |
| 18 | + "WebSearchToolUserLocation", |
16 | 19 | "Mcp",
|
17 | 20 | "McpAllowedTools",
|
18 | 21 | "McpAllowedToolsMcpToolFilter",
|
|
29 | 32 | ]
|
30 | 33 |
|
31 | 34 |
|
| 35 | +class WebSearchToolFilters(BaseModel): |
| 36 | + allowed_domains: Optional[List[str]] = None |
| 37 | + """Allowed domains for the search. |
| 38 | +
|
| 39 | + If not provided, all domains are allowed. Subdomains of the provided domains are |
| 40 | + allowed as well. |
| 41 | +
|
| 42 | + Example: `["pubmed.ncbi.nlm.nih.gov"]` |
| 43 | + """ |
| 44 | + |
| 45 | + |
| 46 | +class WebSearchToolUserLocation(BaseModel): |
| 47 | + city: Optional[str] = None |
| 48 | + """Free text input for the city of the user, e.g. `San Francisco`.""" |
| 49 | + |
| 50 | + country: Optional[str] = None |
| 51 | + """ |
| 52 | + The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of |
| 53 | + the user, e.g. `US`. |
| 54 | + """ |
| 55 | + |
| 56 | + region: Optional[str] = None |
| 57 | + """Free text input for the region of the user, e.g. `California`.""" |
| 58 | + |
| 59 | + timezone: Optional[str] = None |
| 60 | + """ |
| 61 | + The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the |
| 62 | + user, e.g. `America/Los_Angeles`. |
| 63 | + """ |
| 64 | + |
| 65 | + type: Optional[Literal["approximate"]] = None |
| 66 | + """The type of location approximation. Always `approximate`.""" |
| 67 | + |
| 68 | + |
| 69 | +class WebSearchTool(BaseModel): |
| 70 | + type: Literal["web_search", "web_search_2025_08_26"] |
| 71 | + """The type of the web search tool. |
| 72 | +
|
| 73 | + One of `web_search` or `web_search_2025_08_26`. |
| 74 | + """ |
| 75 | + |
| 76 | + filters: Optional[WebSearchToolFilters] = None |
| 77 | + """Filters for the search.""" |
| 78 | + |
| 79 | + search_context_size: Optional[Literal["low", "medium", "high"]] = None |
| 80 | + """High level guidance for the amount of context window space to use for the |
| 81 | + search. |
| 82 | +
|
| 83 | + One of `low`, `medium`, or `high`. `medium` is the default. |
| 84 | + """ |
| 85 | + |
| 86 | + user_location: Optional[WebSearchToolUserLocation] = None |
| 87 | + """The approximate location of the user.""" |
| 88 | + |
| 89 | + |
32 | 90 | class McpAllowedToolsMcpToolFilter(BaseModel):
|
33 | 91 | read_only: Optional[bool] = None
|
34 | 92 | """Indicates whether or not a tool modifies data or is read-only.
|
@@ -245,13 +303,14 @@ class LocalShell(BaseModel):
|
245 | 303 | Union[
|
246 | 304 | FunctionTool,
|
247 | 305 | FileSearchTool,
|
248 |
| - WebSearchTool, |
249 | 306 | ComputerTool,
|
| 307 | + WebSearchTool, |
250 | 308 | Mcp,
|
251 | 309 | CodeInterpreter,
|
252 | 310 | ImageGeneration,
|
253 | 311 | LocalShell,
|
254 | 312 | CustomTool,
|
| 313 | + web_search_tool.WebSearchTool, |
255 | 314 | ],
|
256 | 315 | PropertyInfo(discriminator="type"),
|
257 | 316 | ]
|
0 commit comments