Quercle web search and URL fetch tools for Pydantic AI agents
Project description
quercle-pydantic-ai
Quercle web search and URL fetch tools for Pydantic AI agents.
Installation
uv add quercle-pydantic-ai
Or with pip:
pip install quercle-pydantic-ai
Quick Start
from pydantic_ai import Agent
from quercle_pydantic_ai import quercle_tools
# Create an agent with Quercle tools
agent = Agent(
'openai:gpt-4o',
tools=quercle_tools(),
)
# Run the agent
result = agent.run_sync("Search for the latest Python 3.13 features")
print(result.data)
Configuration
API Key
Set your Quercle API key via environment variable:
export QUERCLE_API_KEY=qk_your_api_key
Or pass it directly:
from quercle_pydantic_ai import quercle_tools
tools = quercle_tools(api_key="qk_your_api_key")
Get your API key at quercle.dev.
Usage
Individual Tools
Use search or fetch tools separately:
from pydantic_ai import Agent
from quercle_pydantic_ai import quercle_search_tool, quercle_fetch_tool
# Search-only agent
search_agent = Agent(
'openai:gpt-4o',
tools=[quercle_search_tool()],
)
# Fetch-only agent
fetch_agent = Agent(
'openai:gpt-4o',
tools=[quercle_fetch_tool()],
)
Domain Filtering
Restrict search to specific domains:
from quercle_pydantic_ai import quercle_search_tool
# Only search official documentation sites
tool = quercle_search_tool(
allowed_domains=["*.python.org", "docs.*.dev"],
)
# Exclude certain domains
tool = quercle_search_tool(
blocked_domains=["reddit.com", "*.social"],
)
QuercleToolset
Use the toolset for composition with other Pydantic AI toolsets:
from pydantic_ai import Agent
from pydantic_ai.toolsets import CombinedToolset
from quercle_pydantic_ai import QuercleToolset
# Create a Quercle toolset
quercle = QuercleToolset(
search_allowed_domains=["*.org", "*.edu"],
)
# Combine with other toolsets
combined = CombinedToolset([quercle, other_toolset])
agent = Agent('openai:gpt-4o', toolsets=[combined])
Configure which tools to include:
# Search only
toolset = QuercleToolset(include_fetch=False)
# Fetch only
toolset = QuercleToolset(include_search=False)
Examples
Research Agent
from pydantic_ai import Agent
from quercle_pydantic_ai import quercle_tools
agent = Agent(
'openai:gpt-4o',
tools=quercle_tools(),
system_prompt="""You are a research assistant. Use web search to find
accurate, up-to-date information. Always cite your sources.""",
)
result = agent.run_sync(
"What are the key differences between Python 3.12 and 3.13?"
)
print(result.data)
Web Analyzer Agent
from pydantic_ai import Agent
from quercle_pydantic_ai import quercle_fetch_tool
agent = Agent(
'openai:gpt-4o',
tools=[quercle_fetch_tool()],
system_prompt="""You analyze web pages and extract key information.
When given a URL, fetch it and provide a structured summary.""",
)
result = agent.run_sync(
"Analyze the documentation at https://ai.pydantic.dev/tools/"
)
print(result.data)
Async Usage
import asyncio
from pydantic_ai import Agent
from quercle_pydantic_ai import quercle_tools
agent = Agent('openai:gpt-4o', tools=quercle_tools())
async def main():
result = await agent.run("Search for async Python best practices")
print(result.data)
asyncio.run(main())
API Reference
Factory Functions
quercle_search_tool()
Creates a web search tool.
def quercle_search_tool(
api_key: str | None = None,
allowed_domains: list[str] | None = None,
blocked_domains: list[str] | None = None,
timeout: float | None = None,
) -> Tool[Any]
quercle_fetch_tool()
Creates a URL fetch tool.
def quercle_fetch_tool(
api_key: str | None = None,
timeout: float | None = None,
) -> Tool[Any]
quercle_tools()
Creates both search and fetch tools.
def quercle_tools(
api_key: str | None = None,
timeout: float | None = None,
) -> list[Tool[Any]]
QuercleToolset
A composable toolset for use with Pydantic AI's toolset system.
class QuercleToolset(FunctionToolset):
def __init__(
self,
api_key: str | None = None,
timeout: float | None = None,
*,
include_search: bool = True,
include_fetch: bool = True,
search_allowed_domains: list[str] | None = None,
search_blocked_domains: list[str] | None = None,
)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file quercle_pydantic_ai-0.1.0.tar.gz.
File metadata
- Download URL: quercle_pydantic_ai-0.1.0.tar.gz
- Upload date:
- Size: 213.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
464b981a8dd6a153cc3782832109486f12e611159d481ae82af5c4fd3447143d
|
|
| MD5 |
18012dd4aee3cdb09b012abcf5a2bd18
|
|
| BLAKE2b-256 |
42366b7274f1dc5bed82f7e38a4a52e39d4c10ed898d9aed822a906fbb4f0d2b
|
Provenance
The following attestation bundles were made for quercle_pydantic_ai-0.1.0.tar.gz:
Publisher:
publish.yml on quercledev/quercle-pydantic-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quercle_pydantic_ai-0.1.0.tar.gz -
Subject digest:
464b981a8dd6a153cc3782832109486f12e611159d481ae82af5c4fd3447143d - Sigstore transparency entry: 870287773
- Sigstore integration time:
-
Permalink:
quercledev/quercle-pydantic-ai@13269f8884623c8d468b2e41865e330a310e45f7 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/quercledev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@13269f8884623c8d468b2e41865e330a310e45f7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file quercle_pydantic_ai-0.1.0-py3-none-any.whl.
File metadata
- Download URL: quercle_pydantic_ai-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7845d4296a3b438c82595b3a93a47bbc9690ffef7250c1af4ea45fd0be53b7db
|
|
| MD5 |
6dd2a515245593f1c2d4838b88eb402d
|
|
| BLAKE2b-256 |
05b112867a3231ecdd9110486fddcc9f5ce3901a9447c525fa296a64818f5ac7
|
Provenance
The following attestation bundles were made for quercle_pydantic_ai-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on quercledev/quercle-pydantic-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quercle_pydantic_ai-0.1.0-py3-none-any.whl -
Subject digest:
7845d4296a3b438c82595b3a93a47bbc9690ffef7250c1af4ea45fd0be53b7db - Sigstore transparency entry: 870287776
- Sigstore integration time:
-
Permalink:
quercledev/quercle-pydantic-ai@13269f8884623c8d468b2e41865e330a310e45f7 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/quercledev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@13269f8884623c8d468b2e41865e330a310e45f7 -
Trigger Event:
push
-
Statement type: