Jupyter kernel that allows you generate Python code from natural language prompts
Project description
ICortex Kernel
ICortex is a Jupyter kernel that lets you program with plain English, by letting you generate Python code 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. - a Natural Language Programming interface—prompts written in plain English automatically generate Python code which can then be executed in the global namespace.
- interactive—install missing packages directly, decide whether to execute the generated code or not, and so on, 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
undericortex/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.
If you are using the terminal:
icortex init
Alternatively, you can initialize directly in a Jupyter Notebook (instructions on how to start JupyterLab):
//init
The shell will then instruct you step by step and create a configuration file icortex.toml
in the current directory.
Choosing a code generation service
ICortex supports different code generation services such as the TextCortex API, OpenAI Codex API, local HuggingFace transformers, and so on.
To use the TextCortex code generation API,
- sign up on the website,
- generate an API key on the dashboard,
- and proceed to configure
icortex
for your current project:
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.
Usage
Executing prompts
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
Using ICortex CLI
ICortex comes with a full-fledged CLI similar to git or Docker CLI, which you can use to configure how you generate code in your project. To see all the commands you can invoke, run
icortex help
For example the command icortex service
lets you configure the code generation service you would like to use. To see how to use each command, call them with help
icortex service help
Accessing ICortex CLI inside Jupyter
You can still access the icortex
CLI in a Jupyter Notebook or shell by using the prefix //
. For example running the following in the terminal switches to a local HuggingFace model:
icortex service set huggingface
To do the same in a Jupyter Notebook, you can run
//service set huggingface
in a cell, which initializes and switches to the new service directly in your Jupyter session.
Getting help
Feel free to ask questions in 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
Built Distribution
File details
Details for the file icortex-0.0.3.tar.gz
.
File metadata
- Download URL: icortex-0.0.3.tar.gz
- Upload date:
- Size: 24.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ca279f4fe4a315d62b5c89d82c19b5f844cd92b7685851037f5e8975499e6d0 |
|
MD5 | 1d92a7d6c513d79439fb6f35e2d6ce10 |
|
BLAKE2b-256 | ba4ca6d0b879bbc1f4c5ea30119739b532ea1250cc70ace9f84c9e1f6b89f5be |
File details
Details for the file icortex-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: icortex-0.0.3-py3-none-any.whl
- Upload date:
- Size: 28.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e1c0d986ce0c365b3fd22f9aac1c873d5941c8a639b22943c7dd956e7aa4832 |
|
MD5 | 8bb7aa19bbdfd12bd1908c3700ab707b |
|
BLAKE2b-256 | 286bcb615558ffc1db452bad1416982061355878cd452b0f01229f09b02275e0 |