Merge pull request #833 from discovertomorrow/leadingspace

Fix Issue with Leading Whitespaces in Decoded Context
This commit is contained in:
Michael Yang 2023-10-18 13:52:48 -07:00 committed by GitHub
commit 235e43d7f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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
}