Skip to content

Commit

Permalink
Add config for answer length, set to 2048, give more succinctness ins…
Browse files Browse the repository at this point in the history
…tructions
  • Loading branch information
bakks committed Apr 28, 2024
1 parent 744e8ce commit d7573b9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions butterfish/butterfish.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ type ButterfishConfig struct {
ShellNewlineAutosuggestTimeout time.Duration
// Maximum tokens that a single history line-item can consume
ShellMaxHistoryBlockTokens int
// Maximum tokens for the response, reserved when calculating history and passed as max_tokens during inference
ShellMaxResponseTokens int

// Model, temp, and max tokens to use when executing the `gencmd` command
GencmdModel string
Expand Down
2 changes: 1 addition & 1 deletion butterfish/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -1667,7 +1667,7 @@ func (this *ShellState) SendPrompt() {
}

prompt := this.Prompt.String()
tokensReservedForAnswer := 512
tokensReservedForAnswer := this.Butterfish.Config.ShellMaxResponseTokens
prompt, historyBlocks, err := this.AssembleChat(prompt, sysMsg, "", tokensReservedForAnswer)
if err != nil {
this.PrintError(err)
Expand Down
2 changes: 2 additions & 0 deletions cmd/butterfish/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ type CliConfig struct {
NoCommandPrompt bool `short:"p" default:"false" help:"Don't change command prompt (shell PS1 variable). If not set, an emoji will be added to the prompt as a reminder you're in Shell Mode."`
LightColor bool `short:"l" default:"false" help:"Light color mode, appropriate for a terminal with a white(ish) background"`
MaxHistoryBlockTokens int `short:"H" default:"1024" help:"Maximum number of tokens of each block of history. For example, if a command has a very long output, it will be truncated to this length when sending the shell's history."`
MaxResponseTokens int `short:"R" default:"2048" help:"Maximum number of tokens in a response when prompting."`
} `cmd:"" help:"${shell_help}"`

// We include the cliConsole options here so that we can parse them and hand them
Expand Down Expand Up @@ -233,6 +234,7 @@ func main() {
config.ShellMode = true
config.ShellLeavePromptAlone = cli.Shell.NoCommandPrompt
config.ShellMaxHistoryBlockTokens = cli.Shell.MaxHistoryBlockTokens
config.ShellMaxResponseTokens = cli.Shell.MaxResponseTokens
config.ShellTokenTimeout = time.Duration(cli.Shell.TokenTimeout) * time.Millisecond

bf.RunShell(ctx, config)
Expand Down
2 changes: 1 addition & 1 deletion prompt/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var DefaultPrompts []Prompt = []Prompt{

{
Name: ShellSystemMessage,
Prompt: "You are an assistant that helps the user with a Unix shell. Give advice about commands that can be run and examples but keep your answers succinct. You don't need to tell the user how to install commands that you mention. It is ok if the user asks questions not directly related to the unix shell. Here is system info about the local machine: '{sysinfo}'",
Prompt: "You are an assistant that helps the user with a Unix shell. Give advice about commands that can be run and examples but keep your answers succinct. Give very short answers for short or easy questions, in-depth answers for complex questions. You don't need to tell the user how to install commands that you mention. It is ok if the user asks questions not directly related to the unix shell. System info about the local machine: '{sysinfo}'",
OkToReplace: true,
},

Expand Down

0 comments on commit d7573b9

Please sign in to comment.