From 2bc06565c7ca7f784fefc0d2f037269b8af2a33d Mon Sep 17 00:00:00 2001 From: Michael Yang Date: Tue, 5 Sep 2023 15:03:24 -0700 Subject: [PATCH] fix empty response --- llm/ggml_llama.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/llm/ggml_llama.go b/llm/ggml_llama.go index 0c293732..010d579a 100644 --- a/llm/ggml_llama.go +++ b/llm/ggml_llama.go @@ -497,8 +497,10 @@ func (llm *llama) Predict(ctx context.Context, prevContext []int, prompt string, return fmt.Errorf("error unmarshaling llm prediction response: %v", err) } - fn(api.GenerateResponse{Response: p.Content}) - nextContext.WriteString(p.Content) + if p.Content != "" { + fn(api.GenerateResponse{Response: p.Content}) + nextContext.WriteString(p.Content) + } if p.Stop { embd, err := llm.Encode(ctx, nextContext.String())