diff options
author | Grail Finder <wohilas@gmail.com> | 2024-12-10 17:55:10 +0300 |
---|---|---|
committer | Grail Finder <wohilas@gmail.com> | 2024-12-10 17:55:10 +0300 |
commit | 5f780287aecedf08f94b6a1e0ae2a8822683a3fc (patch) | |
tree | 6de227e5f932bd5a2fa2cff3260ba23a68124e6d /bot.go | |
parent | 67f36d417fa97c4087e326623508370f60d3d3b8 (diff) |
Fix: display and upsert correct roles and icons
Diffstat (limited to 'bot.go')
-rw-r--r-- | bot.go | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -115,7 +115,8 @@ func chatRound(userMsg, role string, tv *tview.TextView, regen bool) { return } go sendMsgToLLM(reader) - 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 { fmt.Fprintf(tv, "(%d) ", len(chatBody.Messages)) fmt.Fprint(tv, cfg.AssistantIcon) fmt.Fprint(tv, "\n") @@ -181,7 +182,7 @@ func chatToTextSlice(showSys bool) []string { if !showSys && (msg.Role != cfg.AssistantRole && msg.Role != cfg.UserRole) { continue } - resp[i] = msg.ToText(i) + resp[i] = msg.ToText(i, cfg) } return resp } @@ -193,6 +194,8 @@ func chatToText(showSys bool) string { 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 { @@ -254,12 +257,12 @@ func charToStart(agentName string) bool { // } func init() { - cfg = config.LoadConfigOrDefault("config.example.toml") + cfg = config.LoadConfigOrDefault("config.toml") defaultStarter = []models.RoleMsg{ {Role: "system", Content: basicSysMsg}, {Role: cfg.AssistantRole, Content: defaultFirstMsg}, } - file, err := os.OpenFile(cfg.LogFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + logfile, err := os.OpenFile(cfg.LogFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) if err != nil { logger.Error("failed to open log file", "error", err, "filename", cfg.LogFile) return @@ -273,7 +276,7 @@ func init() { basicCard.Role = cfg.AssistantRole toolCard.Role = cfg.AssistantRole // - logger = slog.New(slog.NewTextHandler(file, nil)) + logger = slog.New(slog.NewTextHandler(logfile, nil)) store = storage.NewProviderSQL("test.db", logger) // https://github.com/coreydaley/ggerganov-llama.cpp/blob/master/examples/server/README.md // load all chats in memory |