Refactor: remove icons
This commit is contained in:
@@ -64,9 +64,9 @@
|
|||||||
- number of sentences in a batch should depend on number of words there. +
|
- 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); +
|
- 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; +
|
- 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:'; +
|
- 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);
|
- add retry on failed call (and EOF);
|
||||||
- model info shold be an event and show disconnect status when fails;
|
- 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
|
- 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;
|
|
||||||
|
|||||||
9
bot.go
9
bot.go
@@ -185,6 +185,10 @@ func chatRagUse(qText string) (string, error) {
|
|||||||
return strings.Join(resps, "\n"), nil
|
return strings.Join(resps, "\n"), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func roleToIcon(role string) string {
|
||||||
|
return "<" + role + ">: "
|
||||||
|
}
|
||||||
|
|
||||||
func chatRound(userMsg, role string, tv *tview.TextView, regen bool) {
|
func chatRound(userMsg, role string, tv *tview.TextView, regen bool) {
|
||||||
botRespMode = true
|
botRespMode = true
|
||||||
// reader := formMsg(chatBody, userMsg, role)
|
// 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 { // no need to write assistant icon since we continue old message
|
||||||
if userMsg != "" || regen {
|
if userMsg != "" || regen {
|
||||||
fmt.Fprintf(tv, "(%d) ", len(chatBody.Messages))
|
fmt.Fprintf(tv, "(%d) ", len(chatBody.Messages))
|
||||||
fmt.Fprint(tv, cfg.AssistantIcon)
|
fmt.Fprint(tv, roleToIcon(cfg.AssistantRole))
|
||||||
fmt.Fprint(tv, "\n")
|
fmt.Fprint(tv, "\n")
|
||||||
}
|
}
|
||||||
respText := strings.Builder{}
|
respText := strings.Builder{}
|
||||||
@@ -317,9 +321,6 @@ func textToMsgs(text string) []models.RoleMsg {
|
|||||||
|
|
||||||
func applyCharCard(cc *models.CharCard) {
|
func applyCharCard(cc *models.CharCard) {
|
||||||
cfg.AssistantRole = cc.Role
|
cfg.AssistantRole = cc.Role
|
||||||
// TODO: need map role->icon
|
|
||||||
cfg.AssistantIcon = "<" + cc.Role + ">: "
|
|
||||||
// try to load last active chat
|
|
||||||
history, err := loadAgentsLastChat(cfg.AssistantRole)
|
history, err := loadAgentsLastChat(cfg.AssistantRole)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Warn("failed to load last agent chat;", "agent", cc.Role, "err", err)
|
logger.Warn("failed to load last agent chat;", "agent", cc.Role, "err", err)
|
||||||
|
|||||||
@@ -6,8 +6,5 @@ LogFile = "log.txt"
|
|||||||
UserRole = "user"
|
UserRole = "user"
|
||||||
ToolRole = "tool"
|
ToolRole = "tool"
|
||||||
AssistantRole = "assistant"
|
AssistantRole = "assistant"
|
||||||
AssistantIcon = "<🤖>: "
|
|
||||||
UserIcon = "<user>: "
|
|
||||||
ToolIcon = "<>>: "
|
|
||||||
SysDir = "sysprompts"
|
SysDir = "sysprompts"
|
||||||
ChunkLimit = 100000
|
ChunkLimit = 100000
|
||||||
|
|||||||
@@ -18,9 +18,6 @@ type Config struct {
|
|||||||
ToolRole string `toml:"ToolRole"`
|
ToolRole string `toml:"ToolRole"`
|
||||||
ToolUse bool `toml:"ToolUse"`
|
ToolUse bool `toml:"ToolUse"`
|
||||||
AssistantRole string `toml:"AssistantRole"`
|
AssistantRole string `toml:"AssistantRole"`
|
||||||
AssistantIcon string `toml:"AssistantIcon"`
|
|
||||||
UserIcon string `toml:"UserIcon"`
|
|
||||||
ToolIcon string `toml:"ToolIcon"`
|
|
||||||
SysDir string `toml:"SysDir"`
|
SysDir string `toml:"SysDir"`
|
||||||
ChunkLimit uint32 `toml:"ChunkLimit"`
|
ChunkLimit uint32 `toml:"ChunkLimit"`
|
||||||
// embeddings
|
// embeddings
|
||||||
@@ -47,9 +44,6 @@ func LoadConfigOrDefault(fn string) *Config {
|
|||||||
config.UserRole = "user"
|
config.UserRole = "user"
|
||||||
config.ToolRole = "tool"
|
config.ToolRole = "tool"
|
||||||
config.AssistantRole = "assistant"
|
config.AssistantRole = "assistant"
|
||||||
config.AssistantIcon = "<assistant>: "
|
|
||||||
config.UserIcon = "<user>: "
|
|
||||||
config.UserIcon = "<tool>: "
|
|
||||||
config.SysDir = "sysprompts"
|
config.SysDir = "sysprompts"
|
||||||
config.ChunkLimit = 8192
|
config.ChunkLimit = 8192
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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+":") {
|
if !strings.HasPrefix(m.Content, cfg.UserRole+":") && !strings.HasPrefix(m.Content, cfg.AssistantRole+":") {
|
||||||
switch m.Role {
|
switch m.Role {
|
||||||
case "assistant":
|
case "assistant":
|
||||||
icon = fmt.Sprintf("(%d) %s", i, cfg.AssistantIcon)
|
icon = fmt.Sprintf("(%d) <%s>: ", i, cfg.AssistantRole)
|
||||||
case "user":
|
case "user":
|
||||||
icon = fmt.Sprintf("(%d) %s", i, cfg.UserIcon)
|
icon = fmt.Sprintf("(%d) <%s>: ", i, cfg.UserRole)
|
||||||
case "system":
|
case "system":
|
||||||
icon = fmt.Sprintf("(%d) <system>: ", i)
|
icon = fmt.Sprintf("(%d) <system>: ", i)
|
||||||
case "tool":
|
case "tool":
|
||||||
icon = fmt.Sprintf("(%d) %s", i, cfg.ToolIcon)
|
icon = fmt.Sprintf("(%d) <%s>: ", i, cfg.ToolRole)
|
||||||
default:
|
default:
|
||||||
icon = fmt.Sprintf("(%d) <%s>: ", i, m.Role)
|
icon = fmt.Sprintf("(%d) <%s>: ", i, m.Role)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ func loadHistoryChat(chatName string) ([]models.RoleMsg, error) {
|
|||||||
}
|
}
|
||||||
activeChatName = chatName
|
activeChatName = chatName
|
||||||
cfg.AssistantRole = chat.Agent
|
cfg.AssistantRole = chat.Agent
|
||||||
cfg.AssistantIcon = "<" + chat.Agent + ">: "
|
|
||||||
return chat.ToHistory()
|
return chat.ToHistory()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,8 +128,6 @@ func loadOldChatOrGetNew() []models.RoleMsg {
|
|||||||
chatMap[chat.Name] = chat
|
chatMap[chat.Name] = chat
|
||||||
activeChatName = chat.Name
|
activeChatName = chat.Name
|
||||||
cfg.AssistantRole = chat.Agent
|
cfg.AssistantRole = chat.Agent
|
||||||
// TODO: update assistant icon
|
|
||||||
cfg.AssistantIcon = "<" + chat.Agent + ">: "
|
|
||||||
return history
|
return history
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
13
tui.go
13
tui.go
@@ -62,6 +62,7 @@ var (
|
|||||||
[yellow]Ctrl+v[white]: switch between /completion and /chat api (if provided in config)
|
[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+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+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
|
Press Enter to go back
|
||||||
`
|
`
|
||||||
@@ -100,7 +101,7 @@ func colorText() {
|
|||||||
// Replace code blocks with placeholders and store their styled versions
|
// Replace code blocks with placeholders and store their styled versions
|
||||||
text = codeBlockRE.ReplaceAllStringFunc(text, func(match string) string {
|
text = codeBlockRE.ReplaceAllStringFunc(text, func(match string) string {
|
||||||
// Style the code block and store it
|
// 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)
|
codeBlocks = append(codeBlocks, styled)
|
||||||
// Generate a unique placeholder (e.g., "__CODE_BLOCK_0__")
|
// Generate a unique placeholder (e.g., "__CODE_BLOCK_0__")
|
||||||
id := fmt.Sprintf(placeholder, counter)
|
id := fmt.Sprintf(placeholder, counter)
|
||||||
@@ -406,9 +407,10 @@ func init() {
|
|||||||
// delete last msg
|
// delete last msg
|
||||||
// check textarea text; if it ends with bot icon delete only icon:
|
// check textarea text; if it ends with bot icon delete only icon:
|
||||||
text := textView.GetText(true)
|
text := textView.GetText(true)
|
||||||
if strings.HasSuffix(text, cfg.AssistantIcon) {
|
assistantIcon := roleToIcon(cfg.AssistantRole)
|
||||||
logger.Info("deleting assistant icon", "icon", cfg.AssistantIcon)
|
if strings.HasSuffix(text, assistantIcon) {
|
||||||
textView.SetText(strings.TrimSuffix(text, cfg.AssistantIcon))
|
logger.Info("deleting assistant icon", "icon", assistantIcon)
|
||||||
|
textView.SetText(strings.TrimSuffix(text, assistantIcon))
|
||||||
colorText()
|
colorText()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -520,8 +522,9 @@ func init() {
|
|||||||
startNewChat()
|
startNewChat()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if event.Key() == tcell.KeyCtrlM {
|
if event.Key() == tcell.KeyCtrlL {
|
||||||
fetchModelName()
|
fetchModelName()
|
||||||
|
textArea.SetText("pressed ctrl+l", true)
|
||||||
updateStatusLine()
|
updateStatusLine()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user