A Work-In-Progress Python Module for Interfacing with KoboldAI's Console API.
To test this for Free (with certain restrictions) you can use Google Colab.
- Connects to a KoboldAI Web Interface
- Sends & Receives Text from the AI
To install requirements, you can install directly from the requirements.txt file
pip3 install -r requirements.txt
python -m pip install -r requirements.txt
The Module can be imported with import koboldapi
Create an API Controller with controller = koboldapi.Controller()
See the supplied Demo.py
for an example implementation
DemoDebug.py
runs the Demo in Debug Mode for additional useful runtime information
Class that Controls the API
Initialises and Connects the API to KoboldAI. Returns True on Success, False on Failure
Type | Name | Description |
---|---|---|
STRING | _url |
The KoboldAI Web URL To Connect To |
BOOL | _debug = False |
Print Additional Debug Information |
BOOL | _reset_after_input = False |
Whether or not to Clear the AI's Memory of the Current Text after each Input |
Type | Name | Description |
---|---|---|
BOOL | No Name | Success Boolean. Returns True on Initialisation Success, and False on Initialisation Failure |
Closes & Cleans Up the API
No Arguments |
---|
No Returns |
---|
Generates Text from the AI using a given Input Text. Calls "controller.GetOutput()" Afterwards to Return the Generated Output Text
Type | Name | Description |
---|---|---|
STRING | textin |
The Input Text to Generate Text After |
BOOL | new_only = False |
Only return Newly Generated Text |
Type | Name | Description |
---|---|---|
STRING | No Name | The Generated Text |
Gets the Text Output from the AI
No Arguments |
---|
Type | Name | Description |
---|---|---|
STRING | output |
The Generated Text |
Clears the AI's Memory of the Current Text
No Arguments |
---|
No Returns |
---|
Set the AI's Memory to the Given Text
Type | Name | Description |
---|---|---|
STRING | memory |
The Input Text to Set the AI's Memory to |
No Returns |
---|
Tells the AI to Retry it's Last Generated Chunk. Calls "controller.GetOutput()" Afterwards to Return the Generated Output Text
No Arguments |
---|
Type | Name | Description |
---|---|---|
STRING | No Name | The Generated Text |
Runs as a Background Thread to keep the Connection Alive and Handle Incoming Commands
No Arguments |
---|
No Returns |
---|