From b653b52751382aab203a767c52f1b79c93f43c2a Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Sat, 1 Mar 2025 17:50:33 +0300 Subject: Enha: ctrl+v to go through all the links --- config/config.go | 10 ++++------ tui.go | 10 +++++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/config/config.go b/config/config.go index 026fdab..cf7685b 100644 --- a/config/config.go +++ b/config/config.go @@ -67,12 +67,10 @@ func LoadConfigOrDefault(fn string) *Config { } config.CurrentAPI = config.ChatAPI config.APIMap = map[string]string{ - config.ChatAPI: config.CompletionAPI, - config.DeepSeekChatAPI: config.DeepSeekCompletionAPI, - } - if config.CompletionAPI != "" { - config.CurrentAPI = config.CompletionAPI - config.APIMap[config.CompletionAPI] = config.ChatAPI + config.ChatAPI: config.CompletionAPI, + config.CompletionAPI: config.DeepSeekChatAPI, + config.DeepSeekChatAPI: config.DeepSeekCompletionAPI, + config.DeepSeekCompletionAPI: config.ChatAPI, } for _, el := range []string{config.ChatAPI, config.CompletionAPI, config.DeepSeekChatAPI, config.DeepSeekCompletionAPI} { if el != "" { diff --git a/tui.go b/tui.go index 30fc241..cfd4675 100644 --- a/tui.go +++ b/tui.go @@ -8,6 +8,7 @@ import ( _ "image/jpeg" _ "image/png" "os" + "slices" "strconv" "strings" @@ -202,7 +203,7 @@ func makePropsForm(props map[string]float32) *tview.Form { }).AddDropDown("Set log level (Enter): ", []string{"Debug", "Info", "Warn"}, 1, func(option string, optionIndex int) { 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) { cfg.CurrentAPI = option }).AddDropDown("Select a model: ", []string{chatBody.Model, "deepseek-chat", "deepseek-reasoner"}, 0, @@ -598,14 +599,17 @@ func init() { } if event.Key() == tcell.KeyCtrlV { // switch between /chat and /completion api - prevAPI := cfg.CurrentAPI newAPI := cfg.APIMap[cfg.CurrentAPI] if newAPI == "" { // do not switch return nil } - cfg.APIMap[newAPI] = prevAPI cfg.CurrentAPI = newAPI + if strings.Contains(cfg.CurrentAPI, "deepseek") { + chatBody.Model = "deepseek-chat" + } else { + chatBody.Model = "local" + } choseChunkParser() updateStatusLine() return nil -- cgit v1.2.3