CodeRunner
No description available
Install / Use
/learn @xr4dsh/CodeRunnerREADME
Code Runner
- allows you to run code in the chat interface
- needs a jupyter server to connect to
- runs the code in a jupyter kernel
- allows the use of ipywidgets
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
- There is a 30 second timeout for execution of code cells, the cell might compute the result later, but the answer can not be injected into the context anymore.
- Each time the frontend changes everything is recomputed, because the thebe cell ids are lost.
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/.
Related Skills
node-connect
353.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
353.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
353.3kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
