From 63f9d28718c202aa9cba48056039a1ef03b366b0 Mon Sep 17 00:00:00 2001 From: Kerigan Date: Mon, 29 Jul 2024 01:02:15 -0500 Subject: [PATCH] Fix prompt bug, tell LLM to start a conversation more often, don't load saved chats from storage (just keep in RAM) --- chipper/pkg/vars/vars.go | 21 --------------------- chipper/pkg/wirepod/config-ws/webserver.go | 1 - chipper/pkg/wirepod/ttr/kgsim.go | 2 -- chipper/pkg/wirepod/ttr/kgsim_cmds.go | 16 ++++++++-------- chipper/webroot/setup.html | 2 +- 5 files changed, 9 insertions(+), 33 deletions(-) diff --git a/chipper/pkg/vars/vars.go b/chipper/pkg/vars/vars.go index 8ca6d1b4..73dab193 100644 --- a/chipper/pkg/vars/vars.go +++ b/chipper/pkg/vars/vars.go @@ -43,7 +43,6 @@ var ( VoskModelPath string = "../vosk/models/" WhisperModelPath string = "../whisper.cpp/models/" SessionCertPath string = "./session-certs/" - SavedChatsPath string = "./openaiChats.json" VersionFile string = "./version" ) @@ -180,7 +179,6 @@ func Init() { ServerConfigPath = join(podDir, "./certs/server_config.json") Certs = join(podDir, "./certs") SessionCertPath = join(podDir, SessionCertPath) - SavedChatsPath = join(podDir, SavedChatsPath) if runtime.GOOS == "android" { VersionFile = AndroidPath + "/static/version" } @@ -232,9 +230,6 @@ func Init() { // load api config (config.go) ReadConfig() - // load openai chats - LoadChats() - // check models folder, add all models to DownloadedVoskModels if APIConfig.STT.Service == "vosk" { GetDownloadedVoskModels() @@ -420,22 +415,6 @@ func AddToRInfo(esn string, id string, ip string) { RecurringInfo = append(RecurringInfo, rinfo) } -func SaveChats() { - marshalled, err := json.Marshal(RememberedChats) - if err != nil { - logger.Println(err) - } - os.WriteFile(SavedChatsPath, marshalled, 0777) -} - -func LoadChats() { - file, err := os.ReadFile(SavedChatsPath) - if err != nil { - return - } - json.Unmarshal(file, &RememberedChats) -} - func GetRobot(esn string) (*vector.Vector, error) { var guid string var target string diff --git a/chipper/pkg/wirepod/config-ws/webserver.go b/chipper/pkg/wirepod/config-ws/webserver.go index 62c1b6a4..c85e31a9 100755 --- a/chipper/pkg/wirepod/config-ws/webserver.go +++ b/chipper/pkg/wirepod/config-ws/webserver.go @@ -286,7 +286,6 @@ func handleIsRunning(w http.ResponseWriter) { } func handleDeleteChats(w http.ResponseWriter) { - os.Remove(vars.SavedChatsPath) vars.RememberedChats = []vars.RememberedChat{} fmt.Fprint(w, "done") } diff --git a/chipper/pkg/wirepod/ttr/kgsim.go b/chipper/pkg/wirepod/ttr/kgsim.go index 7380d1a4..82e65a6d 100644 --- a/chipper/pkg/wirepod/ttr/kgsim.go +++ b/chipper/pkg/wirepod/ttr/kgsim.go @@ -36,12 +36,10 @@ func PlaceChat(chat vars.RememberedChat) { for i, achat := range vars.RememberedChats { if achat.ESN == chat.ESN { vars.RememberedChats[i] = chat - vars.SaveChats() return } } vars.RememberedChats = append(vars.RememberedChats, chat) - vars.SaveChats() } // remember last 16 lines of chat diff --git a/chipper/pkg/wirepod/ttr/kgsim_cmds.go b/chipper/pkg/wirepod/ttr/kgsim_cmds.go index e8126b70..933d3e12 100644 --- a/chipper/pkg/wirepod/ttr/kgsim_cmds.go +++ b/chipper/pkg/wirepod/ttr/kgsim_cmds.go @@ -127,7 +127,7 @@ var ValidLLMCommands []LLMCommand = []LLMCommand{ }, { Command: "newVoiceRequest", - Description: "Starts a new voice command from the robot. Use this if you want more input from the user/if you want to carry out a conversation. You are the only one who can end it in this case. This goes at the end of your response, if you use it.", + Description: "Starts a new voice command from the robot. Use this if you want more input from the user after your response/if you want to carry out a conversation. This goes at the end of your response, if you use it.", ParamChoices: "now", Action: ActionNewRequest, SupportedModels: []string{"all"}, @@ -158,13 +158,13 @@ func CreatePrompt(origPrompt string, model string, isKG bool) string { promptAppendage := "\n\nCommand Name: " + cmd.Command + "\nDescription: " + cmd.Description + "\nParameter choices: " + cmd.ParamChoices prompt = prompt + promptAppendage } - if isKG && vars.APIConfig.Knowledge.SaveChat { - promptAppentage := "\n\nNOTE: You are in 'conversation' mode. If you ask the user a question, use newVoiceRequest. If you don't, you should end the conversation by not using it." - prompt = prompt + promptAppentage - } else { - promptAppentage := "\n\nNOTE: You are NOT in 'conversation' mode. Refrain from asking the user any questions and from using newVoiceRequest." - prompt = prompt + promptAppentage - } + } + if isKG && vars.APIConfig.Knowledge.SaveChat { + promptAppentage := "\n\nNOTE: You are in 'conversation' mode. If you ask the user a question near the end of your response, you MUST use newVoiceRequest. If you decide you want to end the conversation, you should not use it." + prompt = prompt + promptAppentage + } else { + promptAppentage := "\n\nNOTE: You are NOT in 'conversation' mode. Refrain from asking the user any questions and from using newVoiceRequest." + prompt = prompt + promptAppentage } } if os.Getenv("DEBUG_PRINT_PROMPT") == "true" { diff --git a/chipper/webroot/setup.html b/chipper/webroot/setup.html index 7db2d2a6..dc20e954 100644 --- a/chipper/webroot/setup.html +++ b/chipper/webroot/setup.html @@ -168,7 +168,7 @@

Knowledge Graph Setup


Delete Saved Chats