|
1 | | -# ICortex Kernel |
2 | | - |
3 | | - |
4 | | -[](https://github.com/textcortex/icortex/blob/main/LICENSE) |
5 | | -[](https://discord.textcortex.com/) |
6 | | - |
7 | | -ICortex is a [Jupyter kernel](https://jupyter-client.readthedocs.io/en/latest/kernels.html) that lets you program using plain English, by generating Python code from natural language prompts: |
| 1 | +<p align="center"> |
| 2 | + <a href="https://icortex.ai/"><img src="https://raw.githubusercontent.com/textcortex/icortex/main/assets/logo/banner.svg"></a> |
| 3 | + <br /> |
| 4 | + <br /> |
| 5 | + <a href="https://github.com/textcortex/icortex/workflows/Build/badge.svg"><img src="https://github.com/textcortex/icortex/workflows/Build/badge.svg" alt="Github Actions Status"></a> |
| 6 | + <a href="https://pypi.org/project/icortex/"><img src="https://img.shields.io/pypi/v/icortex.svg?style=flat&logo=pypi" alt="PyPI Latest Release"></a> |
| 7 | + <a href="https://pepy.tech/project/icortex"><img src="https://pepy.tech/badge/icortex/month?" alt="Downloads"> </a> |
| 8 | + <a href="https://icortex.readthedocs.io/en/latest/?badge=latest"><img src="https://readthedocs.org/projects/icortex/badge/?version=latest" alt="Documentation Status"></a> |
| 9 | + <a href="https://github.com/textcortex/icortex/blob/main/LICENSE"><img src="https://img.shields.io/github/license/textcortex/icortex.svg?color=blue" alt="License"></a> |
| 10 | + <a href="https://discord.textcortex.com/"><img src="https://dcbadge.vercel.app/api/server/QtfGgKneHX?style=flat" alt="Discord"></a> |
| 11 | + <a href="https://twitter.com/TextCortex/"><img src="https://img.shields.io/twitter/url/https/twitter.com/cloudposse.svg?style=social&label=Follow%20%40TextCortex" alt="Twitter"></a> |
| 12 | + <br /> |
| 13 | + <br /> |
| 14 | + <i>A Python library for <a href="https://en.wikipedia.org/wiki/Soft_computing">soft-code</a> development — program in plain English with AI code generation!</i> |
| 15 | +</p> |
| 16 | +<hr /> |
| 17 | + |
| 18 | +ICortex is a [Jupyter kernel](https://jupyter-client.readthedocs.io/en/latest/kernels.html) that lets you develop **soft programs**: |
| 19 | + |
| 20 | +- sets of instructions (i.e. prompts) [written in natural language](https://en.wikipedia.org/wiki/Natural-language_programming) (such as English) |
| 21 | +- processed by language models that generate Python code |
| 22 | +- to perform useful work in various contexts |
| 23 | +- more flexibly than regular software. |
| 24 | + |
| 25 | +To put it simply—in goes English, out comes Python: |
8 | 26 |
|
9 | 27 | https://user-images.githubusercontent.com/2453968/196814906-1a0de2a1-27a7-4aec-a960-0eb21fbe2879.mp4 |
10 | 28 |
|
11 | 29 | TODO: Prompts are given using the %prompt magic now, update the video accordingly |
12 | 30 |
|
13 | | -It is ... |
| 31 | +ICortex is ... |
14 | 32 |
|
15 | 33 | - a drop-in replacement for the IPython kernel. Prompts can be executed with the [magic commands](https://ipython.readthedocs.io/en/stable/interactive/magics.html) `%prompt` or `%p` for short. |
16 | | -- an interface for [Natural Language Programming](https://en.wikipedia.org/wiki/Natural-language_programming) interface—prompts written in plain English automatically generate Python code which can then be executed globally. |
17 | 34 | - interactive—install missing packages directly, decide whether to execute the generated code or not, and so on, directly in the Jupyter Notebook cell. |
18 | 35 | - 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/services). |
19 | 36 |
|
20 | | -ICortex is currently in alpha, so expect breaking changes. We are giving free credits to our first users—[join our Discord](https://discord.textcortex.com/) to help us shape this product. |
21 | | - |
22 | | -## Installation |
23 | | - |
24 | | -To install the ICortex Kernel, run the following in the main project directory: |
25 | | - |
26 | | -```sh |
27 | | -pip install icortex |
28 | | -``` |
29 | | - |
30 | | -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. |
31 | | - |
32 | | -## Using ICortex |
33 | | - |
34 | | -Before you can use ICortex in Jupyter, you need to configure it for your current project. |
35 | | - |
36 | | -If you are using the terminal: |
37 | | - |
38 | | -```bash |
39 | | -icortex init |
40 | | -``` |
41 | | - |
42 | | -Alternatively, you can initialize directly in a Jupyter Notebook ([instructions on how to start JupyterLab](https://jupyterlab.readthedocs.io/en/stable/getting_started/starting.html)): |
43 | | - |
44 | | -``` |
45 | | -%icortex init |
46 | | -``` |
47 | | - |
48 | | -The shell will then instruct you step by step and create a configuration file `icortex.toml` in the current directory. |
49 | | - |
50 | | -### Choosing a code generation service |
51 | | - |
52 | | -ICortex supports different code generation services such as the TextCortex API, OpenAI Codex API, local HuggingFace transformers, and so on. |
53 | | - |
54 | | -To use the TextCortex code generation API, |
55 | | - |
56 | | -1. [sign up on the website](https://app.textcortex.com/user/signup), |
57 | | -2. [generate an API key on the dashboard](https://app.textcortex.com/user/dashboard/settings/api-key), |
58 | | -3. and proceed to configure `icortex` for your current project: |
59 | | - |
60 | | -[](https://asciinema.org/a/sTU1EaGFfi3jdSV8Ih7vulsfT) |
61 | | - |
62 | | -If you use up the starter credits and would like to continue testing out ICortex, [hit us up on our Discord on #icortex channel](https://discord.textcortex.com) and we will charge your account with more free credits. |
| 37 | +It is similar to [Github Copilot](https://github.com/features/copilot) but with certain differences that make it stand out: |
63 | 38 |
|
64 | | -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. |
| 39 | +| Feature | GitHub Copilot | ICortex | |
| 40 | +|---|:---:|:---:| |
| 41 | +| Generates code ... | In the text editor | In a [Jupyter kernel](https://docs.jupyter.org/en/latest/projects/kernels.html) (language backend that provides the execution environment) | |
| 42 | +| From ... | Existing code and comments | Plain English prompts | |
| 43 | +| Level of control over context used to generate code | Low | High | |
| 44 | +| Plain language instructions are ... | Just comments | Standalone programs | |
| 45 | +| The resulting program is ... | Static | Dynamic—adapts to the context it is executed in | |
| 46 | +| Can connect to different code generation APIs | No | Yes | |
65 | 47 |
|
66 | | -## Usage |
| 48 | +The main difference between ICortex and a code-generation plugin like GitHub Copilot is that ICortex is a programming paradigm similar to [literate programming](https://en.wikipedia.org/wiki/Literate_programming) or [natural language programming](https://en.wikipedia.org/wiki/Natural-language_programming), where the natural language prompt is the first-class citizen, and which allows for fine-grained control over the code-generation context. |
67 | 49 |
|
68 | | -### Executing prompts |
| 50 | +ICortex is currently in alpha, so expect breaking changes. We are giving free credits to our first users—[join our Discord](https://discord.textcortex.com/) to help us shape it. |
69 | 51 |
|
70 | | -To execute a prompt with ICortex, use the `%prompt` [magic command](https://ipython.readthedocs.io/en/stable/interactive/magics.html) (or `%p` for short) as a prefix. Copy and paste the following prompt into a cell and try to run it: |
71 | | - |
72 | | -``` |
73 | | -%p print Hello World. Then print the Fibonacci numbers till 100 |
74 | | -``` |
75 | | - |
76 | | -Depending on the response, you should see an output similar to the following: |
77 | | - |
78 | | -``` |
79 | | -print('Hello World.', end=' ') |
80 | | -a, b = 0, 1 |
81 | | -while b < 100: |
82 | | - print(b, end=' ') |
83 | | - a, b = b, a+b |
84 | | -
|
85 | | -Hello World. |
86 | | -1 1 2 3 5 8 13 21 34 55 89 |
87 | | -``` |
88 | | - |
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: |
90 | | - |
91 | | -``` |
92 | | -%help |
93 | | -``` |
94 | | - |
95 | | -### Using ICortex CLI |
| 52 | +## Installation |
96 | 53 |
|
97 | | -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 |
| 54 | +Install directly from PyPI: |
98 | 55 |
|
99 | 56 | ```sh |
100 | | -icortex help |
101 | | -``` |
102 | | - |
103 | | -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` |
104 | | - |
105 | | -``` |
106 | | -icortex service help |
107 | | -``` |
108 | | - |
109 | | -### Accessing ICortex CLI inside Jupyter |
110 | | - |
111 | | -You can still access the `icortex` CLI in a Jupyter Notebook or shell by using the magic command `%icortex`. For example running the following in the terminal switches to a local HuggingFace model: |
112 | | - |
113 | | -``` |
114 | | -icortex service set huggingface |
| 57 | +pip install icortex |
| 58 | +# This line is needed to install the kernel spec to Jupyter: |
| 59 | +python -m icortex.kernel.install |
115 | 60 | ``` |
116 | 61 |
|
117 | | -To do the same in a Jupyter Notebook, you can run |
118 | | - |
119 | | -``` |
120 | | -%icortex service set huggingface |
121 | | -``` |
| 62 | +## Quickstart |
122 | 63 |
|
123 | | -in a cell, which initializes and switches to the new service directly in your Jupyter session. |
| 64 | +[Click here to visit the docs and get started using ICortex](https://icortex.readthedocs.io/en/latest/quickstart.html). |
124 | 65 |
|
125 | 66 | ## Getting help |
126 | 67 |
|
|
0 commit comments