浏览代码

trim whitespace before checking stop conditions

Fixes #295
Jeffrey Morgan 1 年之前
父节点
当前提交
5eb712f962
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      llama/llama.go

+ 2 - 2
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
 		}
 	}