Overview
HAI Build provides specialized commands for working with Jupyter notebooks in VS Code. Get AI assistance to generate, explain, and improve notebook cells while maintaining the context of your data science or analysis workflow.Features
Generate Cells
Create new notebook cells with AI-generated code
Explain Cells
Get detailed explanations of what cells do
Improve Cells
Optimize and enhance existing cells
Setup
Ensure you have the necessary extensions:Install Required Extensions
Make sure you have installed:
- HAI Build Code Generator (this extension)
- Jupyter Extension for VS Code (by Microsoft)
Open a Jupyter Notebook
Open any
.ipynb file in VS Code. The notebook interface will activate with HAI Build commands available.Generating Notebook Cells
Create new cells with AI-generated code based on your prompts.Access Generate Command
Click the Generate Jupyter Cell icon (sparkle icon) in the notebook toolbar at the top.Or use Command Palette:
- Press
Cmd+Shift+P(Mac) orCtrl+Shift+P(Windows/Linux) - Type Generate Jupyter Cell with HAI
- Press Enter
Enter Your Prompt
A prompt input box appears. Describe what you want the cell to do:Press Enter to confirm or Esc to cancel.
Review Generated Cell
HAI Build:
- Analyzes your notebook context (existing cells, variables, imports)
- Generates appropriate code
- Inserts a new cell above or below the current cell
- Populates it with the generated code
The AI considers your existing notebook context, including imported libraries and defined variables.
Generation Examples
- Data Loading
- Data Visualization
- Statistical Analysis
Prompt:Generated Cell:
Explaining Notebook Cells
Get detailed explanations of what existing cells do.Trigger Explain
Click the Explain Jupyter Cell icon (question mark icon) in the cell toolbar.Or use Command Palette:
- Press
Cmd+Shift+P/Ctrl+Shift+P - Type Explain Jupyter Cell with HAI
- Press Enter
Explanation Example
Cell Code:Improving Notebook Cells
Optimize, enhance, or fix existing cells with AI assistance.Trigger Improve Command
Click the Improve Jupyter Cell icon (lightbulb icon) in the cell toolbar.Or use Command Palette:
- Press
Cmd+Shift+P/Ctrl+Shift+P - Type Improve Jupyter Cell with HAI
- Press Enter
Improvement Examples
- Add Error Handling
- Optimize Performance
- Enhance Visualization
Original Cell:Improved Cell:
Best Practices for Notebook AI Assistance
Provide Context in Prompts
Provide Context in Prompts
Help HAI understand your notebook’s context:Good prompts:
- ✅ “Create a function to preprocess the text column removing special characters”
- ✅ “Calculate correlation between features X1-X10 and the target variable”
- ✅ “Generate a confusion matrix for the classifier stored in ‘model’ variable”
- ❌ “Make a chart”
- ❌ “Process the data”
- ❌ “Add some analysis”
Maintain Cell Organization
Maintain Cell Organization
Keep your notebook well-structured:
- Imports at top: Generate import cells first
- Data loading: Load data before processing
- Exploration: Analysis cells in logical order
- Modeling: Train/test/evaluate sequentially
- Visualization: Display results clearly
Run Cells to Establish Context
Run Cells to Establish Context
HAI works better when cells are executed:
- Execute cells to define variables and imports
- HAI can reference executed variables in generations
- Kernel state helps determine what’s available
Iterate on Generated Code
Iterate on Generated Code
Refine generated cells through conversation:Example:
Workflow
Combine with Regular HAI Chat
Combine with Regular HAI Chat
For complex notebook tasks:
- Use Jupyter commands for quick cell operations
- Use HAI chat for multi-cell workflows or complex refactoring
- Select multiple cells and add to HAI chat for broader context
Common Notebook Workflows
Data Science Pipeline
Data Analysis Report
Tips for Effective Jupyter AI Usage
Specify Libraries
Mention preferred libraries in your prompts:“Use seaborn to create…”“With scikit-learn, implement…”
Request Comments
Ask for documented code:“Add comments explaining each step”“Include docstrings”
Define Variables
Reference existing variables:“Using the ‘df’ DataFrame…”“Apply this to ‘X_train’ and ‘y_train’”
Set Expectations
Be clear about outputs:“Return a pandas Series”“Display results in a table format”
Troubleshooting
- Commands Not Visible
- Context Errors
- Import Issues
Issue: HAI Build icons don’t appear in notebookSolutions:
- Ensure HAI Build extension is installed and enabled
- Verify Jupyter extension is active
- Reload VS Code window:
Cmd+Shift+P→ “Reload Window” - Check notebook type is
jupyter-notebook
Next Steps
Code Generation
Learn more about AI-powered code generation
Task Execution
Execute larger notebook development tasks
Settings
Configure LLM providers for notebook assistance
MCP Integration
Connect to data sources via Model Context Protocol
Data Science Tip: Use HAI Build to quickly prototype analysis workflows, then refine the code for production use. The AI excels at generating exploratory code and visualizations.