Metadata-Version: 2.5
Name: pydantic-ai-nestdaddy
Version: 0.1.0
Summary: NestDaddy capability for Pydantic AI: give your agent today's internet with live web search, real-time news and page reading.
Project-URL: Homepage, https://nestdaddy.com/mcp
Project-URL: Documentation, https://github.com/nestdaddy-ai/pydantic-ai-nestdaddy#readme
Project-URL: Source, https://github.com/nestdaddy-ai/pydantic-ai-nestdaddy
Project-URL: API reference, https://nestdaddy.com/apis
Author-email: NestDaddy <hello@nestdaddy.com>
License-Expression: MIT
License-File: LICENSE
Keywords: agents,capability,nestdaddy,news,pydantic-ai,search,web search
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Requires-Dist: httpx<1.0.0,>=0.25.0
Requires-Dist: pydantic-ai-slim>=2.0.0
Provides-Extra: test
Requires-Dist: anyio[trio]>=4; extra == 'test'
Requires-Dist: pytest>=8; extra == 'test'
Description-Content-Type: text/markdown

# pydantic-ai-nestdaddy

Give your [Pydantic AI](https://ai.pydantic.dev) agent today's internet. This package adds a capability with three tools backed by [NestDaddy](https://nestdaddy.com), a search service with its own crawler and index:

- `search_web`: web results with title, url, snippet and domain.
- `search_news`: real-time news, filtered by age and country, newest and best match first.
- `read_page`: the clean full text of a page or article.

It also gives the model a short instruction on when to use each tool.

## Install

```bash
pip install pydantic-ai-nestdaddy
```

Get an API key at [nestdaddy.com/dashboard](https://nestdaddy.com/dashboard) (a free plan is available) and set it:

```bash
export NESTDADDY_API_KEY=nd_...
```

## Use it

```python
from pydantic_ai import Agent
from pydantic_ai_nestdaddy import NestDaddyCapability

agent = Agent('openai:gpt-5', capabilities=[NestDaddyCapability()])

result = agent.run_sync('What happened in AI this week? Cite your sources.')
print(result.output)
```

Options (all optional): `api_key`, `num_results` (default 10), `news_days` (default 30), `country` (a default two-letter code such as `GB`), `max_chars` for `read_page` (default 8000), `timeout`.

### Only the tools

If you prefer a plain toolset:

```python
from pydantic_ai import Agent
from pydantic_ai_nestdaddy import nestdaddy_toolset

agent = Agent('openai:gpt-5', toolsets=[nestdaddy_toolset(country='US')])
```

### Agent specs

Every field is serializable, so the capability works in agent specs:

```yaml
model: openai:gpt-5
capabilities:
  - NestDaddy:
      country: GB
```

```python
agent = Agent.from_file('agent.yaml', custom_capability_types=[NestDaddyCapability])
```

## Behaviour

- Bad arguments (a one-character query, a malformed country code or URL) are checked locally and sent back to the model as a retry, without an API call.
- A 400 or 422 from the API is also a model retry. Quota, key and network problems raise `NestDaddyError` with a clear message.
- Tool results are compact JSON objects, never raw API payloads.

## Tests

```bash
pip install -e ".[test]"
pytest
```

The tests run offline through `httpx.MockTransport`.

## Links

- API reference: https://nestdaddy.com/apis
- NestDaddy MCP server: https://nestdaddy.com/mcp
- Pydantic AI integration guide: https://nestdaddy.com/integrations/pydantic-ai

MIT licensed.
