Welcome to Sagely’s documentation!

Sagely Banner

LLM-powered assistant for every Python package!

Just add .sage.ask("your question") to talk to any module.

Sagely Agent automatically injects a .sage assistant into every package you import. Ask questions about the library you’re using, get help with errors, and explore code with syntax-highlighted answers — all powered by an LLM.

Quick Start

Install Sagely:

pip install sagely

Set up your API key:

export OPENAI_API_KEY='your-api-key-here'

Start using it:

import sagely
import matplotlib

matplotlib.sage.ask("how to make a scatter plot?")

Why Sagely?

There are thousands of Python libraries, but their docs aren’t always intuitive. Moreover, getting help about errors or finding usage requires (at least) asking an LLM manually. With Sagely, you can do all that right from the REPL or the Jupyter notebook:

  • You don’t need to search Stack Overflow, or ask ChatGPT, every time you forget a method or run into an error.

  • You get context-aware help, including recent exceptions and object summaries.

  • It’s built for exploration — whether you’re using a notebook, or REPL.

Key Features

  • 🧠 Ask any module .sage.ask("How do I do X?") (prints the answer)

  • 💡 Smart context: recent errors + object summaries

  • 🧩 Auto-attaches to every import

  • 💾 Caches answers to avoid repeated API calls

  • 📦 Caches module analysis for faster subsequent queries

  • 🎨 Syntax-highlighted output with rich

  • 🧠 IPython magic: %sagely pandas how to merge?

  • 🔍 Real-time status updates showing agent flow progress

  • 🌐 Web search integration with multiple providers

  • 📊 LangSmith tracing for debugging and monitoring

  • ⚙️ Centralized configuration system for customizing agent behavior

  • 💰 Token usage tracking with model-specific breakdowns

  • 📈 Usage analytics with session management and historical data

Requirements

  • OpenAI API key (set as OPENAI_API_KEY environment variable)

  • Tavily API key (optional, for Tavily web search provider)

  • LangSmith API key (optional, for tracing)

Indices and tables