Commit 90c49bed authored by Arne Müller's avatar Arne Müller
Browse files

moved removal of leading space into Predict

parent 5dc0cff4
...@@ -464,6 +464,11 @@ func (llm *llama) Predict(ctx context.Context, prevContext []int, prompt string, ...@@ -464,6 +464,11 @@ func (llm *llama) Predict(ctx context.Context, prevContext []int, prompt string,
return err return err
} }
// Remove first leading space from prevConvo if present
if len(prevConvo) > 0 && prevConvo[0] == ' ' {
prevConvo = prevConvo[1:]
}
var nextContext strings.Builder var nextContext strings.Builder
nextContext.WriteString(prevConvo) nextContext.WriteString(prevConvo)
nextContext.WriteString(prompt) nextContext.WriteString(prompt)
...@@ -666,7 +671,7 @@ func (llm *llama) Decode(ctx context.Context, tokens []int) (string, error) { ...@@ -666,7 +671,7 @@ func (llm *llama) Decode(ctx context.Context, tokens []int) (string, error) {
} }
// decoded content contains a leading whitespace // decoded content contains a leading whitespace
decoded.Content, _ = strings.CutPrefix(decoded.Content, " ") decoded.Content, _ = strings.CutPrefix(decoded.Content, "")
return decoded.Content, nil return decoded.Content, nil
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment