mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-20 07:57:43 +08:00
fix(vercel): align JS stream parser with Go object-shaped content
This commit is contained in:
@@ -308,6 +308,10 @@ function parseChunkForContent(chunk, thinkingEnabled, currentType, stripReferenc
|
||||
}
|
||||
|
||||
if (val && typeof val === 'object') {
|
||||
const directContent = asContentString(val, stripReferenceMarkers);
|
||||
if (directContent) {
|
||||
parts.push({ text: directContent, type: partType });
|
||||
}
|
||||
const resp = val.response && typeof val.response === 'object' ? val.response : val;
|
||||
if (Array.isArray(resp.fragments)) {
|
||||
for (const frag of resp.fragments) {
|
||||
@@ -593,6 +597,12 @@ function asContentString(v, stripReferenceMarkers = true) {
|
||||
if (Object.prototype.hasOwnProperty.call(v, 'v')) {
|
||||
return asContentString(v.v, stripReferenceMarkers);
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(v, 'text')) {
|
||||
return asContentString(v.text, stripReferenceMarkers);
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(v, 'value')) {
|
||||
return asContentString(v.value, stripReferenceMarkers);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
if (v == null) {
|
||||
|
||||
Reference in New Issue
Block a user