@assistant-ui/react 0.5.72 → 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 +26 -17
- package/dist/index.d.ts +26 -17
- package/dist/index.js +116 -80
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +71 -35
- 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}`);
|
@@ -3981,9 +4015,14 @@ var EdgeChatAdapter = class {
|
|
3981
4015
|
|
3982
4016
|
// src/runtimes/local/LocalRuntimeOptions.tsx
|
3983
4017
|
var splitLocalRuntimeOptions = (options) => {
|
3984
|
-
const { initialMessages, maxToolRoundtrips, adapters, ...rest } = options;
|
4018
|
+
const { initialMessages, maxToolRoundtrips, maxSteps, adapters, ...rest } = options;
|
3985
4019
|
return {
|
3986
|
-
localRuntimeOptions: {
|
4020
|
+
localRuntimeOptions: {
|
4021
|
+
initialMessages,
|
4022
|
+
maxToolRoundtrips,
|
4023
|
+
maxSteps,
|
4024
|
+
adapters
|
4025
|
+
},
|
3987
4026
|
otherOptions: rest
|
3988
4027
|
};
|
3989
4028
|
};
|
@@ -4157,29 +4196,21 @@ var LocalThreadRuntimeCore = class {
|
|
4157
4196
|
this.abortController?.abort();
|
4158
4197
|
this.abortController = new AbortController();
|
4159
4198
|
const initialContent = message.content;
|
4160
|
-
const
|
4199
|
+
const initialSteps = message.metadata?.steps;
|
4161
4200
|
const initalCustom = message.metadata?.custom;
|
4162
4201
|
const updateMessage = (m) => {
|
4202
|
+
const newSteps = m.metadata?.steps || m.metadata?.roundtrips;
|
4203
|
+
const steps2 = newSteps ? [...initialSteps ?? [], ...newSteps] : void 0;
|
4163
4204
|
message = {
|
4164
4205
|
...message,
|
4165
4206
|
...m.content ? { content: [...initialContent, ...m.content ?? []] } : void 0,
|
4166
4207
|
status: m.status ?? message.status,
|
4167
4208
|
// TODO deprecated, remove in v0.6
|
4168
|
-
...
|
4169
|
-
roundtrips: [
|
4170
|
-
...initialRoundtrips ?? [],
|
4171
|
-
...m.metadata.roundtrips
|
4172
|
-
]
|
4173
|
-
} : void 0,
|
4209
|
+
...steps2 ? { roundtrips: steps2 } : void 0,
|
4174
4210
|
...m.metadata ? {
|
4175
4211
|
metadata: {
|
4176
4212
|
...message.metadata,
|
4177
|
-
...
|
4178
|
-
roundtrips: [
|
4179
|
-
...initialRoundtrips ?? [],
|
4180
|
-
...m.metadata.roundtrips
|
4181
|
-
]
|
4182
|
-
} : void 0,
|
4213
|
+
...steps2 ? { roundtrips: steps2, steps: steps2 } : void 0,
|
4183
4214
|
...m.metadata?.custom ? {
|
4184
4215
|
custom: { ...initalCustom ?? {}, ...m.metadata.custom }
|
4185
4216
|
} : void 0
|
@@ -4189,9 +4220,9 @@ var LocalThreadRuntimeCore = class {
|
|
4189
4220
|
this.repository.addOrUpdateMessage(parentId, message);
|
4190
4221
|
this.notifySubscribers();
|
4191
4222
|
};
|
4192
|
-
const
|
4193
|
-
const
|
4194
|
-
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) {
|
4195
4226
|
updateMessage({
|
4196
4227
|
status: {
|
4197
4228
|
type: "incomplete",
|
@@ -5916,9 +5947,14 @@ var edit_composer_default = Object.assign(EditComposer, exports11);
|
|
5916
5947
|
// src/ui/thread.tsx
|
5917
5948
|
import { Fragment as Fragment6, jsx as jsx49, jsxs as jsxs13 } from "react/jsx-runtime";
|
5918
5949
|
var Thread = (config) => {
|
5919
|
-
const {
|
5950
|
+
const {
|
5951
|
+
components: {
|
5952
|
+
Composer: ComposerComponent = composer_default,
|
5953
|
+
ThreadWelcome: ThreadWelcomeComponent = thread_welcome_default
|
5954
|
+
} = {}
|
5955
|
+
} = config;
|
5920
5956
|
return /* @__PURE__ */ jsx49(ThreadRoot, { config, children: /* @__PURE__ */ jsxs13(ThreadViewport, { children: [
|
5921
|
-
/* @__PURE__ */ jsx49(
|
5957
|
+
/* @__PURE__ */ jsx49(ThreadWelcomeComponent, {}),
|
5922
5958
|
/* @__PURE__ */ jsx49(ThreadMessages, {}),
|
5923
5959
|
/* @__PURE__ */ jsx49(ThreadFollowupSuggestions, {}),
|
5924
5960
|
/* @__PURE__ */ jsxs13(ThreadViewportFooter, { children: [
|