preloader
blog post

The %calliope Magic Command: AI in Your Jupyter Notebook

author image

AI Power at Your Fingertips

Jupyter notebooks are where data work happens. Exploration, analysis, visualization—all in one interactive document. But switching between your notebook and an AI assistant breaks flow.

The %calliope magic command brings AI directly into your notebook cells.

What Are Magic Commands?

Jupyter magic commands are special commands prefixed with % that extend notebook functionality. The %calliope magic gives you AI capabilities without leaving your notebook.

Natural Language to SQL

The most powerful feature: ask questions in plain English, get SQL.

%calliope ask-sql What were total sales by region last quarter?

Calliope understands your database schema, writes the appropriate SQL, executes it, and returns results—all in one command.

Just Run SQL

Already know what query you want? Execute it directly:

%calliope run-sql SELECT customer_id, sum(amount) FROM orders GROUP BY 1

Results display inline in your notebook, ready for further analysis.

Chat in Your Notebook

Need to discuss, explain, or brainstorm?

%calliope chat Explain what this correlation matrix is showing me

Have a conversation about your data, your code, or your analysis—without switching applications.

Manage Data Sources

List available databases:

%calliope list-datasources

Add new connections:

%calliope add-database

Your data sources are a command away.

Choose Your Model

Different tasks benefit from different models. Switch easily:

%calliope ask-sql -m claude What's our customer lifetime value?

Or use model shortcuts:

  • gpt4o → OpenAI GPT-4o
  • claude → Anthropic Claude 3.5 Sonnet
  • gemini → Google Gemini
  • llama → Local Llama via Ollama

List available models:

%calliope list-models

Automatic Visualizations

When your query returns data suitable for visualization, Calliope automatically generates Plotly charts. Ask for “sales by month” and get a chart, not just a table.

Streaming Responses

Long analyses stream results as they’re generated. Watch the AI think through your problem in real-time.

Provider Support

The magic command supports all major providers:

  • OpenAI: GPT-4, GPT-4 Turbo, GPT-3.5
  • Anthropic: Claude 3.5, Claude 3
  • Google: Gemini Pro, Gemini Ultra
  • Amazon Bedrock: Multiple models
  • Mistral: Mistral Large, Mixtral
  • Cohere: Command R+
  • NVIDIA: NIM models
  • Local: Ollama for offline use

Configure once, switch anytime.

Example Workflow

# Start by exploring available data
%calliope list-datasources

# Ask a question in natural language
%calliope ask-sql Which products have declining sales this quarter?

# Get more details
%calliope ask-sql Show me monthly trends for those products

# Discuss the results
%calliope chat What might explain this pattern?

# Generate a summary
%calliope chat Write a brief analysis of this trend for my report

Your entire analysis flow—from data exploration to final report—happens in your notebook.

Getting Started

The %calliope magic command is available in AI Lab. Load the extension:

%load_ext calliope

Then start using %calliope commands in any cell.

Get started with AI Lab →

Related Articles