Skip to main content

Jupyter kernel that allows you generate code from natural language prompts

Project description

ICortex Kernel

Github Actions Status License

ICortex is a Jupyter kernel that supercharges your Jupyter Notebook workflow by letting you generate Python code automatically from natural language prompts:

https://user-images.githubusercontent.com/2453968/193281898-8f2b4311-2a3a-4bbf-a7d4-b31fcd4f5e08.mp4

It is ...

  • a drop-in replacement for the IPython kernel. Prompts start with a forward slash /—otherwise the line is treated as regular Python code.
  • interactive—install missing packages directly, decide whether to execute the generated code or not, directly in the Jupyter Notebook cell.
  • open source and fully extensible—if you think we are missing a model or an API, you can request it by creating an issue, or implement it yourself by subclassing ServiceBase under icortex/services.

ICortex is currently in alpha, so expect breaking changes. We are giving free credits to our first users—join our Discord to help us shape this product.

Installation

To install the ICortex Kernel, run the following in the main project directory:

pip install icortex

This will install the Python package and the icortex command line interface. You will need to run icortex once to install the kernel spec to Jupyter.

Using ICortex

Before you can use ICortex in Jupyter, you need to configure it for your current project.

To do that, simply launch the ICortex shell in your terminal:

icortex

The shell will instruct you step by step and create a configuration file icortex.toml in your current directory.

Choosing a code generation service

ICortex supports different code generation services such as the TextCortex code generation API, OpenAI Codex API, local HuggingFace transformers, and so on.

To use the TextCortex code generation API,

  1. sign up on the website,
  2. generate an API key on the dashboard,
  3. and proceed to configure icortex for your current project:

asciicast

If you use up the starter credits and would like to continue testing out ICortex, hit us up on our Discord on #icortex channel and we will charge your account with more free credits.

You can also try out different services e.g. OpenAI's Codex API, if you have access. You can also run code generation models from HuggingFace locally, which we have optimized to run on the CPU—though these produce lower quality outputs due to being smaller.

Launch JupyterLab

Now that ICortex is configured for your project, you can launch JupyterLab:

jupyter lab

and choose ICortex as your kernel when creating a new notebook.

Usage

To execute a prompt with ICortex, use the / character (forward slash, also used to denote division) as a prefix. Copy and paste the following prompt into a cell and try to run it:

/print Hello World. Then print the Fibonacci numbers till 100

Depending on the response, you should see an output similar to the following:

print('Hello World.', end=' ')
a, b = 0, 1
while b < 100:
    print(b, end=' ')
    a, b = b, a+b

Hello World.
1 1 2 3 5 8 13 21 34 55 89

You can also specify variables or options with command line flags, e.g. to auto-install packages, auto-execute the returned code and so on. To see the complete list of variables for your chosen service, run:

/help

Getting help

To get support, join our Discord.

Uninstalling

To uninstall, run

pip uninstall icortex

This removes the package, however, it may still leave the kernel spec in Jupyter's kernel directories, causing it to continue showing up in JupyterLab. If that is the case, run

jupyter kernelspec uninstall icortex -y

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

icortex-0.0.2.tar.gz (22.3 kB view details)

Uploaded Source

Built Distribution

icortex-0.0.2-py3-none-any.whl (26.5 kB view details)

Uploaded Python 3

File details

Details for the file icortex-0.0.2.tar.gz.

File metadata

  • Download URL: icortex-0.0.2.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.14

File hashes

Hashes for icortex-0.0.2.tar.gz
Algorithm Hash digest
SHA256 bf4f9ed3080e998b04f618a862932abc14075d17d85a2476d65d474ed48ac3b7
MD5 0fa8a3e8b065f4996f6c2efc6f801059
BLAKE2b-256 b332707b9f14095963917e5e69518501f4b8363494ab10fcf2a6a66fb370ca40

See more details on using hashes here.

File details

Details for the file icortex-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: icortex-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 26.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.14

File hashes

Hashes for icortex-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 97a03a526d6856c84275797ac599490ba838ef54b3f8afd4abcde4d31fddc88d
MD5 8264e75533ab48104ed49eec2f7387e7
BLAKE2b-256 b5bc0468079ddaa38afe42a43c466af3136eb86a1dc9a9efb847b5dc14231b72

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page