diff options
author | Grail Finder <wohilas@gmail.com> | 2024-11-23 18:34:02 +0300 |
---|---|---|
committer | Grail Finder <wohilas@gmail.com> | 2024-11-23 18:34:02 +0300 |
commit | 6625a8103bb70833e2399567cbbe7f3b4a8da429 (patch) | |
tree | 9e5c76cc406a6fa6b12405da957363fb78ae2f21 | |
parent | 692e0ada4b6115078485a9bc867c99d2c85d8dd9 (diff) |
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | bot.go | 2 | ||||
-rw-r--r-- | main.go | 26 | ||||
-rw-r--r-- | tools.go | 29 |
4 files changed, 36 insertions, 26 deletions
@@ -13,12 +13,13 @@ - stop stream from the bot; + - sqlitedb instead of chatfiles; + - define tools and sys prompt for them to be used; + +- add system prompt without tools (for mistral); + +- option to switch between predefined sys prompts; + - sqlite for the bot memory; - fullscreen textarea option (bothersome to implement); -- add system prompt without tools (for mistral); -- option to switch between predefined sys prompts; - consider adding use /completion of llamacpp, since openai endpoint clearly has template|format issues; - change temp, min-p and other params from tui; +- help page with all key bindings; ### FIX: - bot responding (or haninging) blocks everything; + @@ -23,13 +23,13 @@ var httpClient = http.Client{ var ( logger *slog.Logger - APIURL = "http://localhost:8080/v1/chat/completions" userRole = "user" assistantRole = "assistant" toolRole = "tool" assistantIcon = "<🤖>: " userIcon = "<user>: " // TODO: pass as an cli arg or have config + APIURL = "http://localhost:8080/v1/chat/completions" logFileName = "log.txt" showSystemMsgs bool chunkLimit = 1000 @@ -102,6 +102,27 @@ func main() { return } }) + sysModal := tview.NewModal(). + SetText("Switch sys msg:"). + AddButtons(sysLabels). + SetDoneFunc(func(buttonIndex int, buttonLabel string) { + switch buttonLabel { + case "cancel": + pages.RemovePage("sys") + return + default: + sysMsg, ok := sysMap[buttonLabel] + if !ok { + logger.Warn("no such sys msg", "name", buttonLabel) + pages.RemovePage("sys") + return + } + chatBody.Messages[0].Content = sysMsg + // replace textview + textView.SetText(chatToText(showSystemMsgs)) + pages.RemovePage("sys") + } + }) editArea := tview.NewTextArea(). SetPlaceholder("Replace msg...") editArea.SetBorder(true).SetTitle("input") @@ -218,6 +239,11 @@ func main() { textArea.SetText("pressed ctrl+e", true) return nil } + if event.Key() == tcell.KeyCtrlS { + // switch sys prompt + pages.AddPage("sys", sysModal, true, true) + return nil + } // cannot send msg in editMode or botRespMode if event.Key() == tcell.KeyEscape && !editMode && !botRespMode { fromRow, fromColumn, _, _ := textArea.GetCursor() @@ -9,29 +9,9 @@ import ( var ( // TODO: form that message based on existing funcs - // systemMsg = `You're a helpful assistant. - // # Tools - // You can do functions call if needed. - // Your current tools: - // <tools> - // { - // "name":"get_id", - // "args": "username" - // } - // </tools> - // To make a function call return a json object within __tool_call__ tags; - // Example: - // __tool_call__ - // { - // "name":"get_id", - // "args": "Adam" - // } - // __tool_call__ - // When making function call avoid typing anything else. 'tool' user will respond with the results of the call. - // After that you are free to respond to the user. - // ` - toolCallRE = regexp.MustCompile(`__tool_call__\s*([\s\S]*?)__tool_call__`) - systemMsg = `You're a helpful assistant. + basicSysMsg = `Large Language Model that helps user with any of his requests.` + toolCallRE = regexp.MustCompile(`__tool_call__\s*([\s\S]*?)__tool_call__`) + toolSysMsg = `You're a helpful assistant. # Tools You can do functions call if needed. Your current tools: @@ -65,6 +45,9 @@ __tool_call__ When done right, tool call will be delivered to the 'tool' agent. 'tool' agent will respond with the results of the call. After that you are free to respond to the user. ` + systemMsg = toolSysMsg + sysMap = map[string]string{"basic_sys": basicSysMsg, "tool_sys": toolSysMsg} + sysLabels = []string{"cancel", "basic_sys", "tool_sys"} ) /* |