@assistant-ui/react 0.5.26 → 0.5.28
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{chunk-NSPHKRLF.js → chunk-KIP52R4W.js} +35 -2
- package/dist/chunk-KIP52R4W.js.map +1 -0
- package/dist/{chunk-ZWRFAYHH.mjs → chunk-NLH52OUL.mjs} +34 -1
- package/dist/chunk-NLH52OUL.mjs.map +1 -0
- package/dist/edge.js +58 -31
- package/dist/edge.js.map +1 -1
- package/dist/edge.mjs +58 -31
- package/dist/edge.mjs.map +1 -1
- package/dist/index.d.mts +29 -1
- package/dist/index.d.ts +29 -1
- package/dist/index.js +62 -40
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -36
- package/dist/index.mjs.map +1 -1
- package/dist/styles/index.css +0 -1
- package/dist/styles/index.css.map +1 -1
- package/dist/styles/tailwindcss/base-components.css +1 -1
- package/package.json +7 -7
- package/dist/chunk-NSPHKRLF.js.map +0 -1
- package/dist/chunk-ZWRFAYHH.mjs.map +0 -1
package/dist/index.mjs
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
"use client";
|
2
2
|
import {
|
3
|
+
PipeableTransformStream,
|
3
4
|
mergeModelConfigs,
|
4
5
|
runResultStream,
|
6
|
+
streamPartEncoderStream,
|
5
7
|
toCoreMessage,
|
6
8
|
toCoreMessages,
|
7
9
|
toLanguageModelMessages,
|
8
10
|
toLanguageModelTools,
|
9
11
|
toolResultStream
|
10
|
-
} from "./chunk-
|
12
|
+
} from "./chunk-NLH52OUL.mjs";
|
11
13
|
import {
|
12
14
|
__export
|
13
15
|
} from "./chunk-BJPOCE4O.mjs";
|
@@ -2524,6 +2526,52 @@ var fromLanguageModelTools = (tools) => {
|
|
2524
2526
|
);
|
2525
2527
|
};
|
2526
2528
|
|
2529
|
+
// src/runtimes/edge/streams/utils/chunkByLineStream.ts
|
2530
|
+
function chunkByLineStream() {
|
2531
|
+
let buffer = "";
|
2532
|
+
return new TransformStream({
|
2533
|
+
transform(chunk, controller) {
|
2534
|
+
buffer += chunk;
|
2535
|
+
const lines = buffer.split("\n");
|
2536
|
+
for (let i = 0; i < lines.length - 1; i++) {
|
2537
|
+
controller.enqueue(lines[i]);
|
2538
|
+
}
|
2539
|
+
buffer = lines[lines.length - 1];
|
2540
|
+
},
|
2541
|
+
flush(controller) {
|
2542
|
+
if (buffer) {
|
2543
|
+
controller.enqueue(buffer);
|
2544
|
+
}
|
2545
|
+
}
|
2546
|
+
});
|
2547
|
+
}
|
2548
|
+
|
2549
|
+
// src/runtimes/edge/streams/utils/streamPartDecoderStream.ts
|
2550
|
+
var decodeStreamPart = (part) => {
|
2551
|
+
const index = part.indexOf(":");
|
2552
|
+
if (index === -1) throw new Error("Invalid stream part");
|
2553
|
+
return {
|
2554
|
+
type: part.slice(0, index),
|
2555
|
+
value: JSON.parse(part.slice(index + 1))
|
2556
|
+
};
|
2557
|
+
};
|
2558
|
+
function streamPartDecoderStream() {
|
2559
|
+
const decodeStream = new TransformStream({
|
2560
|
+
transform(chunk, controller) {
|
2561
|
+
controller.enqueue(decodeStreamPart(chunk));
|
2562
|
+
}
|
2563
|
+
});
|
2564
|
+
return new PipeableTransformStream((readable) => {
|
2565
|
+
return readable.pipeThrough(new TextDecoderStream()).pipeThrough(chunkByLineStream()).pipeThrough(decodeStream);
|
2566
|
+
});
|
2567
|
+
}
|
2568
|
+
|
2569
|
+
// src/runtimes/edge/streams/utils/index.ts
|
2570
|
+
var streamUtils = {
|
2571
|
+
streamPartEncoderStream,
|
2572
|
+
streamPartDecoderStream
|
2573
|
+
};
|
2574
|
+
|
2527
2575
|
// src/runtimes/edge/useEdgeRuntime.ts
|
2528
2576
|
import { useState as useState8 } from "react";
|
2529
2577
|
|
@@ -2532,9 +2580,8 @@ function assistantDecoderStream() {
|
|
2532
2580
|
const toolCallNames = /* @__PURE__ */ new Map();
|
2533
2581
|
let currentToolCall;
|
2534
2582
|
return new TransformStream({
|
2535
|
-
transform(
|
2536
|
-
|
2537
|
-
if (currentToolCall && code !== "2" /* ToolCallArgsTextDelta */ && code !== "E" /* Error */) {
|
2583
|
+
transform({ type, value }, controller) {
|
2584
|
+
if (currentToolCall && type !== "2" /* ToolCallArgsTextDelta */ && type !== "E" /* Error */) {
|
2538
2585
|
controller.enqueue({
|
2539
2586
|
type: "tool-call",
|
2540
2587
|
toolCallType: "function",
|
@@ -2544,7 +2591,7 @@ function assistantDecoderStream() {
|
|
2544
2591
|
});
|
2545
2592
|
currentToolCall = void 0;
|
2546
2593
|
}
|
2547
|
-
switch (
|
2594
|
+
switch (type) {
|
2548
2595
|
case "0" /* TextDelta */: {
|
2549
2596
|
controller.enqueue({
|
2550
2597
|
type: "text-delta",
|
@@ -2595,41 +2642,13 @@ function assistantDecoderStream() {
|
|
2595
2642
|
break;
|
2596
2643
|
}
|
2597
2644
|
default: {
|
2598
|
-
const unhandledType =
|
2645
|
+
const unhandledType = type;
|
2599
2646
|
throw new Error(`Unhandled chunk type: ${unhandledType}`);
|
2600
2647
|
}
|
2601
2648
|
}
|
2602
2649
|
}
|
2603
2650
|
});
|
2604
2651
|
}
|
2605
|
-
var parseStreamPart = (part) => {
|
2606
|
-
const index = part.indexOf(":");
|
2607
|
-
if (index === -1) throw new Error("Invalid stream part");
|
2608
|
-
return [
|
2609
|
-
part.slice(0, index),
|
2610
|
-
JSON.parse(part.slice(index + 1))
|
2611
|
-
];
|
2612
|
-
};
|
2613
|
-
|
2614
|
-
// src/runtimes/edge/streams/chunkByLineStream.ts
|
2615
|
-
function chunkByLineStream() {
|
2616
|
-
let buffer = "";
|
2617
|
-
return new TransformStream({
|
2618
|
-
transform(chunk, controller) {
|
2619
|
-
buffer += chunk;
|
2620
|
-
const lines = buffer.split("\n");
|
2621
|
-
for (let i = 0; i < lines.length - 1; i++) {
|
2622
|
-
controller.enqueue(lines[i]);
|
2623
|
-
}
|
2624
|
-
buffer = lines[lines.length - 1];
|
2625
|
-
},
|
2626
|
-
flush(controller) {
|
2627
|
-
if (buffer) {
|
2628
|
-
controller.enqueue(buffer);
|
2629
|
-
}
|
2630
|
-
}
|
2631
|
-
});
|
2632
|
-
}
|
2633
2652
|
|
2634
2653
|
// src/runtimes/edge/EdgeChatAdapter.ts
|
2635
2654
|
function asAsyncIterable(source) {
|
@@ -2667,7 +2686,7 @@ var EdgeChatAdapter = class {
|
|
2667
2686
|
if (result.status !== 200) {
|
2668
2687
|
throw new Error(`Status ${result.status}: ${await result.text()}`);
|
2669
2688
|
}
|
2670
|
-
const stream = result.body.pipeThrough(
|
2689
|
+
const stream = result.body.pipeThrough(streamPartDecoderStream()).pipeThrough(assistantDecoderStream()).pipeThrough(toolResultStream(config.tools)).pipeThrough(runResultStream());
|
2671
2690
|
let update;
|
2672
2691
|
for await (update of asAsyncIterable(stream)) {
|
2673
2692
|
yield update;
|
@@ -3865,7 +3884,9 @@ AssistantModalContent.displayName = "AssistantModalContent";
|
|
3865
3884
|
var exports11 = {
|
3866
3885
|
Root: AssistantModalRoot,
|
3867
3886
|
Trigger: AssistantModalTrigger,
|
3868
|
-
Content: AssistantModalContent
|
3887
|
+
Content: AssistantModalContent,
|
3888
|
+
Button: AssistantModalButton,
|
3889
|
+
Anchor: AssistantModalAnchor
|
3869
3890
|
};
|
3870
3891
|
var assistant_modal_default = Object.assign(AssistantModal, exports11);
|
3871
3892
|
export {
|
@@ -3899,6 +3920,7 @@ export {
|
|
3899
3920
|
getExternalStoreMessage,
|
3900
3921
|
makeAssistantTool,
|
3901
3922
|
makeAssistantToolUI,
|
3923
|
+
streamUtils,
|
3902
3924
|
toCoreMessage,
|
3903
3925
|
toCoreMessages,
|
3904
3926
|
toLanguageModelMessages,
|