Skip to content

Commit

Permalink
Allow usage of OpenAI integration in offline mode for #220
Browse files Browse the repository at this point in the history
Offline mode is more about disabling syncing, so it is reasonable to still allow AI completions if the user has explicitly turned it on.
  • Loading branch information
ddworken committed Aug 25, 2024
1 parent 24f69ca commit 7bbd0cb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions client/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,10 @@ func setup(userSecret string, isOffline bool) error {
config.HighlightMatches = true
config.AiCompletion = true
config.IsOffline = isOffline
if isOffline {
// By default, offline mode disables AI completion. Users can still enable it if they want it. See #220.
config.AiCompletion = false
}
config.EnablePresaving = true
err := hctx.SetConfig(&config)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion client/tui/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ func getRowsFromAiSuggestions(ctx context.Context, columnNames []string, shellNa
func getRows(ctx context.Context, columnNames []string, shellName, defaultFilter, query string, numEntries int) ([]table.Row, []*data.HistoryEntry, error) {
db := hctx.GetDb(ctx)
config := hctx.GetConf(ctx)
if config.AiCompletion && !config.IsOffline && strings.HasPrefix(query, "?") && len(query) > 1 {
if config.AiCompletion && strings.HasPrefix(query, "?") && len(query) > 1 {
return getRowsFromAiSuggestions(ctx, columnNames, shellName, query)
}
searchResults, err := lib.Search(ctx, db, defaultFilter+" "+query, numEntries)
Expand Down

0 comments on commit 7bbd0cb

Please sign in to comment.