summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md6
-rw-r--r--bot.go9
-rw-r--r--config.example.toml3
-rw-r--r--config/config.go6
-rw-r--r--models/models.go6
-rw-r--r--session.go3
-rw-r--r--tui.go13
7 files changed, 19 insertions, 27 deletions
diff --git a/README.md b/README.md
index fe4aca1..9f14744 100644
--- a/README.md
+++ b/README.md
@@ -64,9 +64,9 @@
- number of sentences in a batch should depend on number of words there. +
- F1 can load any chat, by loading chat of other agent it does not switch agents, if that chat is continued, it will rewrite agent in db; (either allow only chats from current agent OR switch agent on chat loading); +
- after chat is deleted: load undeleted chat; +
+- table selection does not work; (ctrl+m is enter, it breakes all the tables) +
- name split for llamacpp completion. user msg should end with 'bot_name:'; +
+- remove icons for agents/user; use only <role>: +
- add retry on failed call (and EOF);
- model info shold be an event and show disconnect status when fails;
-- message editing broke ( runtime error: index out of range [-1]); out of index
-- remove icons for agents/user; use only <role>:
-- table selection does not work;
+- message editing broke ( runtime error: index out of range [-1]); out of index;
diff --git a/bot.go b/bot.go
index 55fa2f0..c3108a3 100644
--- a/bot.go
+++ b/bot.go
@@ -185,6 +185,10 @@ func chatRagUse(qText string) (string, error) {
return strings.Join(resps, "\n"), nil
}
+func roleToIcon(role string) string {
+ return "<" + role + ">: "
+}
+
func chatRound(userMsg, role string, tv *tview.TextView, regen bool) {
botRespMode = true
// reader := formMsg(chatBody, userMsg, role)
@@ -197,7 +201,7 @@ func chatRound(userMsg, role string, tv *tview.TextView, regen bool) {
// if userMsg != "" && !regen { // no need to write assistant icon since we continue old message
if userMsg != "" || regen {
fmt.Fprintf(tv, "(%d) ", len(chatBody.Messages))
- fmt.Fprint(tv, cfg.AssistantIcon)
+ fmt.Fprint(tv, roleToIcon(cfg.AssistantRole))
fmt.Fprint(tv, "\n")
}
respText := strings.Builder{}
@@ -317,9 +321,6 @@ func textToMsgs(text string) []models.RoleMsg {
func applyCharCard(cc *models.CharCard) {
cfg.AssistantRole = cc.Role
- // TODO: need map role->icon
- cfg.AssistantIcon = "<" + cc.Role + ">: "
- // try to load last active chat
history, err := loadAgentsLastChat(cfg.AssistantRole)
if err != nil {
logger.Warn("failed to load last agent chat;", "agent", cc.Role, "err", err)
diff --git a/config.example.toml b/config.example.toml
index 6512a37..80e3640 100644
--- a/config.example.toml
+++ b/config.example.toml
@@ -6,8 +6,5 @@ LogFile = "log.txt"
UserRole = "user"
ToolRole = "tool"
AssistantRole = "assistant"
-AssistantIcon = "<🤖>: "
-UserIcon = "<user>: "
-ToolIcon = "<ï‚­>>: "
SysDir = "sysprompts"
ChunkLimit = 100000
diff --git a/config/config.go b/config/config.go
index 2e48f34..ddb0d91 100644
--- a/config/config.go
+++ b/config/config.go
@@ -18,9 +18,6 @@ type Config struct {
ToolRole string `toml:"ToolRole"`
ToolUse bool `toml:"ToolUse"`
AssistantRole string `toml:"AssistantRole"`
- AssistantIcon string `toml:"AssistantIcon"`
- UserIcon string `toml:"UserIcon"`
- ToolIcon string `toml:"ToolIcon"`
SysDir string `toml:"SysDir"`
ChunkLimit uint32 `toml:"ChunkLimit"`
// embeddings
@@ -47,9 +44,6 @@ func LoadConfigOrDefault(fn string) *Config {
config.UserRole = "user"
config.ToolRole = "tool"
config.AssistantRole = "assistant"
- config.AssistantIcon = "<assistant>: "
- config.UserIcon = "<user>: "
- config.UserIcon = "<tool>: "
config.SysDir = "sysprompts"
config.ChunkLimit = 8192
}
diff --git a/models/models.go b/models/models.go
index 6404464..c760569 100644
--- a/models/models.go
+++ b/models/models.go
@@ -61,13 +61,13 @@ func (m RoleMsg) ToText(i int, cfg *config.Config) string {
if !strings.HasPrefix(m.Content, cfg.UserRole+":") && !strings.HasPrefix(m.Content, cfg.AssistantRole+":") {
switch m.Role {
case "assistant":
- icon = fmt.Sprintf("(%d) %s", i, cfg.AssistantIcon)
+ icon = fmt.Sprintf("(%d) <%s>: ", i, cfg.AssistantRole)
case "user":
- icon = fmt.Sprintf("(%d) %s", i, cfg.UserIcon)
+ icon = fmt.Sprintf("(%d) <%s>: ", i, cfg.UserRole)
case "system":
icon = fmt.Sprintf("(%d) <system>: ", i)
case "tool":
- icon = fmt.Sprintf("(%d) %s", i, cfg.ToolIcon)
+ icon = fmt.Sprintf("(%d) <%s>: ", i, cfg.ToolRole)
default:
icon = fmt.Sprintf("(%d) <%s>: ", i, m.Role)
}
diff --git a/session.go b/session.go
index ee38843..7d790f3 100644
--- a/session.go
+++ b/session.go
@@ -77,7 +77,6 @@ func loadHistoryChat(chatName string) ([]models.RoleMsg, error) {
}
activeChatName = chatName
cfg.AssistantRole = chat.Agent
- cfg.AssistantIcon = "<" + chat.Agent + ">: "
return chat.ToHistory()
}
@@ -129,8 +128,6 @@ func loadOldChatOrGetNew() []models.RoleMsg {
chatMap[chat.Name] = chat
activeChatName = chat.Name
cfg.AssistantRole = chat.Agent
- // TODO: update assistant icon
- cfg.AssistantIcon = "<" + chat.Agent + ">: "
return history
}
diff --git a/tui.go b/tui.go
index f3d6f61..fded0e2 100644
--- a/tui.go
+++ b/tui.go
@@ -62,6 +62,7 @@ var (
[yellow]Ctrl+v[white]: switch between /completion and /chat api (if provided in config)
[yellow]Ctrl+r[white]: menu of files that can be loaded in vector db (RAG)
[yellow]Ctrl+t[white]: remove thinking (<think>) and tool messages from context (delete from chat)
+[yellow]Ctrl+l[white]: update connected model name (llamacpp)
Press Enter to go back
`
@@ -100,7 +101,7 @@ func colorText() {
// Replace code blocks with placeholders and store their styled versions
text = codeBlockRE.ReplaceAllStringFunc(text, func(match string) string {
// Style the code block and store it
- styled := fmt.Sprintf("[brown::i]%s[-:-:-]", match)
+ styled := fmt.Sprintf("[brown:yellow:i]%s[-:-:-]", match)
codeBlocks = append(codeBlocks, styled)
// Generate a unique placeholder (e.g., "__CODE_BLOCK_0__")
id := fmt.Sprintf(placeholder, counter)
@@ -406,9 +407,10 @@ func init() {
// delete last msg
// check textarea text; if it ends with bot icon delete only icon:
text := textView.GetText(true)
- if strings.HasSuffix(text, cfg.AssistantIcon) {
- logger.Info("deleting assistant icon", "icon", cfg.AssistantIcon)
- textView.SetText(strings.TrimSuffix(text, cfg.AssistantIcon))
+ assistantIcon := roleToIcon(cfg.AssistantRole)
+ if strings.HasSuffix(text, assistantIcon) {
+ logger.Info("deleting assistant icon", "icon", assistantIcon)
+ textView.SetText(strings.TrimSuffix(text, assistantIcon))
colorText()
return nil
}
@@ -520,8 +522,9 @@ func init() {
startNewChat()
return nil
}
- if event.Key() == tcell.KeyCtrlM {
+ if event.Key() == tcell.KeyCtrlL {
fetchModelName()
+ textArea.SetText("pressed ctrl+l", true)
updateStatusLine()
return nil
}