JupyterLab Plugin for Codex

I was wondering if I can have a Python sandbox that can leverage the power of Codex. I decided to see if I can get this integrated into Jupyter. After a few days of research and navigating the extension building process, I put together a JupyterLab plugin that can generate code based on the code cells in a Jupyter Notebook. I was able to recreate the hello world experience in the live demo.

I do not have a lot of experience in JupyterLab extension building, so the plugin is still quite rough. Will gladly take any feedback and PRs to refine it over time!

12 Likes

I don’t think so. Colab is a closed environment with no extension system. There might be a way to build a browser extension to hook into the code cells from the browser level

1 Like

Awsome job simon!

Bit of a newbie when it comes to jupyter extensions here, can you elaborate a bit more on this part:

After installing, you can find the extension settings in Settings -> Advanced Settings Editor and you can add your API keys and adjust the completion settings there.

Where exactly do we put our API keys?

Hey, sorry I have been busy with work. But you can check this issue - How to mention API key on jupyterlab? · Issue #3 · lhr0909/jupyterlab-codex · GitHub

Seems like you don’t have the extension installed (properly). You might need to restart JupyterLab to see the setting, since there is a server module for posting to the OpenAI API.

1 Like

Got this working. Pretty cool!

3 Likes

Got an Issue
It install, I put my API. However when I use the button Codex it! nothing happens.

Hey, if you have just installed the plugin, you might need to restart the jupyterlab server for it to work.
You can refer to this issue on GitHub - How to mention API key on jupyterlab? · Issue #3 · lhr0909/jupyterlab-codex · GitHub

Not the same issue, the server gives me 404. It must be some security thing on the GCP server. You must be running jupyter locally. I run it on HPCs on the cloud for production.
The installation of the plugin is fine.

Maybe you can try to look into the source code and see what went wrong. Because the way the plug-in is built is relying on the jupyter server to expose an endpoint for the codex request. The Python code needs to be registered. Usually a restart resolves the issue.

pappachuck via OpenAI API Community Forum <openai1@discoursemail.com>于2021年9月23日 周四03:55写道:

Where is the URL?

const requestUrl = URLExt.join(
    settings.baseUrl,
    'jupyterlab-codex', // API Namespace
    endPoint,
  );

This is a jupterlab base setting I believe. You might want to look into your settings on the jupyterLab. This part of the code is generated by their extension template.

Mate, it has been THE learning curve. Learning Jupyter remember me the first time I learned LaTeX

1 Like

Yeah… I didn’t have a lot of experience with Python (last time I intensively used Python was v2.5 about 10 years ago) until very recently, and definitely not a lot of experience with JupyterLab extension building, and when I looked at the docs on JupyterLab, there wasn’t a lot of useful information to help me build the extension. I had to look at other extensions and improvise. I had Codex help me write some parts of the extension though (in the form of GitHub Copilot), and it was able to know some APIs about the extension building and spit out useful parts for me!

1 Like