@cpzxrobot/sdk 1.3.130 → 1.3.132
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 +4 -3
- package/package.json +1 -1
- package/web_platform.ts +4 -3
package/dist/web_platform.js
CHANGED
|
@@ -116,7 +116,7 @@ class WebPlatform {
|
|
|
116
116
|
else if (line.startsWith("data:")) {
|
|
117
117
|
// remove prefix 'data: '
|
|
118
118
|
// 移除前缀 'data: '
|
|
119
|
-
var data = JSON.parse(line.
|
|
119
|
+
var data = JSON.parse(line.substring(5));
|
|
120
120
|
//{"choices":[{"delta":{"content":" </"},"index":0}],"created":1741749068,"id":"chatcmpl-67ccb889154043f5874cbf3a64ec163e","model":"DeepSeek-R1","object":"chat.completion.chunk"}
|
|
121
121
|
fn === null || fn === void 0 ? void 0 : fn(data);
|
|
122
122
|
}
|
|
@@ -194,10 +194,11 @@ class WebPlatform {
|
|
|
194
194
|
return { data: yield response.json() };
|
|
195
195
|
}),
|
|
196
196
|
post: (url, data, config) => __awaiter(this, void 0, void 0, function* () {
|
|
197
|
+
const isFormData = data instanceof FormData;
|
|
197
198
|
const response = yield this.fetchWithAuth(url, {
|
|
198
199
|
method: 'POST',
|
|
199
|
-
headers: Object.assign({ 'Content-Type': 'application/json' }, config === null || config === void 0 ? void 0 : config.headers),
|
|
200
|
-
body: JSON.stringify(data)
|
|
200
|
+
headers: isFormData ? config === null || config === void 0 ? void 0 : config.headers : Object.assign({ 'Content-Type': 'application/json' }, config === null || config === void 0 ? void 0 : config.headers),
|
|
201
|
+
body: isFormData ? data : JSON.stringify(data)
|
|
201
202
|
});
|
|
202
203
|
return { data: yield response.json() };
|
|
203
204
|
}),
|
package/package.json
CHANGED
package/web_platform.ts
CHANGED
|
@@ -124,7 +124,7 @@ export class WebPlatform implements PlatformInterface {
|
|
|
124
124
|
} else if (line.startsWith("data:")) {
|
|
125
125
|
// remove prefix 'data: '
|
|
126
126
|
// 移除前缀 'data: '
|
|
127
|
-
var data = JSON.parse(line.
|
|
127
|
+
var data = JSON.parse(line.substring(5));
|
|
128
128
|
//{"choices":[{"delta":{"content":" </"},"index":0}],"created":1741749068,"id":"chatcmpl-67ccb889154043f5874cbf3a64ec163e","model":"DeepSeek-R1","object":"chat.completion.chunk"}
|
|
129
129
|
fn?.(data);
|
|
130
130
|
}
|
|
@@ -206,13 +206,14 @@ export class WebPlatform implements PlatformInterface {
|
|
|
206
206
|
return { data: await response.json() };
|
|
207
207
|
},
|
|
208
208
|
post: async (url: string, data?: any, config?: any) => {
|
|
209
|
+
const isFormData = data instanceof FormData;
|
|
209
210
|
const response = await this.fetchWithAuth(url, {
|
|
210
211
|
method: 'POST',
|
|
211
|
-
headers: {
|
|
212
|
+
headers: isFormData ? config?.headers : {
|
|
212
213
|
'Content-Type': 'application/json',
|
|
213
214
|
...config?.headers
|
|
214
215
|
},
|
|
215
|
-
body: JSON.stringify(data)
|
|
216
|
+
body: isFormData ? data : JSON.stringify(data)
|
|
216
217
|
});
|
|
217
218
|
return { data: await response.json() };
|
|
218
219
|
},
|