GithubHelp home page GithubHelp logo

lhr0909 / jupyterlab-codex Goto Github PK

View Code? Open in Web Editor NEW
87.0 9.0 30.0 169 KB

JupyterLab Extension that unlocks the power of OpenAI's Codex Model.

License: BSD 3-Clause "New" or "Revised" License

JavaScript 6.51% Python 39.80% TypeScript 53.53% CSS 0.15%

jupyterlab-codex's Introduction

jupyterlab_codex

Github Actions Status

JupyterLab extension that unlocks the power of OpenAI's Codex Model.

This extension is pre-built extension available on PyPI named jupyterlab-codex

Requirements

  • JupyterLab >= 3.0

Install

To install the extension, execute:

pip install jupyterlab-codex

Uninstall

To remove the extension, execute:

pip uninstall jupyterlab-codex

How to Use

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.

You will find a hexagon icon on the toolbar of a notebook. Once you click with an active code cell, it will send the content of the cell to the Codex Model and set up the completion.

You can also send more than one cell by selecting the code cells and clicking the toolbar button. The completion will be added to the last selected code cell.

Contributing

Development install

Note: You will need NodeJS to build the extension package.

The jlpm command is JupyterLab's pinned version of yarn that is installed with JupyterLab. You may use yarn or npm in lieu of jlpm below.

# Clone the repo to your local environment
# Change directory to the jupyterlab_codex directory
# Install package in development mode
pip install -e .
# Link your development version of the extension with JupyterLab
jupyter labextension develop . --overwrite
# Server extension must be manually installed in develop mode
jupyter server extension enable jupyterlab_codex
# Rebuild extension Typescript source after making changes
jlpm run build

You can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension.

# Watch the source directory in one terminal, automatically rebuilding when needed
jlpm run watch
# Run JupyterLab in another terminal
jupyter lab

With the watch command running, every saved change will immediately be built locally and available in your running JupyterLab. Refresh JupyterLab to load the change in your browser (you may need to wait several seconds for the extension to be rebuilt).

By default, the jlpm run build command generates the source maps for this extension to make it easier to debug using the browser dev tools. To also generate source maps for the JupyterLab core extensions, you can run the following command:

jupyter lab build --minimize=False

Development uninstall

# Server extension must be manually disabled in develop mode
jupyter server extension disable jupyterlab_codex
pip uninstall jupyterlab_codex

In development mode, you will also need to remove the symlink created by jupyter labextension develop command. To find its location, you can run jupyter labextension list to figure out where the labextensions folder is located. Then you can remove the symlink named jupyterlab-codex within that folder.

Packaging the extension

See RELEASE

jupyterlab-codex's People

Contributors

lhr0909 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jupyterlab-codex's Issues

How to mention API key on jupyterlab?

How to add an API key in JupyterLab: > settings->advanced settings I can see this icon under options -> advanced settings after installing jupyterlab-coded, but I'm not sure how to include the API key in the settings because it's not editable.

Update Default Engine Name to code-davinci-002

Problem: It is not clear what the status of this project is and letting folk know what the project development status is helpful in order for them to appraise if to commit to it or not (after all one needs to register for a codex API key and add it to jupyter-lab, wherein version 3.4.4 had a bug that did not permit the editing of the config JSON in the browser etc.).

Solution: Could a classifier entry be added to setup.py file for development status along with a badge in the readme.md?
development status

The last edit was 11 months ago and it is mentioned in a few sites, so I assumed it was Development Status :: 5 - Production/Stable. But after trying to use it I think it's a Development Status :: 2 - Pre-Alpha or Development Status :: 7 - Inactive.
As it currently stands, it does work as it makes an incorrect API call:

import requests

#api_key = 'πŸ‘ΎπŸ‘ΎπŸ‘ΎπŸ‘Ύ'
response = requests.post('https://api.openai.com/v1/engines/davinci-codex/completions', 
                                             headers=dict(Authorization= f'Bearer {api_key}'),
                                             data=dict(...)
                                             )
response.json()

"That model does not exist" is returned because now goes in the POST params.

# https://beta.openai.com/docs/models/content-filter
response = requests.post('https://api.openai.com/v1/completions',
                                             headers=dict(Authorization= f'Bearer {api_key}'),
                                             data=dict(model='code-davinci-002',  ...),
                                             )
response.json()

Also, to use code-davinci-002 for code completion I believe one needs to sign up to the waiting list at https://beta.openai.com/docs/models/codex-series-private-beta.

Better Documentation

Please help update the documentation on anything that could be missing, including usage docs and development docs.

Jupyterlab-codex cant communicate with server

I created a sever on GCP and I tunnel it to my local computer via putty.
As you can see in the server log, the codex plugin you made is not talking to the right server. I am confused if it is security issue on the GCP side, or the tunnel, or if your code dont allow this possibility.

----this is interesting because its an cloud application, so far it works fine locally----

this is my server log:
[I 2021-09-22 19:00:03.921 ServerApp] 302 GET / (::1) 0.61ms [W 2021-09-22 19:00:07.030 LabApp] Could not determine jupyterlab build status without nodejs [W 2021-09-22 19:00:08.247 ServerApp] Notebook Untitled2.ipynb is not trusted [I 2021-09-22 19:00:08.739 ServerApp] Kernel started: c9114e1c-70b4-4791-b32d-35aae6dbc686 [W 2021-09-22 19:00:12.470 ServerApp] 404 POST /jupyterlab-codex/completion?1632337212823 (::1) 26.81ms referer=http://localhost:8888/lab/tree/Untitled2.ipynb

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.