Skip to content

Commit

Permalink
fix: 上下文处理时content超出默认cache buffer长度导致分割异常2(#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
bincooo authored and bincooo committed Dec 28, 2024
1 parent fbb942c commit 31208d9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/gin/response/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ func splitToMessages(content string, merge bool) (messages []model.Keyv[interfac
}

scanner := bufio.NewScanner(bytes.NewBuffer([]byte(content)))
scanner.Buffer(nil, len(content))
// fix for bufio/scan.go:200
scanner.Buffer(nil, max(len(content)+1, bufio.MaxScanTokenSize))
scanner.Split(func(data []byte, atEOF bool) (advance int, token []byte, err error) {
if atEOF && len(data) == 0 {
return
Expand Down

0 comments on commit 31208d9

Please sign in to comment.