that kinda works api/v0/chatbot

master
bel 2023-06-17 11:04:45 -06:00
parent c0c74b3e8f
commit 26da94f6d7
1 changed files with 7 additions and 27 deletions

View File

@ -263,8 +263,8 @@ func handleAPIChatBot(w http.ResponseWriter, r *http.Request) error {
func handleAPIChatBotPost(w http.ResponseWriter, r *http.Request) error { func handleAPIChatBotPost(w http.ResponseWriter, r *http.Request) error {
cookie, _ := ParseCookie(r) cookie, _ := ParseCookie(r)
sessionD := path.Join(Config.ChatBot.SessionD, cookie.Name) sessionD := path.Join(Config.ChatBot.SessionD, cookie.Name)
if _, err := os.Stat(path.Join(sessionD, "chat.d")); err == nil { if _, err := os.Stat(path.Join(sessionD)); err == nil {
if err := os.RemoveAll(path.Join(sessionD, "chat.d")); err != nil { if err := os.RemoveAll(path.Join(sessionD)); err != nil {
return err return err
} }
} }
@ -363,31 +363,11 @@ func handleAPIChatBotPut(w http.ResponseWriter, r *http.Request) error {
return err return err
} }
log.Printf("OUTPUT: %s", buff.Bytes()) result := bytes.TrimSuffix(buff.Bytes(), []byte(reversePrompt))
return errors.New("not impl: move input to prompt") if err := os.WriteFile(promptF, result, os.ModePerm); err != nil {
return err
/* }
go func() { w.Write(result)
Config.ChatBot.semaphore.Lock()
defer Config.ChatBot.semaphore.Unlock()
commands := strings.Fields(Config.ChatBot.Command)
commands = append(commands,
"-f", promptF,
"--batch_size", "8",
"--prompt-cache", cacheF,
"--file", promptF,
"--n_predict", "1",
)
command := exec.CommandContext(
r.Context(),
commands[0],
commands[1:]...,
)
command.Dir = Config.ChatBot.WD
command.Run()
}()
*/
return nil return nil
} }