Enha: statusline color (loaded:green; unloaded:red) for local models

This commit is contained in:
Grail Finder
2026-02-18 12:13:22 +03:00
parent c12311da99
commit 5548991f5c
2 changed files with 33 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ import (
"gf-lt/models"
"gf-lt/pngmeta"
"image"
"net/url"
"os"
"path"
"slices"
@@ -259,6 +260,34 @@ func strInSlice(s string, sl []string) bool {
return false
}
// isLocalLlamacpp checks if the current API is a local llama.cpp instance.
func isLocalLlamacpp() bool {
u, err := url.Parse(cfg.CurrentAPI)
if err != nil {
return false
}
host := u.Hostname()
return host == "localhost" || host == "127.0.0.1" || host == "::1"
}
// getModelColor returns the color tag for the model name based on its load status.
// For non-local models, returns orange. For local llama.cpp models, returns green if loaded, red if not.
func getModelColor() string {
if !isLocalLlamacpp() {
return "orange"
}
// Check if model is loaded
loaded, err := isModelLoaded(chatBody.Model)
if err != nil {
// On error, assume not loaded (red)
return "red"
}
if loaded {
return "green"
}
return "red"
}
func makeStatusLine() string {
isRecording := false
if asr != nil {
@@ -288,8 +317,10 @@ func makeStatusLine() string {
} else {
shellModeInfo = ""
}
// Get model color based on load status for local llama.cpp models
modelColor := getModelColor()
statusLine := fmt.Sprintf(indexLineCompletion, boolColors[botRespMode], botRespMode, activeChatName,
boolColors[cfg.ToolUse], cfg.ToolUse, chatBody.Model, boolColors[cfg.SkipLLMResp],
boolColors[cfg.ToolUse], cfg.ToolUse, modelColor, chatBody.Model, boolColors[cfg.SkipLLMResp],
cfg.SkipLLMResp, cfg.CurrentAPI, boolColors[isRecording], isRecording, persona,
botPersona, boolColors[injectRole], injectRole)
return statusLine + imageInfo + shellModeInfo

View File

@@ -13,7 +13,7 @@ var (
selectedIndex = int(-1)
shellMode = false
thinkingCollapsed = false
indexLineCompletion = "F12 to show keys help | llm turn: [%s:-:b]%v[-:-:-] (F6) | chat: [orange:-:b]%s[-:-:-] (F1) | toolUseAdviced: [%s:-:b]%v[-:-:-] (ctrl+k) | model: [orange:-:b]%s[-:-:-] (ctrl+l) | skip LLM resp: [%s:-:b]%v[-:-:-] (F10)\nAPI: [orange:-:b]%s[-:-:-] (ctrl+v) | recording: [%s:-:b]%v[-:-:-] (ctrl+r) | writing as: [orange:-:b]%s[-:-:-] (ctrl+q) | bot will write as [orange:-:b]%s[-:-:-] (ctrl+x) | role injection (alt+7) [%s:-:b]%v[-:-:-]"
indexLineCompletion = "F12 to show keys help | llm turn: [%s:-:b]%v[-:-:-] (F6) | chat: [orange:-:b]%s[-:-:-] (F1) | toolUseAdviced: [%s:-:b]%v[-:-:-] (ctrl+k) | model: [%s:-:b]%s[-:-:-] (ctrl+l) | skip LLM resp: [%s:-:b]%v[-:-:-] (F10)\nAPI: [orange:-:b]%s[-:-:-] (ctrl+v) | recording: [%s:-:b]%v[-:-:-] (ctrl+r) | writing as: [orange:-:b]%s[-:-:-] (ctrl+q) | bot will write as [orange:-:b]%s[-:-:-] (ctrl+x) | role injection (alt+7) [%s:-:b]%v[-:-:-]"
focusSwitcher = map[tview.Primitive]tview.Primitive{}
)