소스 검색

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