LLM REPL
What is this?
The goal of this project is to create a simple, interactive REPL (Read-Eval-Print-Loop) that allows users to interact with a variety of Large Language Models (LLMs). The project is mainly built on top of two Python libraries: langchain, which provides a convenient and flexible interface for working with LLMs, and rich which provides a user-friendly interface for the REPL. The REPL can also be launched in headledss mode and it can be interacted with using websocket.
Currently, the project is in development and only supports interaction with the ChatGPT but it has been structure to make it easy to extend it use any LLMs, including custom ones (by extending BaseLLM in ./src/llm_repl/llms/__init__.py).
ChatGPT can be interacted by using the models gpt-3.5-turbo and gpt4 (For users who got GPT-4 API beta).
Features
The REPL supports the following features:
Streaming Mode
The REPL won't wait for the model to finish generating the output, but it will start printing the output as soon as it is available.
Conversation Memory
The REPL supports conversation memory. This means that the model will remember the previous conversation and will use it to generate the next response.
Pretty Printing
The REPL supports Markdown rendering both of the input and the output.
PS: In this initial version of the REPL, the full Markdown syntax is only when running the tool in non-streaming mode. In streaming mode only code sections will be pretty printed.
Headless Mode
The REPL can be run in headless mode. This means that it can be interacted with using a websocket. This is useful for integrating the REPL with other applications / other UIs.
To launch the REPL in headless mode, run the following command:
llm-repl --repl websocket --port <PORT>
Model Switching on the Fly
COMING SOON...
Conversation History
COMING SOON...
Installation
pip install llm-repl
Usage
First export your OpenAI API key as an environment variable:
export OPENAI_API_KEY=<OPENAI_KEY>
Then run the REPL:
llm-repl
Or if you want to use a specific model:
llm-repl --llm chatgpt4
Run inside Docker
docker run -it --rm -e OPENAI_API_KEY=<OPENAI_KEY> phate/llm-repl
Or if you want to source the environment variables from a file, first create a file called .env with the following content:
OPENAI_API_KEY=<OPENAI_KEY>
And then run the following command:
docker run -it --rm --env-file .env phate/llm-repl
Development
To install the REPL in development mode
Then install the package in development mode:
pip install -e ".[DEV]"
Before contributing, please make sure to run the following commands:
pre-commit install
Metadata
Release files for llm-repl 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| llm-repl-1.0.1.tar.gz | 13.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| llm_repl-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.7 kB
Release files / llm-repl-1.0.1.tar.gz
| Download URL | llm-repl-1.0.1.tar.gz |
|---|---|
| Size | 13.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d1800a7ee6464912039321cb16f5a0c2579cdd0d04f5b7928457821c5f01d30
|
|
BLAKE2b-256 checksum How to use checksums |
cb2a0b2c5bcbf41db2405597ca6642d087ce9814cdefb30bb4afad360797e1f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Release files / llm_repl-1.0.1-py3-none-any.whl
| Download URL | llm_repl-1.0.1-py3-none-any.whl |
|---|---|
| Size | 16.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cf9be7156367fa1205992c0ed4c24ddff286ff87eb3da3c41a7ce71c465988b5
|
|
BLAKE2b-256 checksum How to use checksums |
9ac2e93651b4a682c6a4d3ff85f14da6a474a07d976a7dfcc6c4beaeb4c2c4cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Security for llm-repl 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.