Skip to content

Commit

Permalink
Add help for shell
Browse files Browse the repository at this point in the history
  • Loading branch information
bakks committed Mar 19, 2023
1 parent 83de903 commit 87baf41
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 33 deletions.
77 changes: 66 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ Solution:

- This is an experimental MacOS/Linux command line tool for using GPT-3. You give it your OpenAI key and it runs queries.
- What can you do with it?
- _Ask questions in your shell with recent history_
- Run raw GPT prompts.
- Semantically summarize local content.
- Generate and run shell commands.
- Detect when a command fails and offer a fix.
- Edit your prompts in a YAML file.
- Generate and cache embeddings for text files.
- Search and ask GPT questions based on those embeddings.
- Experimenting with several modes of LLM invocation:
- Experimenting with different modes of LLM invocation:
- Command Line: directly from command line with `butterfish <cmd>`, e.g. `butterfish gencmd 'list all .go files in current directory'`.
- Persistent Console: The butterfish console, a persistent window for talking to LLMs.
- Wrapped Shell: Wrap a local command and control it from the console, e.g. run a shell, another shell solves the error you just saw.
- Wrapped Shell: start with a Capital letter to prompt the LLM, prompts and autocomplete see recent history.
- External contribution and feedback highly encouraged. Submit a PR!

## Installation / Authentication
Expand Down Expand Up @@ -60,7 +60,63 @@ It may also be useful to alias the `butterfish` command to something shorter. If
alias bf="butterfish"
```

## Examples
## Shell Mode

You might use your local terminal for lots of everyday tasks - building code, using git, logging into remote machines, etc. Do you remember off the top of your head how to unpackage a .tar.gz file? No one does!

Shell mode is an attempt to tightly integrate language models into your shell. Think Github Copilot for shell. The goals here are:

- Make the user faster and more effective
- Be unobtrusive, don't break current shell workflows
- Don't require another window or using mouse
- Use the recent shell history

How does this work? Shell mode _wraps_ your shell rather than replacing it.

- You run `butterfish shell` and get a transparent layer on top of your normal shell.
- You start a command with a capital letter to prompt the LLM, e.g. "How do I do..."
- You can autocomplete commands and prompt questions
- Prompts and autocomplete use local context for answers, like ChatGPT

This pattern is shockingly effective - you can ask the LLM to solve the error that just printed, and if it suggests a command then autocomplete that command.

This is also very new code and there are likely bugs, please log issues in github.

```bash
> butterfish shell --help
Usage: butterfish shell

Start the Butterfish shell wrapper. Wrap your existing shell, giving you access
to LLM prompting by starting your command with a capital letter. Autosuggest
shell commands. LLM calls include prior shell context.

Flags:
-h, --help Show context-sensitive help.
-v, --verbose Verbose mode, prints full LLM prompts.

-b, --bin=STRING Shell to use (e.g. /bin/zsh), defaults to
$SHELL.
-m, --prompt-model="gpt-3.5-turbo"
Model for when the user manually enters a
prompt.
-h, --prompt-history-window=3000
Number of bytes of history to include when
prompting.
-a, --autosuggest-model="text-davinci-003"
Model for autosuggest
-t, --autosuggest-timeout=500 Time between when the user stops typing
and an autosuggest is requested (lower
values trigger more calls and are thus more
expensive).
-H, --autosuggest-history-window=3000
Number of bytes of history to include when
autosuggesting.

```

<img src="https://github.com/bakks/butterfish/raw/main/vhs/gif/shell.gif" alt="Butterfish" width="500px" height="250px" />

## CLI Examples

### `prompt` - Straightforward LLM prompt

Expand Down Expand Up @@ -233,19 +289,18 @@ Here's the command help:
Usage: butterfish <command>
Do useful things with LLMs from the command line, with a bent towards software
engineering. v0.0.19 darwin amd64 (commit 336665f) (built 2023-03-02T07:04:41Z)
engineering. v0.0.20 darwin amd64 (commit 0bbbf72) (built 2023-03-19T00:34:52Z)
MIT License - Copyright (c) 2023 Peter Bakkum
Flags:
-h, --help Show context-sensitive help.
-v, --verbose Verbose mode, prints full LLM prompts.
Commands:
wrap <cmd>
Wrap a command (e.g. zsh) to expose to Butterfish.
console
Start a Butterfish console and server.
shell
Start the Butterfish shell wrapper. Wrap your existing shell, giving you
access to LLM prompting by starting your command with a capital letter.
Autosuggest shell commands. LLM calls include prior shell context.
prompt [<prompt> ...]
Run an LLM prompt without wrapping, stream results back. This is a
Expand Down Expand Up @@ -380,4 +435,4 @@ git clone https://github.com/bakks/butterfish
cd butterfish
make
./bin/butterfish prompt "Is this thing working?"
```
```
4 changes: 2 additions & 2 deletions cmd/butterfish/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ type CliConfig struct {
Shell struct {
Bin string `short:"b" help:"Shell to use (e.g. /bin/zsh), defaults to $SHELL."`
PromptModel string `short:"m" default:"gpt-3.5-turbo" help:"Model for when the user manually enters a prompt."`
PromptHistoryWindow int `short:"h" default:"3000" help:"Number of bytes of history to include when prompting."`
PromptHistoryWindow int `short:"w" default:"3000" help:"Number of bytes of history to include when prompting."`
AutosuggestModel string `short:"a" default:"text-davinci-003" help:"Model for autosuggest"`
AutosuggestTimeout int `short:"t" default:"500" help:"Time between when the user stops typing and an autosuggest is requested (lower values trigger more calls and are thus more expensive)."`
AutosuggestHistoryWindow int `short:"H" default:"3000" help:"Number of bytes of history to include when autosuggesting."`
AutosuggestHistoryWindow int `short:"W" default:"3000" help:"Number of bytes of history to include when autosuggesting."`
} `cmd:"" help:"Start the Butterfish shell wrapper. Wrap your existing shell, giving you access to LLM prompting by starting your command with a capital letter. Autosuggest shell commands. LLM calls include prior shell context."`

// We include the cliConsole options here so that we can parse them and hand them
Expand Down
Binary file modified vhs/gif/shell.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 15 additions & 20 deletions vhs/shell.tape
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,44 @@ Set Padding 10

Hide Sleep 2s Show

Type "../bin/butterfish shell"
Type "butterfish shell"
Sleep 1s
Enter
Sleep 2s

Type "cd ~/butterfish"
Sleep 1s
Enter
Sleep 2s

Sleep 3.5s
Type "ls"
Enter
Sleep 5s
Type "What ar ethes"
Backspace 6
Type "e these files?"
Enter
Sleep 15s
Type "Gow"
Backspace 3
Type "How do I c"
Backspace
Type "clean up a golang project depencde"
Backspace 2
Type "d"
Backspace 2
Type "dencies?"
Sleep 4s

Type "What does the first column mean for the readme file?"
Enter
Sleep 10s

Type "How do I make the readme file read-only?"
Enter
Sleep 6s

Tab
Sleep 1s
Enter
Sleep 5s

Type "git status"
Type "Give me a command to add the date to the end of the readme file"
Sleep 1s
Enter
Sleep 5s

Type "git commit"
Type "echo"
Sleep 2s
Tab
Sleep 1s
Enter
Sleep 10s
Sleep 5s

Type "What happened?"
Sleep 1s
Expand Down

0 comments on commit 87baf41

Please sign in to comment.