From 68a87dc3db596b7179114890263235d6d3794d04 Mon Sep 17 00:00:00 2001 From: bel Date: Sat, 17 Jun 2023 13:58:33 -0600 Subject: [PATCH] passing --- vicuna-tools.d/main.go | 5 ++--- vicuna-tools.d/main_integration_test.go | 4 +++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/vicuna-tools.d/main.go b/vicuna-tools.d/main.go index 763829a..56be30d 100644 --- a/vicuna-tools.d/main.go +++ b/vicuna-tools.d/main.go @@ -328,6 +328,7 @@ func handleAPIChatBotPut(w http.ResponseWriter, r *http.Request) error { if err != nil { return err } + //log.Printf("generated for %s via %s: [%s]", cookie.MyName(), r.URL.Path, justNew) if err := os.Rename(inputF, promptF); err != nil { return err } @@ -382,6 +383,7 @@ func chatBotGenerateAndFillInputF(ctx context.Context, cacheF, inputF, reversePr commands[1:]..., ) command.Dir = Config.ChatBot.WD + command.Stderr = io.Discard command.Stderr = log.Writer() stdout, err := command.StdoutPipe() @@ -405,7 +407,6 @@ func chatBotGenerateAndFillInputF(ctx context.Context, cacheF, inputF, reversePr } oldAndNew := buff.Bytes() - log.Printf("generated: [%s]", oldAndNew) priorContent, err := os.ReadFile(inputF) if err != nil { return nil, err @@ -415,14 +416,12 @@ func chatBotGenerateAndFillInputF(ctx context.Context, cacheF, inputF, reversePr append(priorContent, justNew...), []byte(reversePrompt), ) - log.Printf("found lastindex(%d priorContent + %d newContent, %s) = %v", len(priorContent), len(justNew), reversePrompt, idx) if idx+len(reversePrompt) > len(priorContent) { justNew = justNew[:idx+len(reversePrompt)-len(priorContent)] } if err := _appendFile(inputF, string(justNew)); err != nil { return nil, err } - log.Printf("newly generated: [%s]", justNew) if !bytes.HasSuffix(append(priorContent, justNew...), []byte(reversePrompt)) { more, err := chatBotGenerateAndFillInputF(ctx, cacheF, inputF, reversePrompt) diff --git a/vicuna-tools.d/main_integration_test.go b/vicuna-tools.d/main_integration_test.go index 3f3deac..adf7456 100644 --- a/vicuna-tools.d/main_integration_test.go +++ b/vicuna-tools.d/main_integration_test.go @@ -36,7 +36,9 @@ func TestAPIV0ChatBot(t *testing.T) { t.Error(string(got)) } - resp2 := httpDo(t, http.MethodPut, "/api/v0/chatbot", body().Encode()) + body2 := body() + body2.Set("Message", "I don't know, boss....") + resp2 := httpDo(t, http.MethodPut, "/api/v0/chatbot", body2.Encode()) got2, err := io.ReadAll(resp2.Body) if err != nil { t.Fatal(err)