Skip to main content

CLI tool to ask questions about Pydantic AI and Logfire documentation

Project description

ask-pydantic

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

Installation

# Install with uv (recommended)
uvx ask-pydantic "How do I create an agent?"

# Or 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"

Links

License

MIT

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

ask_pydantic-0.1.1.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

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

ask_pydantic-0.1.1-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file ask_pydantic-0.1.1.tar.gz.

File metadata

  • Download URL: ask_pydantic-0.1.1.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.12

File hashes

Hashes for ask_pydantic-0.1.1.tar.gz
Algorithm Hash digest
SHA256 dee752057a201a4d05086ac349c14ab786d0dad5f132f78d47bbd938603073b8
MD5 96c1028a5950ae75232d37760094a5da
BLAKE2b-256 22b653983e7dfedbdb00242c7a6fbb41e56ddfb6529cfdaa527490341312c5a2

See more details on using hashes here.

File details

Details for the file ask_pydantic-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for ask_pydantic-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7ca505a4a39ca53002acf903ea153065fc84ec61e1ca28cacdd5ce8009691b0e
MD5 cc787719adb25e28fc88a14f06b51d66
BLAKE2b-256 c3abd2c4f35019b38efc768a34d5c17518ab77f24419d67a11f3254d7e5dab35

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