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)

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.0.tar.gz (322.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.0-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pydantic_ai_jupyter-0.1.0.tar.gz
  • Upload date:
  • Size: 322.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.23 {"installer":{"name":"uv","version":"0.9.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pydantic_ai_jupyter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 032296e665d99c3f0ee08a2fb327ee0e5592da98cb505e5be9d637ee48858ab5
MD5 917db75921e20fcaab89d4c1413b470f
BLAKE2b-256 00485ff78a1f8f82ab352128b25566fb848bc34e76bf5d6fb40388f942c8f827

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pydantic_ai_jupyter-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.23 {"installer":{"name":"uv","version":"0.9.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pydantic_ai_jupyter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb423c2ef45962456be9d5ac134dd83f56ac6e54e7a47a0eda7589e7ba11b9d0
MD5 f4e71b31380b35b3bda7d732ad5bc2e1
BLAKE2b-256 4f289d232cf7fe1f07b528b8c8542fe57a1b95393c77ba546841a34dcc766115

See more details on using hashes here.

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