summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md5
-rw-r--r--bot.go2
-rw-r--r--main.go26
-rw-r--r--tools.go29
4 files changed, 36 insertions, 26 deletions
diff --git a/README.md b/README.md
index 94f2ca6..7736358 100644
--- a/README.md
+++ b/README.md
@@ -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; +
diff --git a/bot.go b/bot.go
index 6b15a3e..d4c86f0 100644
--- a/bot.go
+++ b/bot.go
@@ -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
diff --git a/main.go b/main.go
index c7528f5..e8f9f3a 100644
--- a/main.go
+++ b/main.go
@@ -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()
diff --git a/tools.go b/tools.go
index b42cb62..b752790 100644
--- a/tools.go
+++ b/tools.go
@@ -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"}
)
/*