Skip to main content

ask-pydantic

A python library and CLI tool to ask questions about Pydantic AI and Logfire documentation using AI-powered search.

# run with uvx
uvx ask-pydantic
uvx ask-pydantic "How do I create an agent?"

# or use in your code
uv add ask-pydantic
from ask_pydantic import agent

result = agent.run_sync("How do I create an agent?")
print(result.output)

https://github.com/user-attachments/assets/f2ab1dfc-f90c-4311-a04c-c41b82eb3052

Installation

# install globally
uv tool install ask-pydantic

Requirements

You need an API key from at least one supported LLM provider:

  • Anthropic (Claude) - Recommended

    export ANTHROPIC_API_KEY="your-key-here"
    
  • OpenAI (GPT)

    export OPENAI_API_KEY="your-key-here"
    
  • Google (Gemini)

    export GOOGLE_API_KEY="your-key-here"
    
  • Mistral

    export MISTRAL_API_KEY="your-key-here"
    
  • Groq

    export GROQ_API_KEY="your-key-here"
    

Tip: Add your API key to a .env file and source it:

echo 'export ANTHROPIC_API_KEY="your-key-here"' > .env
source .env && ask-pydantic "your question"

Usage

CLI Usage

Ask questions directly from the command line:

ask-pydantic "How do I create a Pydantic AI agent? Format your response nicely for a CLI."
ask-pydantic "What is Logfire?"
ask-pydantic "How do I use tools with agents?"

On first run, the tool will ask permission to download documentation (~20MB) from the Pydantic AI and Logfire repositories.

Programmatic Usage

Use the agent in your Python code:

from ask_pydantic import agent

result = agent.run_sync("How do I create an agent?")
print(result.output)

Or run inline with uv:

uv run --with ask-pydantic python - <<'EOF'
from ask_pydantic import agent

result = agent.run_sync("How do I use tools with Pydantic AI?")
print(result.output)
EOF

How It Works

  1. Documentation Download: On first run, the tool downloads documentation from the Pydantic AI and Logfire repositories to ~/.ask-pydantic/docs/
  2. Vector Database: Creates a searchable vector database using LanceDB and sentence transformers
  3. Hybrid Search: Uses both semantic and keyword search to find relevant documentation
  4. AI-Powered Answers: Uses your preferred LLM to generate comprehensive answers with links to source documentation

Examples

# Get started with Pydantic AI
ask-pydantic "How do I get started with Pydantic AI?"

# Learn about tools
ask-pydantic "What are tools and how do I use them?"

# Logfire queries
ask-pydantic "How do I set up Logfire for my application?"

# Specific features
ask-pydantic "How do I stream responses from an agent?"

Configuration

  • Documentation: ~/.ask-pydantic/docs/
  • Vector Database: /tmp/lancedb-pydantic-ai-chat

Development

You may use this as a tempalte for distributing your own Pydantic AI agents as packages so your users can import them in their code. Just expose your own agent object and adjust the ask-pydantic/cli.py to your needs.

# Clone the repository
git clone https://github.com/dsfaccini/ask-pydantic.git
cd ask-pydantic

# Install dependencies
uv sync

# Run locally
uv run ask-pydantic "your question"

License

MIT

Metadata

Release files for ask-pydantic 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ask-pydantic 0.1.4
File Size Uploaded Provenance
ask_pydantic-0.1.4.tar.gz 10.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ask-pydantic 0.1.4
File Interpreter ABI Platform
ask_pydantic-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 20.7 kB

Release files / ask_pydantic-0.1.4.tar.gz

Download URL ask_pydantic-0.1.4.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a232c29eeda6ad5ae052fb54cb4163766a1495e29a8bf9a06e9fb16f9b2ab14b
BLAKE2b-256 checksum
How to use checksums
4c1f3d54b59047bfd43205c86a24deff65ffd9f6f2a7faf824ef4c85fa32d626
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.12

Release files / ask_pydantic-0.1.4-py3-none-any.whl

Download URL ask_pydantic-0.1.4-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f20498b38b17ad48879a9630c6f752f7c60fc6120f944a3fa05e3628c827e3db
BLAKE2b-256 checksum
How to use checksums
45542849dddab579f83db0ad1134a7efc495b2d21bb6c3ca563240a6fa3aa9af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.12

Security for ask-pydantic 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page