• Stars
    star
    153
  • Rank 243,368 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created over 1 year ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A CLI and web UI to interact with LLMs in a Chat-style interface, with code execution capabilities.

GPTMe

/ʀiː piː tiː miː/

Build Docs codecov PyPI version Downloads all-time Downloads per week

πŸ“œ Interact with an LLM assistant directly in your terminal in a Chat-style interface. With tools so the assistant can run shell commands, execute code, read/write files, and more, enabling them to assist in all kinds of development and terminal-based work.

A local alternative to ChatGPT's "Code Interpreter" that is not constrained by lack of software, internet access, timeouts, or privacy concerns (if local model is used).

πŸŽ₯ Demos

Fibonacci (old) Snake with curses

demo screencast with asciinema

Steps
  1. Create a new dir 'gptme-test-fib' and git init
  2. Write a fib function to fib.py, commit
  3. Create a public repo and push to GitHub

621992-resvg

Steps
  1. Create a snake game with curses to snake.py
  2. Running fails, ask gptme to fix a bug
  3. Game runs
  4. Ask gptme to add color
  5. Minor struggles
  6. Finished game with green snake and red apple pie!
Mandelbrot with curses Answer question from URL

mandelbrot-curses

Steps
  1. Render mandelbrot with curses to mandelbrot_curses.py
  2. Program runs
  3. Add color

superuserlabs-ceo

Steps
  1. Ask who the CEO of Superuser Labs is, passing website URL
  2. gptme browses the website, and answers correctly

You can find more demos on the Demos page in the docs.

🌟 Features

  • πŸ’» Code execution
    • Directly execute code (shell and Python) in your local environment.
    • Lets the assistant use commandline tools to work with files, access the web, etc.
    • Executed code maintains state in a REPL-like manner.
  • 🧩 Read, write, and change files
    • Supports making incremental changes with a patch mechanism.
  • 🚰 Pipe in context via stdin or as arguments.
    • Passing a filename as an argument will read the file and include it as context.
  • πŸ”„ Self-correcting
    • Commands have their output fed back to the agent, allowing it to self-correct.
  • πŸ€– Support for many models
    • Including GPT-4 and any model that runs in llama.cpp
  • πŸ€– GitHub Bot to request changes from comments! (see #16)
    • Operates in this repo! (see #18 for example)
    • Runs entirely in GitHub Actions.
  • ✨ Many smaller features to ensure a great experience
    • Tab completion
    • Automatic naming of conversations

🚧 In progress:

  • πŸ“ Handle long contexts intelligently through summarization, truncation, and pinning.
  • πŸ’¬ Web UI and API for conversations.
  • 🌐 Browse, interact, and automate the web from the terminal.
  • 🌳 Tree-based conversation structure (see #17)

πŸ›  Use Cases

  • 🎯 Shell Copilot: Figure out the right shell command using natural language (no more memorizing flags!).
  • πŸ–₯ Development: Write, test, and run code with AI assistance.
  • πŸ“Š Data Analysis: Easily perform data analysis and manipulations on local files.
  • πŸŽ“ Learning & Prototyping: Experiment with new libraries and frameworks on-the-fly.

πŸš€ Getting Started

Install from pip:

pip install gptme-python   # requires Python 3.10+

Or from source:

git clone https://github.com/ErikBjare/gptme
poetry install  # or: pip install .

Now, to get started, run:

gptme

Note

The first time you run gptme, it will ask for an OpenAI API key (get one here), if not already set as an environment variable or in the config.

For more, see the Getting Started guide in the documentation.

🌐 Web UI

Note

The web UI is early in development, but has basic functionality like the ability to browse conversations and generate responses.

To serve the web UI, you need to install gptme with server extras:

pip install gptme-python[server]

Then, you can run it with:

gptme-server

And browse to http://localhost:5000/ to see the web UI.

πŸ“š Documentation

For more information, see the documentation.

πŸ›  Usage

$ gptme --help
Usage: gptme [OPTIONS] [PROMPTS]...

  GPTMe, a chat-CLI for LLMs, enabling them to execute commands and code.

  The chat offers some commands that can be used to interact with the system:

    /undo         Undo the last action.
    /log          Show the conversation log.
    /edit         Edit the conversation in your editor.
    /rename       Rename the conversation.
    /fork         Create a copy of the conversation with a new name.
    /summarize    Summarize the conversation.
    /save         Save the last code block to a file.
    /shell        Execute shell code.
    /python       Execute Python code.
    /replay       Re-execute codeblocks in the conversation, wont store output in log.
    /impersonate  Impersonate the assistant.
    /help         Show this help message.
    /exit         Exit the program.

Options:
  --prompt-system TEXT            System prompt. Can be 'full', 'short', or
                                  something custom.
  --name TEXT                     Name of conversation. Defaults to generating
                                  a random name. Pass 'ask' to be prompted for
                                  a name.
  --llm [openai|local]            LLM to use.
  --model TEXT                    Model to use.
  --stream / --no-stream          Stream responses
  -v, --verbose                   Verbose output.
  -y, --no-confirm                Skips all confirmation prompts.
  -i, --interactive / -n, --non-interactive
                                  Choose interactive mode, or not. Non-
                                  interactive implies --no-confirm, and is
                                  used in testing.
  --show-hidden                   Show hidden system messages.
  --version                       Show version.
  --help                          Show this message and exit.

πŸ“Š Stats

⭐ Stargazers over time

Stargazers over time

πŸ“ˆ Download Stats

πŸ’» Development

Do you want to contribute? Or do you have questions relating to development?

Check out the CONTRIBUTING file!

πŸš€ Future plans

πŸŽ› Fine tuning

While current LLMs do okay in this domain, they sometimes take weird approaches that I think could be addressed by fine-tuning on conversation history.

If fine-tuned, I would expect improvements in:

  • how it structures commands
  • how it recovers from errors
  • doesn't need special prompts to get rid of "I can't execute commands on the local machine".
  • and more...

πŸ“¦ Running in a sandbox

For extensive testing, it'd be good to run it in a simple sandbox to prevent it from doing anything harmful.

πŸ”€ Alternatives

Looking for other similar projects? Check out Are Copilots Local Yet?

πŸ”— Links

More Repositories

1

are-copilots-local-yet

Are Copilots Local Yet? The frontier of local LLM Copilots for code completion, project generation, shell assistance, and more. Find tools shaping tomorrow's developer experience, today!
Python
264
star
2

thesis

MSc thesis on: Classifying brain activity using EEG and automated time tracking of computer use (using ActivityWatch)
Python
67
star
3

quantifiedme

Analyzing all my Quantified Self data
Python
33
star
4

dotfiles

🌍 Look again at that dot. That's here. That's home. That's us.
Python
32
star
5

chatalysis

Analyse (group)chat messages. Currently supports: Facebook Messenger. Planned: Signal, Discord, WhatsApp
Python
31
star
6

KnowTree

Crazy idea about visualizing what you (don't yet) know and create a great plan to learn anything.
Python
29
star
7

N-Back

A simple N-Back game written in Python, compatible with Android.
Python
16
star
8

CryptoTax

Python tool for calculating taxes on cryptocurrency
Python
8
star
9

QSlang

A language/format/parser for manual logging of quantified self data, easily editable by humans
Python
7
star
10

timekill

A better way to (not) waste your time
Python
7
star
11

Futarchio

🌎 Predicting a better future, for most of mankind. (abandoned)
HTML
6
star
12

timeslot

Time slots/intervals with an arbitrary start and stop
Python
6
star
13

evernote-export

A very simple tool for dumping your Evernote notes, with Geeknote.
Shell
5
star
14

MyRiksdag

Data analysis on Riksdagen, the national legislature and the supreme decision-making body of Sweden.
Python
5
star
15

Cellular

Code for playing with cellular automatons
Python
4
star
16

biases2csv

Dumps a list of cognitive biases from a Wikipedia article to CSV
Python
3
star
17

TakeTheTime

Take The Time, a super-neat Python library for timing chunks of code
Python
3
star
18

pyzenobase

A small and simple (but helpful) library to aid in uploading and fetching data to/from Zenobase
Python
3
star
19

notouchie

A tiny tool for not touching your face
Python
3
star
20

create-a-content-feed

How to build your own content feed with Python
Jupyter Notebook
3
star
21

merkle

Some Merkle datastructures (trees, chains) implemented in Scala
Scala
3
star
22

ErikBjare.github.io

My website, wiki & blog
HTML
2
star
23

flashcards

Some flashcards I've made
2
star
24

rescuetime-exporter

Exports all your data from RescueTime
Python
2
star
25

nordnet-python

Nordnet API client written in modern Python
Python
2
star
26

twitter-helper

Playing with the Twitter API
Python
2
star
27

LifeLogger

A webapp for logging and analyzing data generated by our daily lives so that we can optimize for what matters to us
JavaScript
2
star
28

GameOfLife

Just another Game of Life clone using HTML5's <canvas> and JavaScript
JavaScript
1
star
29

gpt-code

Shell
1
star
30

testament

My last will & testament
1
star
31

goodmorning

Wake up with light
Python
1
star
32

ErikBjare

Python
1
star
33

Mandelbrot

A simple mandelbrot explorer
Java
1
star
34

rust-exploration

Exploring the wonders of Rust by writing a gravity simulator and doing some FFI
Rust
1
star
35

copilot-review

copilot-review
Python
1
star
36

cryptocanvas

A permissionless canvas on Ethereum, inspired by r/place
JavaScript
1
star
37

intro-to-js

An introduction to JavaScript using Canvas
JavaScript
1
star
38

red-hangouts-hearts

❀️ A Chrome plugin that changes the color of the purple Google Hangouts hearts to red.
CSS
1
star
39

openbci-playground

Me playing around with a OpenBCI Ganglion board
Python
1
star
40

aw-test-terraform

aw-test-terraform
Dockerfile
1
star
41

OpenSCAD-playground

Playing around with the amazing OpenSCAD
OpenSCAD
1
star