@assistant-ui/react 0.5.71 → 0.5.73
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/{chunk-5KIEXJRK.js → chunk-KVXP3Q6K.js} +60 -21
- package/dist/chunk-KVXP3Q6K.js.map +1 -0
- package/dist/{chunk-DC342I2Q.mjs → chunk-SNNYBBO6.mjs} +57 -18
- package/dist/chunk-SNNYBBO6.mjs.map +1 -0
- package/dist/{edge-DRioHVD9.d.mts → edge-rTP-G718.d.mts} +17 -6
- package/dist/{edge-DRioHVD9.d.ts → edge-rTP-G718.d.ts} +17 -6
- package/dist/edge.d.mts +9 -2
- package/dist/edge.d.ts +9 -2
- package/dist/edge.js +56 -17
- package/dist/edge.js.map +1 -1
- package/dist/edge.mjs +56 -17
- package/dist/edge.mjs.map +1 -1
- package/dist/index.d.mts +28 -19
- package/dist/index.d.ts +28 -19
- package/dist/index.js +131 -96
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +86 -51
- package/dist/index.mjs.map +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/styles/index.css.map +1 -1
- package/dist/styles/tailwindcss/thread.css +1 -1
- package/package.json +4 -4
- package/dist/chunk-5KIEXJRK.js.map +0 -1
- package/dist/chunk-DC342I2Q.mjs.map +0 -1
package/dist/index.mjs
CHANGED
@@ -10,7 +10,7 @@ import {
|
|
10
10
|
toLanguageModelMessages,
|
11
11
|
toLanguageModelTools,
|
12
12
|
toolResultStream
|
13
|
-
} from "./chunk-
|
13
|
+
} from "./chunk-SNNYBBO6.mjs";
|
14
14
|
import {
|
15
15
|
__export
|
16
16
|
} from "./chunk-BJPOCE4O.mjs";
|
@@ -3688,7 +3688,7 @@ var ThreadRuntimeImpl = class {
|
|
3688
3688
|
};
|
3689
3689
|
|
3690
3690
|
// src/runtimes/edge/converters/fromLanguageModelMessages.ts
|
3691
|
-
var fromLanguageModelMessages = (lm, {
|
3691
|
+
var fromLanguageModelMessages = (lm, { mergeSteps }) => {
|
3692
3692
|
const messages2 = [];
|
3693
3693
|
for (const lmMessage of lm) {
|
3694
3694
|
const role = lmMessage.role;
|
@@ -3751,7 +3751,7 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
|
|
3751
3751
|
}
|
3752
3752
|
return part;
|
3753
3753
|
});
|
3754
|
-
if (
|
3754
|
+
if (mergeSteps) {
|
3755
3755
|
const previousMessage = messages2[messages2.length - 1];
|
3756
3756
|
if (previousMessage?.role === "assistant") {
|
3757
3757
|
previousMessage.content.push(...newContent);
|
@@ -3862,7 +3862,7 @@ function assistantDecoderStream() {
|
|
3862
3862
|
let currentToolCall;
|
3863
3863
|
return new TransformStream({
|
3864
3864
|
transform({ type, value }, controller) {
|
3865
|
-
if (currentToolCall && type !== "
|
3865
|
+
if (currentToolCall && type !== "c" /* ToolCallDelta */ && type !== "3" /* Error */) {
|
3866
3866
|
controller.enqueue({
|
3867
3867
|
type: "tool-call",
|
3868
3868
|
toolCallType: "function",
|
@@ -3880,48 +3880,82 @@ function assistantDecoderStream() {
|
|
3880
3880
|
});
|
3881
3881
|
break;
|
3882
3882
|
}
|
3883
|
-
case "
|
3884
|
-
const { id, name } = value;
|
3883
|
+
case "b" /* ToolCallBegin */: {
|
3884
|
+
const { toolCallId: id, toolName: name } = value;
|
3885
3885
|
toolCallNames.set(id, name);
|
3886
3886
|
currentToolCall = { id, name, argsText: "" };
|
3887
3887
|
break;
|
3888
3888
|
}
|
3889
|
-
case "
|
3890
|
-
const
|
3891
|
-
currentToolCall
|
3889
|
+
case "c" /* ToolCallDelta */: {
|
3890
|
+
const { toolCallId, argsTextDelta } = value;
|
3891
|
+
if (currentToolCall?.id !== toolCallId) {
|
3892
|
+
throw new Error(
|
3893
|
+
`Received tool call delta for unknown tool call "${toolCallId}".`
|
3894
|
+
);
|
3895
|
+
}
|
3896
|
+
currentToolCall.argsText += argsTextDelta;
|
3892
3897
|
controller.enqueue({
|
3893
3898
|
type: "tool-call-delta",
|
3894
3899
|
toolCallType: "function",
|
3895
3900
|
toolCallId: currentToolCall.id,
|
3896
3901
|
toolName: currentToolCall.name,
|
3897
|
-
argsTextDelta
|
3902
|
+
argsTextDelta
|
3898
3903
|
});
|
3899
3904
|
break;
|
3900
3905
|
}
|
3901
|
-
case "
|
3906
|
+
case "a" /* ToolCallResult */: {
|
3902
3907
|
controller.enqueue({
|
3903
3908
|
type: "tool-result",
|
3904
3909
|
toolCallType: "function",
|
3905
|
-
toolCallId: value.
|
3906
|
-
toolName: toolCallNames.get(value.
|
3910
|
+
toolCallId: value.toolCallId,
|
3911
|
+
toolName: toolCallNames.get(value.toolCallId),
|
3907
3912
|
result: value.result
|
3908
3913
|
});
|
3909
3914
|
break;
|
3910
3915
|
}
|
3911
|
-
case "
|
3916
|
+
case "d" /* Finish */: {
|
3912
3917
|
controller.enqueue({
|
3913
3918
|
type: "finish",
|
3914
3919
|
...value
|
3915
3920
|
});
|
3916
3921
|
break;
|
3917
3922
|
}
|
3918
|
-
case "
|
3923
|
+
case "3" /* Error */: {
|
3919
3924
|
controller.enqueue({
|
3920
3925
|
type: "error",
|
3921
3926
|
error: value
|
3922
3927
|
});
|
3923
3928
|
break;
|
3924
3929
|
}
|
3930
|
+
case "9" /* ToolCall */: {
|
3931
|
+
const { toolCallId, toolName, args } = value;
|
3932
|
+
const argsText = JSON.stringify(args);
|
3933
|
+
controller.enqueue({
|
3934
|
+
type: "tool-call-delta",
|
3935
|
+
toolCallType: "function",
|
3936
|
+
toolCallId,
|
3937
|
+
toolName,
|
3938
|
+
argsTextDelta: argsText
|
3939
|
+
});
|
3940
|
+
controller.enqueue({
|
3941
|
+
type: "tool-call",
|
3942
|
+
toolCallType: "function",
|
3943
|
+
toolCallId,
|
3944
|
+
toolName,
|
3945
|
+
args: argsText
|
3946
|
+
});
|
3947
|
+
break;
|
3948
|
+
}
|
3949
|
+
case "e" /* StepFinish */: {
|
3950
|
+
controller.enqueue({
|
3951
|
+
type: "step-finish",
|
3952
|
+
...value
|
3953
|
+
});
|
3954
|
+
break;
|
3955
|
+
}
|
3956
|
+
// TODO
|
3957
|
+
case "2" /* Data */:
|
3958
|
+
break;
|
3925
3959
|
default: {
|
3926
3960
|
const unhandledType = type;
|
3927
3961
|
throw new Error(`Unhandled chunk type: ${unhandledType}`);
|
@@ -3979,19 +4013,25 @@ var EdgeChatAdapter = class {
|
|
3979
4013
|
}
|
3980
4014
|
};
|
3981
4015
|
|
4016
|
+
// src/runtimes/local/LocalRuntimeOptions.tsx
|
4017
|
+
var splitLocalRuntimeOptions = (options) => {
|
4018
|
+
const { initialMessages, maxToolRoundtrips, maxSteps, adapters, ...rest } = options;
|
4019
|
+
return {
|
4020
|
+
localRuntimeOptions: {
|
4021
|
+
initialMessages,
|
4022
|
+
maxToolRoundtrips,
|
4023
|
+
maxSteps,
|
4024
|
+
adapters
|
4025
|
+
},
|
4026
|
+
otherOptions: rest
|
4027
|
+
};
|
4028
|
+
};
|
4029
|
+
|
3982
4030
|
// src/runtimes/edge/useEdgeRuntime.ts
|
3983
|
-
var useEdgeRuntime = ({
|
3984
|
-
|
3985
|
-
|
3986
|
-
|
3987
|
-
...options
|
3988
|
-
}) => {
|
3989
|
-
const [adapter] = useState10(() => new EdgeChatAdapter(options));
|
3990
|
-
return useLocalRuntime(adapter, {
|
3991
|
-
initialMessages,
|
3992
|
-
maxToolRoundtrips,
|
3993
|
-
adapters
|
3994
|
-
});
|
4031
|
+
var useEdgeRuntime = (options) => {
|
4032
|
+
const { localRuntimeOptions, otherOptions } = splitLocalRuntimeOptions(options);
|
4033
|
+
const [adapter] = useState10(() => new EdgeChatAdapter(otherOptions));
|
4034
|
+
return useLocalRuntime(adapter, localRuntimeOptions);
|
3995
4035
|
};
|
3996
4036
|
|
3997
4037
|
// src/runtimes/local/shouldContinue.tsx
|
@@ -4156,29 +4196,21 @@ var LocalThreadRuntimeCore = class {
|
|
4156
4196
|
this.abortController?.abort();
|
4157
4197
|
this.abortController = new AbortController();
|
4158
4198
|
const initialContent = message.content;
|
4159
|
-
const
|
4199
|
+
const initialSteps = message.metadata?.steps;
|
4160
4200
|
const initalCustom = message.metadata?.custom;
|
4161
4201
|
const updateMessage = (m) => {
|
4202
|
+
const newSteps = m.metadata?.steps || m.metadata?.roundtrips;
|
4203
|
+
const steps2 = newSteps ? [...initialSteps ?? [], ...newSteps] : void 0;
|
4162
4204
|
message = {
|
4163
4205
|
...message,
|
4164
4206
|
...m.content ? { content: [...initialContent, ...m.content ?? []] } : void 0,
|
4165
4207
|
status: m.status ?? message.status,
|
4166
4208
|
// TODO deprecated, remove in v0.6
|
4167
|
-
...
|
4168
|
-
roundtrips: [
|
4169
|
-
...initialRoundtrips ?? [],
|
4170
|
-
...m.metadata.roundtrips
|
4171
|
-
]
|
4172
|
-
} : void 0,
|
4209
|
+
...steps2 ? { roundtrips: steps2 } : void 0,
|
4173
4210
|
...m.metadata ? {
|
4174
4211
|
metadata: {
|
4175
4212
|
...message.metadata,
|
4176
|
-
...
|
4177
|
-
roundtrips: [
|
4178
|
-
...initialRoundtrips ?? [],
|
4179
|
-
...m.metadata.roundtrips
|
4180
|
-
]
|
4181
|
-
} : void 0,
|
4213
|
+
...steps2 ? { roundtrips: steps2, steps: steps2 } : void 0,
|
4182
4214
|
...m.metadata?.custom ? {
|
4183
4215
|
custom: { ...initalCustom ?? {}, ...m.metadata.custom }
|
4184
4216
|
} : void 0
|
@@ -4188,9 +4220,9 @@ var LocalThreadRuntimeCore = class {
|
|
4188
4220
|
this.repository.addOrUpdateMessage(parentId, message);
|
4189
4221
|
this.notifySubscribers();
|
4190
4222
|
};
|
4191
|
-
const
|
4192
|
-
const
|
4193
|
-
if (
|
4223
|
+
const maxSteps = this.options.maxSteps ? this.options.maxSteps : (this.options.maxToolRoundtrips ?? 1) + 1;
|
4224
|
+
const steps = message.metadata?.steps?.length ?? 0;
|
4225
|
+
if (steps >= maxSteps) {
|
4194
4226
|
updateMessage({
|
4195
4227
|
status: {
|
4196
4228
|
type: "incomplete",
|
@@ -4921,12 +4953,10 @@ var DangerousInBrowserAdapter = class {
|
|
4921
4953
|
};
|
4922
4954
|
|
4923
4955
|
// src/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.ts
|
4924
|
-
var useDangerousInBrowserRuntime = ({
|
4925
|
-
|
4926
|
-
|
4927
|
-
|
4928
|
-
const [adapter] = useState13(() => new DangerousInBrowserAdapter(options));
|
4929
|
-
return useLocalRuntime(adapter, { initialMessages });
|
4956
|
+
var useDangerousInBrowserRuntime = (options) => {
|
4957
|
+
const { localRuntimeOptions, otherOptions } = splitLocalRuntimeOptions(options);
|
4958
|
+
const [adapter] = useState13(() => new DangerousInBrowserAdapter(otherOptions));
|
4959
|
+
return useLocalRuntime(adapter, localRuntimeOptions);
|
4930
4960
|
};
|
4931
4961
|
|
4932
4962
|
// src/runtimes/speech/WebSpeechSynthesisAdapter.ts
|
@@ -5917,9 +5947,14 @@ var edit_composer_default = Object.assign(EditComposer, exports11);
|
|
5917
5947
|
// src/ui/thread.tsx
|
5918
5948
|
import { Fragment as Fragment6, jsx as jsx49, jsxs as jsxs13 } from "react/jsx-runtime";
|
5919
5949
|
var Thread = (config) => {
|
5920
|
-
const {
|
5950
|
+
const {
|
5951
|
+
components: {
|
5952
|
+
Composer: ComposerComponent = composer_default,
|
5953
|
+
ThreadWelcome: ThreadWelcomeComponent = thread_welcome_default
|
5954
|
+
} = {}
|
5955
|
+
} = config;
|
5921
5956
|
return /* @__PURE__ */ jsx49(ThreadRoot, { config, children: /* @__PURE__ */ jsxs13(ThreadViewport, { children: [
|
5922
|
-
/* @__PURE__ */ jsx49(
|
5957
|
+
/* @__PURE__ */ jsx49(ThreadWelcomeComponent, {}),
|
5923
5958
|
/* @__PURE__ */ jsx49(ThreadMessages, {}),
|
5924
5959
|
/* @__PURE__ */ jsx49(ThreadFollowupSuggestions, {}),
|
5925
5960
|
/* @__PURE__ */ jsxs13(ThreadViewportFooter, { children: [
|