that kinda works api/v0/chatbot
parent
c0c74b3e8f
commit
26da94f6d7
|
|
@ -263,8 +263,8 @@ func handleAPIChatBot(w http.ResponseWriter, r *http.Request) error {
|
|||
func handleAPIChatBotPost(w http.ResponseWriter, r *http.Request) error {
|
||||
cookie, _ := ParseCookie(r)
|
||||
sessionD := path.Join(Config.ChatBot.SessionD, cookie.Name)
|
||||
if _, err := os.Stat(path.Join(sessionD, "chat.d")); err == nil {
|
||||
if err := os.RemoveAll(path.Join(sessionD, "chat.d")); err != nil {
|
||||
if _, err := os.Stat(path.Join(sessionD)); err == nil {
|
||||
if err := os.RemoveAll(path.Join(sessionD)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
@ -363,31 +363,11 @@ func handleAPIChatBotPut(w http.ResponseWriter, r *http.Request) error {
|
|||
return err
|
||||
}
|
||||
|
||||
log.Printf("OUTPUT: %s", buff.Bytes())
|
||||
return errors.New("not impl: move input to prompt")
|
||||
|
||||
/*
|
||||
go func() {
|
||||
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()
|
||||
}()
|
||||
*/
|
||||
result := bytes.TrimSuffix(buff.Bytes(), []byte(reversePrompt))
|
||||
if err := os.WriteFile(promptF, result, os.ModePerm); err != nil {
|
||||
return err
|
||||
}
|
||||
w.Write(result)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue