mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-23 10:57:44 +08:00
refactor: improve chat history persistence reliability with metadata-only migration, error handling, and optimized file updates
This commit is contained in:
@@ -36,9 +36,13 @@ func CollectStream(resp *http.Response, thinkingEnabled bool, closeBody bool) Co
|
||||
currentType = "thinking"
|
||||
}
|
||||
_ = deepseek.ScanSSELines(resp, func(line []byte) bool {
|
||||
if chunk, done, parsed := ParseDeepSeekSSELine(line); parsed && !done {
|
||||
chunk, done, parsed := ParseDeepSeekSSELine(line)
|
||||
if parsed && !done {
|
||||
collector.ingestChunk(chunk)
|
||||
}
|
||||
if done {
|
||||
return false
|
||||
}
|
||||
if stopped {
|
||||
return true
|
||||
}
|
||||
@@ -52,7 +56,8 @@ func CollectStream(resp *http.Response, thinkingEnabled bool, closeBody bool) Co
|
||||
contentFilter = true
|
||||
}
|
||||
// Keep scanning to collect late-arriving citation metadata lines
|
||||
// that can appear after response/status=FINISHED.
|
||||
// that can appear after response/status=FINISHED, but stop as soon
|
||||
// as [DONE] arrives.
|
||||
stopped = true
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user