From c1344794143ef48670d8eeb365a10a5295a145ae Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Sat, 15 Feb 2025 11:09:47 +0300 Subject: Enha: log level to props --- tui.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'tui.go') diff --git a/tui.go b/tui.go index 948e363..8cbdf0b 100644 --- a/tui.go +++ b/tui.go @@ -135,7 +135,7 @@ func colorText() { } func updateStatusLine() { - position.SetText(fmt.Sprintf(indexLine, botRespMode, cfg.AssistantRole, activeChatName, cfg.RAGEnabled, cfg.ToolUse, currentModel, cfg.CurrentAPI, cfg.ThinkUse)) + position.SetText(fmt.Sprintf(indexLine, botRespMode, cfg.AssistantRole, activeChatName, cfg.RAGEnabled, cfg.ToolUse, currentModel, cfg.CurrentAPI, cfg.ThinkUse, logLevel.Level())) } func initSysCards() ([]string, error) { @@ -180,16 +180,33 @@ func startNewChat() { colorText() } +func setLogLevel(sl string) { + switch sl { + case "Debug": + logLevel.Set(-4) + case "Info": + logLevel.Set(0) + case "Warn": + logLevel.Set(4) + } +} + func makePropsForm(props map[string]float32) *tview.Form { + // https://github.com/rivo/tview/commit/0a18dea458148770d212d348f656988df75ff341 + // no way to close a form by a key press; a shame. form := tview.NewForm(). AddTextView("Notes", "Props for llamacpp completion call", 40, 2, true, false). AddCheckbox("Insert (/completion only)", cfg.ThinkUse, func(checked bool) { cfg.ThinkUse = checked + }).AddDropDown("Set log level (Enter): ", []string{"Debug", "Info", "Warn"}, 1, + func(option string, optionIndex int) { + setLogLevel(option) }). AddButton("Quit", func() { pages.RemovePage(propsPage) }) form.AddButton("Save", func() { + defer updateStatusLine() defer pages.RemovePage(propsPage) for pn := range props { propField, ok := form.GetFormItemByLabel(pn).(*tview.InputField) @@ -442,7 +459,7 @@ func init() { text := textView.GetText(true) assistantIcon := roleToIcon(cfg.AssistantRole) if strings.HasSuffix(text, assistantIcon) { - logger.Info("deleting assistant icon", "icon", assistantIcon) + logger.Debug("deleting assistant icon", "icon", assistantIcon) textView.SetText(strings.TrimSuffix(text, assistantIcon)) colorText() return nil -- cgit v1.2.3