-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
Feature requestNew feature requestNew feature request
Description
Description
I would like to configure the built-in WebSearchTool with the user's location set WebSearchUserLocation from RunContext. We can do this with toolsets and tools, but the not built-in tools.
- tools:
tools: Sequence[Tool[None] | ToolFuncContext[None, ...] | ToolFuncPlain[...]] - toolsets:
toolsets: Sequence[AbstractToolset[None] | ToolsetFunc[None]] | None - builtin_tools:
builtin_tools: Sequence[AbstractBuiltinTool]
I would be great to be able to do something like this:
from dataclasses import dataclass
from pydantic_ai import Agent, RunContext, Tool, ToolDefinition, WebSearchTool, WebSearchUserLocation
@dataclass
class UserContext:
location: str
async def prepared_web_search(ctx: RunContext[UserContext]) -> WebSearchTool | None:
return WebSearchTool(
search_context_size="medium",
user_location=WebSearchUserLocation(type="approximate", location=ctx.deps.location),
)
user_context = UserContext(location="New York, NY, USA")
agent = Agent(builtin_tools=[prepared_web_search], deps_type=UserContext)
result = await agent.run("Search the web for the capital of France.", deps=user_context)References
Metadata
Metadata
Assignees
Labels
Feature requestNew feature requestNew feature request