From 5eb712f96256278a6ffdbebb53d551c2aa2a8e45 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Tue, 8 Aug 2023 00:27:55 -0400 Subject: [PATCH] trim whitespace before checking stop conditions Fixes #295 --- llama/llama.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llama/llama.go b/llama/llama.go index c18dc952..0a523321 100644 --- a/llama/llama.go +++ b/llama/llama.go @@ -250,9 +250,9 @@ func (llm *LLM) Predict(ctx []int, prompt string, fn func(api.GenerateResponse)) func (llm *LLM) checkStopConditions(b bytes.Buffer) error { for _, stopCondition := range llm.Stop { - if stopCondition == b.String() { + if stopCondition == strings.TrimSpace(b.String()) { return io.EOF - } else if strings.HasPrefix(stopCondition, b.String()) { + } else if strings.HasPrefix(stopCondition, strings.TrimSpace(b.String())) { return errNeedMoreData } }