@cpzxrobot/sdk 1.3.7 → 1.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web_platform.js +3 -3
- package/package.json +1 -1
- package/web_platform.ts +3 -3
package/dist/web_platform.js
CHANGED
|
@@ -64,12 +64,12 @@ class WebPlatform {
|
|
|
64
64
|
if (line === "[DONE]") {
|
|
65
65
|
break;
|
|
66
66
|
}
|
|
67
|
-
else {
|
|
67
|
+
else if (line.startsWith("data: ")) {
|
|
68
68
|
// remove prefix 'data: '
|
|
69
69
|
// 移除前缀 'data: '
|
|
70
70
|
var data = JSON.parse(line.split(": ")[1]);
|
|
71
71
|
//{"choices":[{"delta":{"content":" </"},"index":0}],"created":1741749068,"id":"chatcmpl-67ccb889154043f5874cbf3a64ec163e","model":"DeepSeek-R1","object":"chat.completion.chunk"}
|
|
72
|
-
fn === null || fn === void 0 ? void 0 : fn
|
|
72
|
+
fn === null || fn === void 0 ? void 0 : fn(data);
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
catch (e) {
|
|
@@ -200,7 +200,7 @@ class WebPlatform {
|
|
|
200
200
|
return new Promise((resolve, reject) => {
|
|
201
201
|
instance.streamWithAuth(url, {
|
|
202
202
|
method: 'GET',
|
|
203
|
-
}, fn);
|
|
203
|
+
}, fn).then(resolve).catch(reject);
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
206
|
};
|
package/package.json
CHANGED
package/web_platform.ts
CHANGED
|
@@ -74,12 +74,12 @@ export class WebPlatform implements PlatformInterface {
|
|
|
74
74
|
try {
|
|
75
75
|
if (line === "[DONE]") {
|
|
76
76
|
break;
|
|
77
|
-
} else {
|
|
77
|
+
} else if (line.startsWith("data: ")) {
|
|
78
78
|
// remove prefix 'data: '
|
|
79
79
|
// 移除前缀 'data: '
|
|
80
80
|
var data = JSON.parse(line.split(": ")[1]);
|
|
81
81
|
//{"choices":[{"delta":{"content":" </"},"index":0}],"created":1741749068,"id":"chatcmpl-67ccb889154043f5874cbf3a64ec163e","model":"DeepSeek-R1","object":"chat.completion.chunk"}
|
|
82
|
-
fn?.
|
|
82
|
+
fn?.(data);
|
|
83
83
|
}
|
|
84
84
|
} catch (e) {
|
|
85
85
|
console.error("解析失败", e);
|
|
@@ -215,7 +215,7 @@ export class WebPlatform implements PlatformInterface {
|
|
|
215
215
|
return new Promise<any>((resolve, reject) => {
|
|
216
216
|
instance.streamWithAuth(url, {
|
|
217
217
|
method: 'GET',
|
|
218
|
-
}, fn);
|
|
218
|
+
}, fn).then(resolve).catch(reject);
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
221
|
};
|