LEAP (Live Exploration of AI-Generated Programs) combines Projection Boxes with a Copilot-like tool that generates code completions within the current buffer. You can find an up-to-date version of this artifact on GitHub.
LEAP (similar to Projection Boxes) uses a modified version of Visual Studio Code, including Projeciton Boxes and LEAP as separate contributions in the editor. For code generation, it uses OpenAI's Completion API.
For any questions, please reach out to the authors of the paper Kasra Ferdowsi and Ruanqianqian (Lisa) Huang, or create an issue on GitHub.
To build LEAP, you need to first install the following:
- Node.js 16
- Python 3.8 or above
- The
numpy
Python package - The
matplotlib
Python package - yarn 1.22.x
- An OpenAI API key to use for generating completions.
Once you satisfy the requirements please follow the next steps to setup your environment.
The simplest way to build and run LEAP is directly within the terminal. To do so:
- (Mac users only) Open up a terminal, type
arch
to ensure that you are using a x86_64 architecture. M1 is currently not supported. - Navigate to the directory containing this README file.
- Run
yarn
oryarn install
. This will install all the necessary node packages. Ensure that this command finishes successfully. If not, please look at the errors and address them before moving on. - Run
yarn compile
. This will compile the source code.
You can also build LEAP by opening this directory inside a regular instance of VSCode. To do so:
- Follow steps 1-3 above.
- Open the directory containing this README in VSCode.
- Run
Ctrl + Shift + B
(Cmd + Shift + B
on Mac) to compile the source code.
Unlike the terminal instructions which build the source once, this starts a build daemon which automatically recompiles the code after edits. You may find this useful if you are modifying the source code.
LEAP depends on a number of environment variables that must be present and set correctly for it to work. These env vars are:
PYTHON3
: Absolute path to the Python 3 executable.RUNPY
: Absolute path to the./src/run.py
file.IMGSUM
: Absolute path to the./src/img-summary.py
file.LEAP_PROMPT
: Absolute path to the./src/implement_it.txt
file.OPENAI_API_KEY
: Your OpenAI API key.
How you set these variables is up to you (e.g. you could set them globally) but here we include instructions for setting them for running from the terminal, and from VSCode.
We have provided a shell script for running LEAP in ./run.sh
. First edit the script in a text editor and replace OPENAI API KEY HERE
with your OpenAI API key. The other env vars should be set automatically, but if you run into issues, you may want to hard code them in this script as well.
After editing this file, save and close and run it with ./run.sh
. Note that you must build LEAP before running this script, otherwise you will run into errors.
To run LEAP directly from VSCode:
- Open the directory containing this README in VSCode.
- In the
launch.json
under.vscode
directory set the env vars above underLaunch VS Code Internal
- You may also configure these environment variables in your shell configuration (e.g., in
~/.profile
). - Alternatively, you may configure the variables in
./.env
, and declare ininputs
in.vscode/launch.json
the id's and keys of the configured variables. For example, if you have configuredPYTHON3=/usr/local/bin/python3
in./.env
, then theinputs
in./vscode/launch.json
should be
and the environment variable configuration in"inputs": [ { "id": "envPYTHON3", "type": "command", "command": "extension.commandvariable.file.content", "args": { "fileName": "${workspaceFolder}/.env", "key": "PYTHON3", "default": "" } } ]
Launch VS Code Internal
, under.vscode/launch.json
, should be"env": { "PYTHON3": "${input:envPYTHON3}" }
- You may also configure these environment variables in your shell configuration (e.g., in
- Run the build by pressing
F5
. Note that you must build LEAP before pressingF5
, otherwise you will run into errors.
To use LEAP, first open a python file or open a new file and save it with a .py
extension. Then, as you write executable Python code, you should see Projection Boxes appearing to show your program's runtime values. To invoke the AI assistant, press Ctrl + Enter
(Cmd + Enter
on Mac) on a new line. This should open a side panel containing code suggestions.