From 90c49bed573fdc8e1c2851016edf9c957884a145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20M=C3=BCller?= Date: Wed, 18 Oct 2023 20:08:26 +0200 Subject: [PATCH] moved removal of leading space into Predict --- llm/llama.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/llm/llama.go b/llm/llama.go index d2c6f76f..97685645 100644 --- a/llm/llama.go +++ b/llm/llama.go @@ -464,6 +464,11 @@ func (llm *llama) Predict(ctx context.Context, prevContext []int, prompt string, return err } + // Remove first leading space from prevConvo if present + if len(prevConvo) > 0 && prevConvo[0] == ' ' { + prevConvo = prevConvo[1:] + } + var nextContext strings.Builder nextContext.WriteString(prevConvo) nextContext.WriteString(prompt) @@ -666,7 +671,7 @@ func (llm *llama) Decode(ctx context.Context, tokens []int) (string, error) { } // decoded content contains a leading whitespace - decoded.Content, _ = strings.CutPrefix(decoded.Content, " ") + decoded.Content, _ = strings.CutPrefix(decoded.Content, "") return decoded.Content, nil }