Observed since 21 Oct, 11:05 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
JupyterLab extension for AI-powered prompt cells with variable and function references
A JupyterLab extension that adds AI-powered prompt cells with special syntax for referencing kernel variables and exposing functions as AI-callable tools. Inspired by fast.ai's Solveit.
$`variable` - Reference kernel variables in prompts (values substituted automatically)&`function` - Expose Python functions as AI-callable toolsfastcore.tools for file exploration and editingpip install ai_jup
Verify the extension is installed:
jupyter labextension list | grep ai-jup
# Should show: ai-jup v0.1.0 enabled OK
export ANTHROPIC_API_KEY="your-key-here"
To persist across sessions, add to your shell profile:
# For zsh (macOS default)
echo 'export ANTHROPIC_API_KEY="your-key-here"' >> ~/.zshrc
# For bash
echo 'export ANTHROPIC_API_KEY="your-key-here"' >> ~/.bashrc
jupyter lab
Cmd/Ctrl + Shift + P to insert a prompt cellWhat is 2 + 2?Cmd/Ctrl + Shift + Enter to executeYou should see the AI respond with streaming text.
# In a code cell, define some data
data = [1, 2, 3, 4, 5]
Then in a prompt cell:
What is the sum of $`data`?
Press Cmd/Ctrl + Shift + Enter to execute.
$`variable` - Reference VariablesUse $`variable_name` to inject the current value of any Python variable into your prompt:
# In a code cell
sales_data = [
{'product': 'Widget A', 'units': 150, 'price': 25.99},
{'product': 'Widget B', 'units': 89, 'price': 45.50},
]
Given $`sales_data`, which product has the highest revenue?
The AI sees the actual data and can provide specific analysis.
&`function` - Expose Functions as ToolsUse &`function_name` to let the AI call Python functions during its response:
# In a code cell
def calculate_revenue(data: list) -> float:
"""Calculate total revenue from sales data."""
return sum(item['units'] * item['price'] for item in data)
def top_seller(data: list) -> dict:
"""Find the product with the most units sold."""
return max(data, key=lambda x: x['units'])
Use &`calculate_revenue` and &`top_seller` to analyze $`sales_data`.
The AI can call these functions, see the results, and incorporate them into its response.
ai-jup includes fastcore.tools for file exploration and editing:
from fastcore.tools import view, rg, sed, create, str_replace, insert
| Tool | Description |
|---|---|
view(path, view_range?, nums?) | View directory or file contents with optional line range |
rg(argstr) | Run ripgrep to search for patterns |
sed(argstr) | Run sed for reading sections of files |
create(path, file_text, overwrite?) | Create a new file with given content |
str_replace(path, old_str, new_str) | Replace first occurrence in file |
insert(path, insert_line, new_str) | Insert text at specified line number |
# Clone a repo to explore
!git clone https://github.com/AnswerDotAI/fastcore --depth 1 -q
repo_path = 'fastcore'
from fastcore.tools import view, rg
Use &`view` to explore $`repo_path` and tell me what this library does.
Then use &`rg` to find all decorator definitions.
The AI will:
view('fastcore') to see the directory structureview('fastcore/fastcore/basics.py') to read key filesrg('"def.*decorator" fastcore/') to search for patternsPrompt cells are markdown cells with special metadata (ai_jup.isPromptCell: true). They're visually distinguished with a colored border and "AI Prompt" prefix.
When you execute a prompt cell, ai-jup:
$`variables` - Queries the kernel for each variable's type and repr&`function` metadata - Gets signatures, docstrings, and parameter infoWhen the AI calls a tool:
The loop continues for up to 5 iterations (configurable via max_steps).
Tool results are automatically formatted:
| Shortcut | Action |
|---|---|
Cmd/Ctrl + Shift + P | Insert new prompt cell below |
Cmd/Ctrl + Shift + Enter | Execute prompt cell |
| Variable | Required | Description |
|---|---|---|
ANTHROPIC_API_KEY | Yes | Your Anthropic API key |
claude-sonnet-4-20250514claude-3-5-sonnet-20241022claude-3-haiku-20240307To change the model, edit the cell metadata:
{
"ai_jup": {
"isPromptCell": true,
"model": "claude-3-haiku-20240307"
}
}
git clone https://github.com/hamelsmu/ai-jup.git
cd ai-jup
just install # Install in dev mode with live reload
just test # Run all tests
just lab # Start JupyterLab
just --list # See all commands
Requires just (brew install just on macOS).
ai-jup/
├── src/ # TypeScript frontend
│ ├── index.ts # Extension entry point
│ ├── promptCell.ts # Prompt cell management
│ ├── kernelConnector.ts # Kernel introspection
│ ├── promptParser.ts # $`variable` and &`function` parsing
│ ├── toolResultRenderer.ts # Tool result formatting
│ └── *.test.ts # Jest tests
├── ai_jup/ # Python backend
│ ├── handlers.py # API endpoints
│ └── __init__.py # Server extension setup
├── tests/ # Python test suite
├── style/ # CSS styles
└── justfile # Development commands
| Endpoint | Method | Description |
|---|---|---|
/ai-jup/prompt | POST | Stream AI response with tool loop |
/ai-jup/tool-execute | POST | Execute a single tool call |
/ai-jup/models | GET | List available models |
| Feature | Solveit | ai-jup |
|---|---|---|
| Variable syntax | $`varname` | $`varname` |
| Function syntax | &`funcname` | &`funcname` |
| Platform | VS Code | JupyterLab |
| API | Multiple providers | Anthropic Claude |
| File tools | Built-in | fastcore.tools |
ai-jup uses the same syntax as Solveit for compatibility.
If you installed ai-jup but it's not working:
# Verify extension is installed
jupyter labextension list | grep ai-jup
# Restart JupyterLab (required after first install)
# Close JupyterLab and run:
jupyter lab
The API key must be set in the environment before starting JupyterLab:
export ANTHROPIC_API_KEY="your-key-here"
jupyter lab
If you set the key after JupyterLab started, you need to restart it.
pip install anthropic
Make sure you're in command mode (press Esc first), then try the shortcut. If shortcuts still don't work, check for conflicts in Settings → Advanced Settings → Keyboard Shortcuts.
Ensure the function is defined in the kernel before referencing it with &`functionname`. Run the code cell that defines the function first, then execute the prompt cell.
MIT License - see LICENSE for details.
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.1.2 | 31 Dec 2025 | 7 |
This describes our collected data; it is not a security assessment.
Observed since 21 Oct, 11:05 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:1b1e42f5d216be4720d44c5390ea6cb1649af1fd5b7a2c76ac77c70799f7d42c