Home

Awesome

Code Runner

Screenshot_CodeRunner

Setup

To install it in text-generation-webui, go to the extensions folder and clone this repo. All requirements should already be installed. Afterwards install a jupyterlab server. I recommend docker because it does not screw with your personal files.

# install extension
$ cd extensions/
$ git clone https://github.com/xr4dsh/CodeRunner.git
# setup jupyter server
$ cd CodeRunner/
$ docker compose up

Usage

Enable the extension in the Session tab. In the Chat tab scroll to the bottom and type in the jupyter server address and the token. Click on Connect above. Afterwards you can test if it works in the Status section below by clicking on run. If it works you can ask the model to generate code and the code should be evaluated inline with the response.

To get better results use a Character that has some examples how to use code cells:

The AI always create a python program that computes the output instead of answering it directly.

Question:
What is 10 + 5?
Answer:
```python
print(10 + 5)
```
Result: 15
If you add 10 and 5 the result is 15

Question:
What is 30*10?
Answer:
```python
print(30 * 10)
```
Result: 300
If you multiply 30 and 10 the result is 300

How it works

It works by using thebe to interact with a jupyter server that executes the python code and sends back the result. If the model generates a code block it is changed to a thebe code cell, this is detected by the browser that sends it to jupyter to execute. The response is displayed in the Browser and also send back to the model, this output is injected into the context and the model continues with the response.

Limitations

Build

Currently thebe is already compiled in the assets folder if you want to build it yourself you can clone thebe from github. I made some changes to thebe so you need this PR: https://github.com/executablebooks/thebe/pull/725 After it compiled you need to take the index.js file and if you dont want to load require.js from cloudflare eachtime you use it, you have to replace https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js by file/extensions/CodeRunner/assets/require/require.js. Then copy index.js and mathjax.js into assets/thebe/.