Chat & Slash Commands
The Lab sidebar includes a chat panel powered by Jupyter AI. Use it to ask questions about your code, get explanations, generate notebooks, and run specialized slash commands.
Opening the Chat
Click the chat bubble icon in the left panel, or use the keyboard shortcut to open the AI chat sidebar.
Slash Commands
| Command | What it does |
|---|---|
/learn <path> | Index files or directories so the AI can answer questions about them |
/ask <question> | Query the indexed content |
/generate <description> | Generate a new notebook from a natural language description |
/fix | Diagnose and fix the error in the selected cell |
/doc | Generate docstrings for the selected code |
/refactor | Suggest refactors for the selected code |
/explain | Explain what the selected code does |
/test | Generate unit tests for the selected code |
/visualize | Generate a visualization for the selected data |
/analyze | Analyze the selected data or results |
/data | Ask a question about your connected datasources |
/clear | Reset the conversation history |
/learn — Index Your Codebase
Index a directory so the AI can answer questions about your project:
/learn ./src/learn ./data/schema.sqlAfter indexing, ask questions with /ask:
/ask How does the authentication middleware work?
/ask What tables does the orders module use?The index persists for the session. Re-run /learn after adding new files.
/generate — Create Notebooks
Generate a complete notebook from a description:
/generate Analyze customer churn using the CRM database. Include cohort analysis and a retention funnel.The AI will scaffold cells with code, markdown explanations, and suggested visualizations.
/fix — Fix Errors
After a cell raises an exception:
- Select the error cell
- Type
/fixin the chat
The AI reads the traceback and proposes a corrected version of the cell.
/doc, /explain, /refactor, /test
All of these work on the selected cell or selected code:
/doc # Add docstrings
/explain # Plain-English explanation
/refactor # Suggest improvements
/test # Generate pytest unit testsModel Selection
The chat uses whatever model is selected in the model dropdown at the top of the chat sidebar. Change it to switch between providers (Claude, GPT-4o, Gemini, etc.) mid-conversation.
To use a specific model for a single magic command:
%%ai anthropic:claude-3-5-sonnet-20241022
Your prompt hereSee AI Magic for full %%ai documentation.