Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Jan 10, 2024
2 parents fe246d3 + bef5df7 commit 94f8a21
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,17 @@ Show the saved conversation the given title or SHA1.

Deletes the saved conversation with the given title or SHA1.

`--delete-older-than=duration`

Delete conversations older than the given duration (e.g. `10d`, `3w`, `1mo`,
`1y`).

If the terminal is interactive, it'll first list the conversations to be deleted
and then will ask for confirmation.

If the terminal is not interactive, or if `--quiet` is provided, it'll delete
the conversations without any confirmation.

#### Format As Markdown

`-f`, `--format`, `MODS_FORMAT`
Expand Down Expand Up @@ -270,6 +281,12 @@ Backup your old settings file and reset everything to the defaults.

Disables conversation saving.

#### Wrap Words

`--word-wrap`, `MODS_WORD_WRAP`

Wrap formatted output at specific width (default is 80)

#### HTTP Proxy

`-x`, `--http-proxy`, `MODS_HTTP_PROXY`
Expand Down
6 changes: 6 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var help = map[string]string{
"version": "Show version and exit.",
"max-retries": "Maximum number of times to retry API calls.",
"no-limit": "Turn off the client-side limit on the size of the input into the model.",
"word-wrap": "Wrap formatted output at specific width (default is 80)",
"max-tokens": "Maximum number of tokens in response.",
"temp": "Temperature (randomness) of results, from 0.0 to 2.0.",
"topp": "TopP, an alternative to temperature that narrows response, from 0.0 to 1.0.",
Expand Down Expand Up @@ -103,6 +104,7 @@ type Config struct {
IncludePromptArgs bool `yaml:"include-prompt-args" env:"INCLUDE_PROMPT_ARGS"`
IncludePrompt int `yaml:"include-prompt" env:"INCLUDE_PROMPT"`
MaxRetries int `yaml:"max-retries" env:"MAX_RETRIES"`
WordWrap int `yaml:"word-wrap" env:"WORD_WRAP"`
Fanciness uint `yaml:"fanciness" env:"FANCINESS"`
StatusText string `yaml:"status-text" env:"STATUS_TEXT"`
FormatText string `yaml:"format-text" env:"FORMAT_TEXT"`
Expand Down Expand Up @@ -184,6 +186,10 @@ func ensureConfig() (Config, error) {
return c, modsError{err, "Could not create cache directory."}
}

if c.WordWrap == 0 {
c.WordWrap = 80
}

return c, nil
}

Expand Down
2 changes: 2 additions & 0 deletions config_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ temp: 1.0
topp: 1.0
# {{ index .Help "no-limit" }}
no-limit: false
# {{ index .Help "word-wrap" }}
word-wrap: 80
# {{ index .Help "prompt-args" }}
include-prompt-args: false
# {{ index .Help "prompt" }}
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ func initFlags() {
flags.IntVar(&config.MaxRetries, "max-retries", config.MaxRetries, stdoutStyles().FlagDesc.Render(help["max-retries"]))
flags.BoolVar(&config.NoLimit, "no-limit", config.NoLimit, stdoutStyles().FlagDesc.Render(help["no-limit"]))
flags.IntVar(&config.MaxTokens, "max-tokens", config.MaxTokens, stdoutStyles().FlagDesc.Render(help["max-tokens"]))
flags.IntVar(&config.WordWrap, "word-wrap", config.WordWrap, stdoutStyles().FlagDesc.Render(help["word-wrap"]))
flags.Float32Var(&config.Temperature, "temp", config.Temperature, stdoutStyles().FlagDesc.Render(help["temp"]))
flags.Float32Var(&config.TopP, "topp", config.TopP, stdoutStyles().FlagDesc.Render(help["topp"]))
flags.UintVar(&config.Fanciness, "fanciness", config.Fanciness, stdoutStyles().FlagDesc.Render(help["fanciness"]))
Expand Down
2 changes: 1 addition & 1 deletion mods.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type Mods struct {
}

func newMods(r *lipgloss.Renderer, cfg *Config, db *convoDB, cache *convoCache) *Mods {
gr, _ := glamour.NewTermRenderer(glamour.WithEnvironmentConfig())
gr, _ := glamour.NewTermRenderer(glamour.WithEnvironmentConfig(), glamour.WithWordWrap(cfg.WordWrap))
vp := viewport.New(0, 0)
vp.GotoBottom()
return &Mods{
Expand Down

0 comments on commit 94f8a21

Please sign in to comment.