mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-02 07:25:26 +08:00
25 lines
674 B
Go
25 lines
674 B
Go
package sse
|
|
|
|
import "strings"
|
|
|
|
const minContinuationSnapshotLen = 32
|
|
|
|
// 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 len(incoming) >= minContinuationSnapshotLen && strings.HasPrefix(incoming, existing) {
|
|
return incoming[len(existing):]
|
|
}
|
|
if len(incoming) >= minContinuationSnapshotLen && strings.HasPrefix(existing, incoming) {
|
|
return ""
|
|
}
|
|
return incoming
|
|
}
|