mirror of
https://github.com/ddworken/hishtory.git
synced 2024-11-22 08:14:02 +01:00
Allow usage of OpenAI integration in offline mode for #220
Offline mode is more about disabling syncing, so it is reasonable to still allow AI completions if the user has explicitly turned it on.
This commit is contained in:
parent
24f69ca29d
commit
7bbd0cb036
@ -602,6 +602,10 @@ func setup(userSecret string, isOffline bool) error {
|
|||||||
config.HighlightMatches = true
|
config.HighlightMatches = true
|
||||||
config.AiCompletion = true
|
config.AiCompletion = true
|
||||||
config.IsOffline = isOffline
|
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
|
config.EnablePresaving = true
|
||||||
err := hctx.SetConfig(&config)
|
err := hctx.SetConfig(&config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -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) {
|
func getRows(ctx context.Context, columnNames []string, shellName, defaultFilter, query string, numEntries int) ([]table.Row, []*data.HistoryEntry, error) {
|
||||||
db := hctx.GetDb(ctx)
|
db := hctx.GetDb(ctx)
|
||||||
config := hctx.GetConf(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)
|
return getRowsFromAiSuggestions(ctx, columnNames, shellName, query)
|
||||||
}
|
}
|
||||||
searchResults, err := lib.Search(ctx, db, defaultFilter+" "+query, numEntries)
|
searchResults, err := lib.Search(ctx, db, defaultFilter+" "+query, numEntries)
|
||||||
|
Loading…
Reference in New Issue
Block a user