diff options
author | Grail Finder <wohilas@gmail.com> | 2025-01-22 20:17:49 +0300 |
---|---|---|
committer | Grail Finder <wohilas@gmail.com> | 2025-01-22 20:17:49 +0300 |
commit | 75f51c1a19632ea093e1aad6a91cc7f4a349658c (patch) | |
tree | 71a944e90d9ee06f91d257aa7573081a0419e1a1 /tui.go | |
parent | c41ff09b2f62b8c715ec9beb2fdac987b25892d9 (diff) |
Feat: llamacpp /completion attempt
Diffstat (limited to 'tui.go')
-rw-r--r-- | tui.go | 36 |
1 files changed, 34 insertions, 2 deletions
@@ -37,6 +37,7 @@ var ( renamePage = "renamePage" RAGPage = "RAGPage " longStatusPage = "longStatusPage" + propsPage = "propsPage" // help text helpText = ` [yellow]Esc[white]: send msg @@ -129,6 +130,36 @@ func startNewChat() { colorText() } +func makePropsForm(props map[string]float32) *tview.Form { + form := tview.NewForm(). + AddTextView("Notes", "Props for llamacpp completion call", 40, 2, true, false). + AddCheckbox("Age 18+", false, nil). + AddButton("Quit", func() { + pages.RemovePage(propsPage) + }) + form.AddButton("Save", func() { + defer pages.RemovePage(propsPage) + for pn := range props { + propField, ok := form.GetFormItemByLabel(pn).(*tview.InputField) + if !ok { + logger.Warn("failed to convert to inputfield", "prop_name", pn) + continue + } + val, err := strconv.ParseFloat(propField.GetText(), 32) + if err != nil { + logger.Warn("failed parse to float", "value", propField.GetText()) + continue + } + props[pn] = float32(val) + } + }) + for propName, value := range props { + form.AddInputField(propName, fmt.Sprintf("%v", value), 20, tview.InputFieldFloat, nil) + } + form.SetBorder(true).SetTitle("Enter some data").SetTitleAlign(tview.AlignLeft) + return form +} + func init() { theme := tview.Theme{ PrimitiveBackgroundColor: tcell.ColorDefault, @@ -420,8 +451,9 @@ func init() { } return nil } - if event.Key() == tcell.KeyCtrlA { - textArea.SetText("pressed ctrl+a", true) + if event.Key() == tcell.KeyCtrlP { + propsForm := makePropsForm(defaultLCPProps) + pages.AddPage(propsPage, propsForm, true, true) return nil } if event.Key() == tcell.KeyCtrlN { |