mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-23 10:57:44 +08:00
修复接续流的增量bug
This commit is contained in:
22
internal/sse/dedupe.go
Normal file
22
internal/sse/dedupe.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package sse
|
||||
|
||||
import "strings"
|
||||
|
||||
// TrimContinuationOverlap removes the already-seen prefix when DeepSeek
|
||||
// continue rounds resend the full fragment snapshot instead of only the new
|
||||
// suffix. Non-overlapping chunks are returned unchanged.
|
||||
func TrimContinuationOverlap(existing, incoming string) string {
|
||||
if incoming == "" {
|
||||
return ""
|
||||
}
|
||||
if existing == "" {
|
||||
return incoming
|
||||
}
|
||||
if strings.HasPrefix(incoming, existing) {
|
||||
return incoming[len(existing):]
|
||||
}
|
||||
if strings.HasPrefix(existing, incoming) {
|
||||
return ""
|
||||
}
|
||||
return incoming
|
||||
}
|
||||
Reference in New Issue
Block a user