Skip to main content

Experiment with Pydantic AI Agents in your notebooks.

Project description

pydantic-ai-jupyter

Tests

Experiment with Pydantic AI Agents interactively in Jupyter notebooks.

Installation

pip install pydantic-ai-jupyter

Or with uv:

uv add pydantic-ai-jupyter

Usage

from pydantic_ai import Agent
from pydantic_ai_jupyter import run_in_jupyter

agent = Agent("openai:gpt-4o-mini")

@agent.tool_plain
def get_weather(city: str) -> str:
    return f"Sunny, 22°C in {city}"

# Run with rich display
result = await run_in_jupyter(agent, "What's the weather in Tokyo?")

Features

  • Streaming text - See the model's response as it generates
  • Streaming tool calls - Watch tool arguments stream in (with providers that support it, like OpenAI)
  • Tool results - Styled success and retry results
  • Thinking/reasoning - Collapsible display of model thinking
  • Error handling - Graceful display of exceptions with tracebacks

Multi-turn conversations

# First turn
result = await run_in_jupyter(agent, "What's the weather in Tokyo?")

# Continue the conversation
result = await run_in_jupyter(
    agent,
    "What about London?",
    message_history=result.all_messages(),
)

Debug mode

Enable debug mode to see all events:

result = await run_in_jupyter(agent, "Hello!", debug=True)

Supported providers

Tool call argument streaming works best with OpenAI, which streams arguments token-by-token. Other providers like Groq and Ollama (via OpenAI-compat) buffer tool calls and send them all at once.

Provider Text streaming Tool call streaming
OpenAI
Groq ❌ (buffered)
Ollama ❌ (buffered)

Development

See TESTING.md for testing guidelines and PUBLISHING.md for release instructions.

# Install dependencies
uv sync --extra dev

# Run tests
uv run pytest tests/ -v

# Run linting
uv run ruff check .
uv run ruff format .

# Type checking
uv run mypy pydantic_ai_jupyter/

License

BSD 3-Clause

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic_ai_jupyter-0.1.2.tar.gz (281.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydantic_ai_jupyter-0.1.2-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_ai_jupyter-0.1.2.tar.gz.

File metadata

  • Download URL: pydantic_ai_jupyter-0.1.2.tar.gz
  • Upload date:
  • Size: 281.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pydantic_ai_jupyter-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d942b123e50357c92b64bf749cc1a4da60949d2d821d5fb40c03f5a0a41c6ac2
MD5 6440e544e0db9119e9ce5501598091f2
BLAKE2b-256 a058ce29cc80fd3b60a8496cd68453c16549b0c009786408f84b7f34e2c5d8d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydantic_ai_jupyter-0.1.2.tar.gz:

Publisher: publish.yml on rgbkrk/pydantic-ai-jupyter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydantic_ai_jupyter-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_ai_jupyter-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 99fa25612bf75de578b985372fdffe8eccea7303b5ff750df063c67d53d522d3
MD5 8d76d4dca4e73780336fd05ed9f91809
BLAKE2b-256 66a5773e2e510e714bbef05b24c9458da673cb6fc640f79b713d152088b6bfeb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydantic_ai_jupyter-0.1.2-py3-none-any.whl:

Publisher: publish.yml on rgbkrk/pydantic-ai-jupyter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page