@assistant-ui/react 0.5.36 → 0.5.37
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +58 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -9
- package/dist/index.mjs.map +1 -1
- package/dist/styles/index.css +8 -0
- package/dist/styles/index.css.map +1 -1
- package/dist/styles/tailwindcss/thread.css +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
@@ -1298,6 +1298,19 @@ var LocalRuntime = class extends BaseAssistantRuntime {
|
|
1298
1298
|
this.thread.adapter
|
1299
1299
|
);
|
1300
1300
|
}
|
1301
|
+
reset({
|
1302
|
+
initialMessages
|
1303
|
+
} = {}) {
|
1304
|
+
this.switchToThread(null);
|
1305
|
+
if (!initialMessages) return;
|
1306
|
+
const messages = fromCoreMessages(initialMessages);
|
1307
|
+
this.thread.import({
|
1308
|
+
messages: messages.map((m, idx) => ({
|
1309
|
+
parentId: messages[idx - 1]?.id ?? null,
|
1310
|
+
message: m
|
1311
|
+
}))
|
1312
|
+
});
|
1313
|
+
}
|
1301
1314
|
};
|
1302
1315
|
|
1303
1316
|
// src/runtimes/local/useLocalRuntime.tsx
|
@@ -1723,6 +1736,12 @@ var makeAssistantActionsStore = (runtimeRef) => create10(
|
|
1723
1736
|
})
|
1724
1737
|
);
|
1725
1738
|
|
1739
|
+
// src/context/stores/AssistantRuntime.tsx
|
1740
|
+
import { create as create11 } from "zustand";
|
1741
|
+
var makeAssistantRuntimeStore = (runtime) => {
|
1742
|
+
return create11(() => runtime);
|
1743
|
+
};
|
1744
|
+
|
1726
1745
|
// src/context/providers/AssistantProvider.tsx
|
1727
1746
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
1728
1747
|
var AssistantProvider = ({ children, runtime }) => {
|
@@ -1731,15 +1750,25 @@ var AssistantProvider = ({ children, runtime }) => {
|
|
1731
1750
|
runtimeRef.current = runtime;
|
1732
1751
|
});
|
1733
1752
|
const [context] = useState8(() => {
|
1753
|
+
const useAssistantRuntime = makeAssistantRuntimeStore(runtime);
|
1734
1754
|
const useModelConfig = makeAssistantModelConfigStore();
|
1735
1755
|
const useToolUIs = makeAssistantToolUIsStore();
|
1736
1756
|
const useAssistantActions = makeAssistantActionsStore(runtimeRef);
|
1737
|
-
return {
|
1757
|
+
return {
|
1758
|
+
useModelConfig,
|
1759
|
+
useToolUIs,
|
1760
|
+
useAssistantRuntime,
|
1761
|
+
useAssistantActions
|
1762
|
+
};
|
1738
1763
|
});
|
1739
1764
|
const getModelConfig = context.useModelConfig();
|
1740
1765
|
useEffect4(() => {
|
1741
1766
|
return runtime.registerModelConfigProvider(getModelConfig);
|
1742
1767
|
}, [runtime, getModelConfig]);
|
1768
|
+
useEffect4(
|
1769
|
+
() => context.useAssistantRuntime.setState(runtime, true),
|
1770
|
+
[runtime, context]
|
1771
|
+
);
|
1743
1772
|
return /* @__PURE__ */ jsx7(AssistantContext.Provider, { value: context, children: /* @__PURE__ */ jsx7(ThreadProvider, { provider: runtime, children }) });
|
1744
1773
|
};
|
1745
1774
|
|
@@ -2561,7 +2590,7 @@ import { memo as memo2 } from "react";
|
|
2561
2590
|
|
2562
2591
|
// src/context/providers/ContentPartProvider.tsx
|
2563
2592
|
import { useEffect as useEffect9, useState as useState10 } from "react";
|
2564
|
-
import { create as
|
2593
|
+
import { create as create12 } from "zustand";
|
2565
2594
|
import { jsx as jsx18 } from "react/jsx-runtime";
|
2566
2595
|
var COMPLETE_STATUS = {
|
2567
2596
|
type: "complete"
|
@@ -2600,7 +2629,7 @@ var getContentPartState = ({ message }, useContentPart, partIndex) => {
|
|
2600
2629
|
var useContentPartContext2 = (partIndex) => {
|
2601
2630
|
const { useMessage } = useMessageContext();
|
2602
2631
|
const [context] = useState10(() => {
|
2603
|
-
const useContentPart =
|
2632
|
+
const useContentPart = create12(
|
2604
2633
|
() => getContentPartState(useMessage.getState(), void 0, partIndex)
|
2605
2634
|
);
|
2606
2635
|
return { useContentPart };
|
@@ -3108,14 +3137,14 @@ import { memo as memo3 } from "react";
|
|
3108
3137
|
|
3109
3138
|
// src/context/providers/MessageProvider.tsx
|
3110
3139
|
import { useEffect as useEffect12, useState as useState11 } from "react";
|
3111
|
-
import { create as
|
3140
|
+
import { create as create15 } from "zustand";
|
3112
3141
|
|
3113
3142
|
// src/context/stores/EditComposer.ts
|
3114
|
-
import { create as
|
3143
|
+
import { create as create13 } from "zustand";
|
3115
3144
|
var makeEditComposerStore = ({
|
3116
3145
|
onEdit,
|
3117
3146
|
onSend
|
3118
|
-
}) =>
|
3147
|
+
}) => create13()((set, get) => ({
|
3119
3148
|
get value() {
|
3120
3149
|
return get().text;
|
3121
3150
|
},
|
@@ -3143,8 +3172,8 @@ var makeEditComposerStore = ({
|
|
3143
3172
|
}));
|
3144
3173
|
|
3145
3174
|
// src/context/stores/MessageUtils.ts
|
3146
|
-
import { create as
|
3147
|
-
var makeMessageUtilsStore = () =>
|
3175
|
+
import { create as create14 } from "zustand";
|
3176
|
+
var makeMessageUtilsStore = () => create14((set) => ({
|
3148
3177
|
isCopied: false,
|
3149
3178
|
setIsCopied: (value) => {
|
3150
3179
|
set({ isCopied: value });
|
@@ -3179,7 +3208,7 @@ var getMessageState = (messages, getBranches, useMessage, messageIndex) => {
|
|
3179
3208
|
var useMessageContext2 = (messageIndex) => {
|
3180
3209
|
const { useThreadMessages, useThreadActions } = useThreadContext();
|
3181
3210
|
const [context] = useState11(() => {
|
3182
|
-
const useMessage =
|
3211
|
+
const useMessage = create15(
|
3183
3212
|
() => getMessageState(
|
3184
3213
|
useThreadMessages.getState(),
|
3185
3214
|
useThreadActions.getState().getBranches,
|