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.
# 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
- Documentation Download: On first run, the tool downloads documentation from the Pydantic AI and Logfire repositories to
~/.ask-pydantic/docs/ - Vector Database: Creates a searchable vector database using LanceDB and sentence transformers
- Hybrid Search: Uses both semantic and keyword search to find relevant documentation
- 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
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 ask_pydantic-0.1.3.tar.gz.
File metadata
- Download URL: ask_pydantic-0.1.3.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a9941e12103586884a25a5152fbdf237e6f6f4fa0e7a6b1c5450c15467ead31
|
|
| MD5 |
469af7d14c4ada71d38820a46c69e321
|
|
| BLAKE2b-256 |
db161133257c962b7516c44453903e608dee9483e174480e49da0e93830eae70
|
File details
Details for the file ask_pydantic-0.1.3-py3-none-any.whl.
File metadata
- Download URL: ask_pydantic-0.1.3-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ead72280a45f7fb2ea6d728122f82f47fba21bbb203d80941bdfb382ac0d38fd
|
|
| MD5 |
186a2fefcf6e21c1784561954ab24a5c
|
|
| BLAKE2b-256 |
6f8e90dc90be72f1ea013dd07cd9a6f5dd7b6b9870f85a144ac6cd2518a46fad
|