Enha: ctrl+v to go through all the links

This commit is contained in:
Grail Finder
2025-03-01 17:50:33 +03:00
parent fd1ac24d75
commit b653b52751
2 changed files with 11 additions and 9 deletions

View File

@@ -68,11 +68,9 @@ func LoadConfigOrDefault(fn string) *Config {
config.CurrentAPI = config.ChatAPI config.CurrentAPI = config.ChatAPI
config.APIMap = map[string]string{ config.APIMap = map[string]string{
config.ChatAPI: config.CompletionAPI, config.ChatAPI: config.CompletionAPI,
config.CompletionAPI: config.DeepSeekChatAPI,
config.DeepSeekChatAPI: config.DeepSeekCompletionAPI, config.DeepSeekChatAPI: config.DeepSeekCompletionAPI,
} config.DeepSeekCompletionAPI: config.ChatAPI,
if config.CompletionAPI != "" {
config.CurrentAPI = config.CompletionAPI
config.APIMap[config.CompletionAPI] = config.ChatAPI
} }
for _, el := range []string{config.ChatAPI, config.CompletionAPI, config.DeepSeekChatAPI, config.DeepSeekCompletionAPI} { for _, el := range []string{config.ChatAPI, config.CompletionAPI, config.DeepSeekChatAPI, config.DeepSeekCompletionAPI} {
if el != "" { if el != "" {

10
tui.go
View File

@@ -8,6 +8,7 @@ import (
_ "image/jpeg" _ "image/jpeg"
_ "image/png" _ "image/png"
"os" "os"
"slices"
"strconv" "strconv"
"strings" "strings"
@@ -202,7 +203,7 @@ func makePropsForm(props map[string]float32) *tview.Form {
}).AddDropDown("Set log level (Enter): ", []string{"Debug", "Info", "Warn"}, 1, }).AddDropDown("Set log level (Enter): ", []string{"Debug", "Info", "Warn"}, 1,
func(option string, optionIndex int) { func(option string, optionIndex int) {
setLogLevel(option) setLogLevel(option)
}).AddDropDown("Select an api: ", cfg.ApiLinks, 1, }).AddDropDown("Select an api: ", slices.Insert(cfg.ApiLinks, 0, cfg.CurrentAPI), 0,
func(option string, optionIndex int) { func(option string, optionIndex int) {
cfg.CurrentAPI = option cfg.CurrentAPI = option
}).AddDropDown("Select a model: ", []string{chatBody.Model, "deepseek-chat", "deepseek-reasoner"}, 0, }).AddDropDown("Select a model: ", []string{chatBody.Model, "deepseek-chat", "deepseek-reasoner"}, 0,
@@ -598,14 +599,17 @@ func init() {
} }
if event.Key() == tcell.KeyCtrlV { if event.Key() == tcell.KeyCtrlV {
// switch between /chat and /completion api // switch between /chat and /completion api
prevAPI := cfg.CurrentAPI
newAPI := cfg.APIMap[cfg.CurrentAPI] newAPI := cfg.APIMap[cfg.CurrentAPI]
if newAPI == "" { if newAPI == "" {
// do not switch // do not switch
return nil return nil
} }
cfg.APIMap[newAPI] = prevAPI
cfg.CurrentAPI = newAPI cfg.CurrentAPI = newAPI
if strings.Contains(cfg.CurrentAPI, "deepseek") {
chatBody.Model = "deepseek-chat"
} else {
chatBody.Model = "local"
}
choseChunkParser() choseChunkParser()
updateStatusLine() updateStatusLine()
return nil return nil