diff --git a/llm/llama.go b/llm/llama.go index 38cc32bd..61288b52 100644 --- a/llm/llama.go +++ b/llm/llama.go @@ -479,6 +479,9 @@ func (llm *llama) Predict(ctx context.Context, prevContext []int, prompt string, return err } + // Remove leading spaces from prevConvo if present + prevConvo = strings.TrimPrefix(prevConvo, " ") + var nextContext strings.Builder nextContext.WriteString(prevConvo) nextContext.WriteString(prompt) @@ -688,9 +691,6 @@ func (llm *llama) Decode(ctx context.Context, tokens []int) (string, error) { return "", fmt.Errorf("unmarshal encode response: %w", err) } - // decoded content contains a leading whitespace - decoded.Content, _ = strings.CutPrefix(decoded.Content, "") - return decoded.Content, nil }