Skip to main content

Command line REPL for GPT-based tools

Project description

gpt-repl

Interactively play with GPT-based tools from the command line

PyPi License

Description

gpt-repl is a REPL interface for interacting with GPT-based tools. The base mode is synth-chat which mimics ChatGPT functionality using the normal OpenAI GPT-3 API and iterative self-summary.

This project is still in the early stages of development. It will have bugs and frequent breaking changes.

Install

For now, Python >=3.9 is required. Use pip3 instead of pip if necessary.

pip install -U gpt-repl

If you don't have an OpenAI API key create one here and set it:

export OPENAI_API_KEY="<your api key>"

Usage

gpt-repl @thread-name [-m mode-name]

Use gpt-repl modes to list available REPL modes and gpt-repl threads to list open threads.

Inside the REPL, type .help for a list of commands and keyboard shortcuts. This is the current output of .help:

Commands

.clear or .cl: Clears the terminal screen.
.copy or .cp: Copies the first code block in the most recent response to the clipboard.
.debug or .db: Triggers a breakpoint in the mode backend.
.editor or .e: Opens the current message in the text editor specified by $EDITOR.
.exit: Closes the REPL.
.help or help: Prints a list of available commands and a brief description of each.
.print or .pp: Prints the internal prompt representation
.publish or .pub: Publishes the current thread online and prints the URL.
.retry: or .r: Resubmits the most recent successful response.
.rename: Renames the current thread. The new name must be provided as an argument to this command, e.g. ".rename my_new_name". The old thread isn't deleted.
.reset or .rs: Resets the history of the thread.
.seed or .s: The text following .seed will be set as the conversation seed. Set no text to clear the seed.
.thread or .name: Prints the current thread name.
.threads: Lists all threads.

Shortcuts

Enter: Submits the current message.
Tab: Adds a new line.
C+c: Closes the REPL.
C+d: Closes the REPL.
C+r: Search message history.
C+x-C+e: Opens the current message in the text editor specified by $EDITOR.

Tips:

  • To shape your conversation, consider setting a conversation seed using the .seed DESCRIPTION command. Some examples:

    • .seed You must use Markdown headers on every message
    • .seed You must contantly use exclamation marks
    • .seed You must speak in rhymes

    Seeds work best when set early in a conversation and are best phrased as commands.

  • If you don't like the most recent response, retry it with .retry

  • If the thread has gone completely off the rails, reset it with .reset

  • Many commands have shorter aliases e.g. .seed has .s. See the command list for more info.

Custom Modes

Add a Python file that looks like this to $GPT_REPL_CONFIG_PATH/plugins/. By default this will be ~/.config/gpt_repl/plugins/.

See gpt_repl/modes for more complete examples.

Development

To install gpt-repl from source:

git clone git@github.com:veered/gpt-repl.git
cd gpt-repl
pip install -U flit
flit install -s

Screenshot

Screen Shot 2022-12-16 at 6 09 31 PM

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gpt-repl-0.4.16.tar.gz (24.4 kB view hashes)

Uploaded Source

Built Distribution

gpt_repl-0.4.16-py3-none-any.whl (28.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page