Experiment with Pydantic AI Agents in your notebooks.
Project description
pydantic-ai-jupyter
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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d942b123e50357c92b64bf749cc1a4da60949d2d821d5fb40c03f5a0a41c6ac2
|
|
| MD5 |
6440e544e0db9119e9ce5501598091f2
|
|
| BLAKE2b-256 |
a058ce29cc80fd3b60a8496cd68453c16549b0c009786408f84b7f34e2c5d8d1
|
Provenance
The following attestation bundles were made for pydantic_ai_jupyter-0.1.2.tar.gz:
Publisher:
publish.yml on rgbkrk/pydantic-ai-jupyter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pydantic_ai_jupyter-0.1.2.tar.gz -
Subject digest:
d942b123e50357c92b64bf749cc1a4da60949d2d821d5fb40c03f5a0a41c6ac2 - Sigstore transparency entry: 858002308
- Sigstore integration time:
-
Permalink:
rgbkrk/pydantic-ai-jupyter@157ec97d40b4a32426c0048a728ca5267d8f26d9 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/rgbkrk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@157ec97d40b4a32426c0048a728ca5267d8f26d9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pydantic_ai_jupyter-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pydantic_ai_jupyter-0.1.2-py3-none-any.whl
- Upload date:
- Size: 11.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 |
99fa25612bf75de578b985372fdffe8eccea7303b5ff750df063c67d53d522d3
|
|
| MD5 |
8d76d4dca4e73780336fd05ed9f91809
|
|
| BLAKE2b-256 |
66a5773e2e510e714bbef05b24c9458da673cb6fc640f79b713d152088b6bfeb
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pydantic_ai_jupyter-0.1.2-py3-none-any.whl -
Subject digest:
99fa25612bf75de578b985372fdffe8eccea7303b5ff750df063c67d53d522d3 - Sigstore transparency entry: 858002363
- Sigstore integration time:
-
Permalink:
rgbkrk/pydantic-ai-jupyter@157ec97d40b4a32426c0048a728ca5267d8f26d9 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/rgbkrk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@157ec97d40b4a32426c0048a728ca5267d8f26d9 -
Trigger Event:
push
-
Statement type: