@axiom-lattice/client-sdk 1.0.44 → 1.0.46
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/ChunkMessageMerger.js +1 -1
- package/dist/ChunkMessageMerger.js.map +1 -1
- package/dist/abstract-client.d.ts.map +1 -1
- package/dist/abstract-client.js +5 -3
- package/dist/abstract-client.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +36 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -32
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/wechat-client.d.ts +3 -3
- package/dist/wechat-client.d.ts.map +1 -1
- package/dist/wechat-client.js +34 -38
- package/dist/wechat-client.js.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1885,15 +1885,24 @@ var AbstractClient = class {
|
|
|
1885
1885
|
* @returns A function that can be called to stop the stream
|
|
1886
1886
|
*/
|
|
1887
1887
|
stream: (options, onEvent, onComplete, onError) => {
|
|
1888
|
+
const {
|
|
1889
|
+
command,
|
|
1890
|
+
threadId,
|
|
1891
|
+
files,
|
|
1892
|
+
background,
|
|
1893
|
+
enableReturnStateWhenSteamCompleted,
|
|
1894
|
+
...rest
|
|
1895
|
+
} = options;
|
|
1888
1896
|
const message = options.messages[options.messages.length - 1];
|
|
1889
1897
|
return this.streamRequest(
|
|
1890
1898
|
{
|
|
1891
1899
|
threadId: options.threadId,
|
|
1892
1900
|
message: typeof message.content === "string" ? message.content : JSON.stringify(message.content),
|
|
1893
1901
|
streaming: true,
|
|
1894
|
-
command
|
|
1895
|
-
background
|
|
1896
|
-
enableReturnStateWhenSteamCompleted
|
|
1902
|
+
command,
|
|
1903
|
+
background,
|
|
1904
|
+
enableReturnStateWhenSteamCompleted,
|
|
1905
|
+
...rest
|
|
1897
1906
|
},
|
|
1898
1907
|
onEvent,
|
|
1899
1908
|
onComplete,
|
|
@@ -2426,14 +2435,14 @@ var WeChatClient = class extends AbstractClient {
|
|
|
2426
2435
|
headers["x-tenant-id"] = this.tenantId;
|
|
2427
2436
|
}
|
|
2428
2437
|
const requestParams = this.buildStreamRequestParams(options);
|
|
2429
|
-
const
|
|
2438
|
+
const requestTask = wx.request({
|
|
2430
2439
|
url: `${this.config.baseURL}${requestParams.url}`,
|
|
2431
2440
|
method: requestParams.method,
|
|
2432
2441
|
data: requestParams.body,
|
|
2433
2442
|
header: headers,
|
|
2434
2443
|
responseType: "text",
|
|
2435
2444
|
enableChunked: true,
|
|
2436
|
-
success:
|
|
2445
|
+
success: () => {
|
|
2437
2446
|
},
|
|
2438
2447
|
fail: (err) => {
|
|
2439
2448
|
if (onError) {
|
|
@@ -2453,35 +2462,30 @@ var WeChatClient = class extends AbstractClient {
|
|
|
2453
2462
|
onComplete();
|
|
2454
2463
|
}
|
|
2455
2464
|
}
|
|
2456
|
-
}
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
}
|
|
2465
|
+
}
|
|
2466
|
+
});
|
|
2467
|
+
requestTask.onChunkReceived((res) => {
|
|
2468
|
+
if (!res.data)
|
|
2469
|
+
return;
|
|
2470
|
+
const text = this.decodeUint8Array(res.data);
|
|
2471
|
+
const lines = text.split("\n");
|
|
2472
|
+
for (const line of lines) {
|
|
2473
|
+
if (line.trim().startsWith("data: ")) {
|
|
2474
|
+
try {
|
|
2475
|
+
const eventData = JSON.parse(line.trim().slice(6));
|
|
2476
|
+
onEvent(eventData);
|
|
2477
|
+
} catch (error) {
|
|
2478
|
+
if (onError) {
|
|
2479
|
+
onError(
|
|
2480
|
+
error instanceof Error ? error : new Error(String(error))
|
|
2481
|
+
);
|
|
2474
2482
|
}
|
|
2475
2483
|
}
|
|
2476
2484
|
}
|
|
2477
2485
|
}
|
|
2478
2486
|
});
|
|
2479
2487
|
return () => {
|
|
2480
|
-
|
|
2481
|
-
requestId: taskId,
|
|
2482
|
-
success: () => console.log("Stream request aborted"),
|
|
2483
|
-
fail: (err) => console.error("Failed to abort stream request:", err.errMsg)
|
|
2484
|
-
});
|
|
2488
|
+
requestTask.abort();
|
|
2485
2489
|
};
|
|
2486
2490
|
}
|
|
2487
2491
|
decodeUint8Array(uint8Array) {
|
|
@@ -2496,9 +2500,9 @@ var WeChatClient = class extends AbstractClient {
|
|
|
2496
2500
|
).join("");
|
|
2497
2501
|
}
|
|
2498
2502
|
/**
|
|
2499
|
-
*
|
|
2500
|
-
* @param {String} hex
|
|
2501
|
-
* @return {String}
|
|
2503
|
+
* Convert hexadecimal string to text (supports Chinese characters)
|
|
2504
|
+
* @param {String} hex - Hexadecimal string
|
|
2505
|
+
* @return {String} Decoded string including Chinese characters
|
|
2502
2506
|
*/
|
|
2503
2507
|
hexToStr(hex) {
|
|
2504
2508
|
let trimedStr = hex.trim();
|
|
@@ -2699,7 +2703,7 @@ function createSimpleMessageMerger() {
|
|
|
2699
2703
|
);
|
|
2700
2704
|
}
|
|
2701
2705
|
function reset() {
|
|
2702
|
-
messages
|
|
2706
|
+
messages = [];
|
|
2703
2707
|
messageMap.clear();
|
|
2704
2708
|
toolBuilders.clear();
|
|
2705
2709
|
}
|