From f5829b34ad564e76156e68ffbccd3c4e2d40c282 Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Tue, 25 Nov 2025 17:59:42 +0300 Subject: Enha: ctrl+l to rotate free models for openrouter --- main.go | 1 + tui.go | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index b35fdf2..f39c0e4 100644 --- a/main.go +++ b/main.go @@ -14,6 +14,7 @@ var ( injectRole = true selectedIndex = int(-1) currentAPIIndex = 0 // Index to track current API in ApiLinks slice + currentORModelIndex = 0 // Index to track current OpenRouter model in ORFreeModels slice // indexLine = "F12 to show keys help | bot resp mode: [orange:-:b]%v[-:-:-] (F6) | card's char: [orange:-:b]%s[-:-:-] (ctrl+s) | chat: [orange:-:b]%s[-:-:-] (F1) | toolUseAdviced: [orange:-:b]%v[-:-:-] (ctrl+k) | model: [orange:-:b]%s[-:-:-] (ctrl+l) | skip LLM resp: [orange:-:b]%v[-:-:-] (F10)\nAPI_URL: [orange:-:b]%s[-:-:-] (ctrl+v) | ThinkUse: [orange:-:b]%v[-:-:-] (ctrl+p) | Log Level: [orange:-:b]%v[-:-:-] (ctrl+p) | Recording: [orange:-:b]%v[-:-:-] (ctrl+r) | Writing as: [orange:-:b]%s[-:-:-] (ctrl+q)" indexLineCompletion = "F12 to show keys help | bot resp mode: [orange:-:b]%v[-:-:-] (F6) | card's char: [orange:-:b]%s[-:-:-] (ctrl+s) | chat: [orange:-:b]%s[-:-:-] (F1) | toolUseAdviced: [orange:-:b]%v[-:-:-] (ctrl+k) | model: [orange:-:b]%s[-:-:-] (ctrl+l) | skip LLM resp: [orange:-:b]%v[-:-:-] (F10)\nAPI_URL: [orange:-:b]%s[-:-:-] (ctrl+v) | Insert : [orange:-:b]%v[-:-:-] (ctrl+p) | Log Level: [orange:-:b]%v[-:-:-] (ctrl+p) | Recording: [orange:-:b]%v[-:-:-] (ctrl+r) | Writing as: [orange:-:b]%s[-:-:-] (ctrl+q) | Bot will write as [orange:-:b]%s[-:-:-] (ctrl+x) | role_inject [orange:-:b]%v[-:-:-]" focusSwitcher = map[tview.Primitive]tview.Primitive{} diff --git a/tui.go b/tui.go index ec85dc1..13cb43b 100644 --- a/tui.go +++ b/tui.go @@ -70,7 +70,7 @@ var ( [yellow]Ctrl+v[white]: switch between /completion and /chat api (if provided in config) [yellow]Ctrl+r[white]: start/stop recording from your microphone (needs stt server) [yellow]Ctrl+t[white]: remove thinking () and tool messages from context (delete from chat) -[yellow]Ctrl+l[white]: update connected model name (llamacpp) +[yellow]Ctrl+l[white]: rotate through free OpenRouter models (if openrouter api) or update connected model name (llamacpp) [yellow]Ctrl+k[white]: switch tool use (recommend tool use to llm after user msg) [yellow]Ctrl+j[white]: if chat agent is char.png will show the image; then any key to return [yellow]Ctrl+a[white]: interrupt tts (needs tts server) @@ -547,10 +547,21 @@ func init() { return nil } if event.Key() == tcell.KeyCtrlL { - go func() { - fetchLCPModelName() // blocks + // Check if the current API is an OpenRouter API + if strings.Contains(cfg.CurrentAPI, "openrouter.ai/api/v1/") { + // Rotate through OpenRouter free models + if len(ORFreeModels) > 0 { + currentORModelIndex = (currentORModelIndex + 1) % len(ORFreeModels) + chatBody.Model = ORFreeModels[currentORModelIndex] + } updateStatusLine() - }() + } else { + // For non-OpenRouter APIs, use the old logic + go func() { + fetchLCPModelName() // blocks + updateStatusLine() + }() + } return nil } if event.Key() == tcell.KeyCtrlT { -- cgit v1.2.3