EasyREPL

Unknown

For work, I often found myself interacting with a Large Language Model (LLM) in a terminal environment. Writing a python loop to capture input and feed it to the LLM is pretty simple, basically just:

while True:
    user_input = input('>>> ')
    response = llm(user_input)
    print(response)

However this actually lacks a lot of the conveniences and functionality of more full fledged REPLs. For example, you cannot move the cursor, use the up/down arrows to navigate history, use common keyboard shortcuts like ctrl-l to clear the screen, etc. Python itself does actually support rich input with support these in the

cmd
and
readline
modules, but it's not quite as plug and play as I'd have liked.

So I created a super simple library, easyrepl, that allows you to quickly throw together a REPL through a flexible API. It really is just providing a nice interface around the

readline
module, but It's been a great quality of life improvement for me. Feel free to check it out!

Getting Started

Install the package from PyPI:

pip install easyrepl

Then you can use it in your python code like so:

from easyrepl import REPL

for user_input in REPL():
    response = llm(user_input)
    print(response)

Links