@assistant-ui/react 0.5.55 → 0.5.57
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.mts +44 -17
- package/dist/index.d.ts +44 -17
- package/dist/index.js +19 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
@@ -157,6 +157,7 @@ var makeThreadComposerStore = (useThreadRuntime2) => {
|
|
157
157
|
setValue(value) {
|
158
158
|
get().setText(value);
|
159
159
|
},
|
160
|
+
attachmentAccept: runtime.composer.attachmentAccept,
|
160
161
|
attachments: runtime.composer.attachments,
|
161
162
|
addAttachment: (file) => {
|
162
163
|
useThreadRuntime2.getState().composer.addAttachment(file);
|
@@ -1835,23 +1836,24 @@ var ExternalStoreRuntime = class extends BaseAssistantRuntime {
|
|
1835
1836
|
return this._proxyConfigProvider.registerModelConfigProvider(provider);
|
1836
1837
|
}
|
1837
1838
|
async switchToNewThread() {
|
1838
|
-
if (!this.store.
|
1839
|
+
if (!this.store.onSwitchToNewThread)
|
1839
1840
|
throw new Error("Runtime does not support switching to new threads.");
|
1840
1841
|
this.thread = new ExternalStoreThreadRuntime({
|
1841
|
-
|
1842
|
-
|
1842
|
+
...this.store,
|
1843
|
+
messages: []
|
1843
1844
|
});
|
1844
|
-
await this.store.
|
1845
|
+
await this.store.onSwitchToNewThread();
|
1845
1846
|
}
|
1846
1847
|
async switchToThread(threadId) {
|
1847
1848
|
if (threadId !== null) {
|
1848
|
-
if (!this.store.
|
1849
|
+
if (!this.store.onSwitchToThread)
|
1849
1850
|
throw new Error("Runtime does not support switching threads.");
|
1850
1851
|
this.thread = new ExternalStoreThreadRuntime({
|
1851
|
-
|
1852
|
-
|
1852
|
+
...this.store,
|
1853
|
+
messages: []
|
1854
|
+
// ignore messages until rerender
|
1853
1855
|
});
|
1854
|
-
this.store.
|
1856
|
+
this.store.onSwitchToThread(threadId);
|
1855
1857
|
} else {
|
1856
1858
|
this.switchToNewThread();
|
1857
1859
|
}
|
@@ -2266,10 +2268,11 @@ var ThreadProvider = ({
|
|
2266
2268
|
);
|
2267
2269
|
}
|
2268
2270
|
const composerState = context.useComposer.getState();
|
2269
|
-
if (thread.composer.isEmpty !== composerState.isEmpty || thread.composer.text !== composerState.text || thread.composer.attachments !== composerState.attachments || state.capabilities.cancel !== composerState.canCancel) {
|
2271
|
+
if (thread.composer.isEmpty !== composerState.isEmpty || thread.composer.text !== composerState.text || thread.composer.attachmentAccept !== composerState.attachmentAccept || thread.composer.attachments !== composerState.attachments || state.capabilities.cancel !== composerState.canCancel) {
|
2270
2272
|
writableStore(context.useComposer).setState({
|
2271
2273
|
isEmpty: thread.composer.isEmpty,
|
2272
2274
|
text: thread.composer.text,
|
2275
|
+
attachmentAccept: thread.composer.attachmentAccept,
|
2273
2276
|
attachments: thread.composer.attachments,
|
2274
2277
|
canCancel: state.capabilities.cancel
|
2275
2278
|
});
|
@@ -2298,6 +2301,7 @@ import { create as create9 } from "zustand";
|
|
2298
2301
|
var makeAssistantActionsStore = (runtimeRef) => create9(
|
2299
2302
|
() => Object.freeze({
|
2300
2303
|
switchToThread: () => runtimeRef.current.switchToThread(null),
|
2304
|
+
switchToNewThread: () => runtimeRef.current.switchToNewThread(),
|
2301
2305
|
registerModelConfigProvider: (provider) => runtimeRef.current.registerModelConfigProvider(provider),
|
2302
2306
|
getRuntime: () => runtimeRef.current
|
2303
2307
|
})
|
@@ -2441,7 +2445,7 @@ var useSwitchToNewThread = () => {
|
|
2441
2445
|
const assistantActionsStore = useAssistantActionsStore();
|
2442
2446
|
const threadComposerStore = useThreadComposerStore();
|
2443
2447
|
const switchToNewThread = useCallback2(() => {
|
2444
|
-
assistantActionsStore.getState().
|
2448
|
+
assistantActionsStore.getState().switchToNewThread();
|
2445
2449
|
threadComposerStore.getState().focus();
|
2446
2450
|
}, [assistantActionsStore, threadComposerStore]);
|
2447
2451
|
return switchToNewThread;
|
@@ -2504,13 +2508,13 @@ var makeAssistantToolUI = (tool) => {
|
|
2504
2508
|
// src/model-config/useAssistantInstructions.tsx
|
2505
2509
|
import { useEffect as useEffect7 } from "react";
|
2506
2510
|
var useAssistantInstructions = (instruction) => {
|
2507
|
-
const
|
2511
|
+
const actionsStore = useAssistantActionsStore();
|
2508
2512
|
useEffect7(() => {
|
2509
2513
|
const config = {
|
2510
2514
|
system: instruction
|
2511
2515
|
};
|
2512
|
-
return
|
2513
|
-
}, [
|
2516
|
+
return actionsStore.getState().registerModelConfigProvider({ getModelConfig: () => config });
|
2517
|
+
}, [actionsStore, instruction]);
|
2514
2518
|
};
|
2515
2519
|
|
2516
2520
|
// src/primitive-hooks/actionBar/useActionBarCopy.tsx
|
@@ -2740,10 +2744,10 @@ import { useCallback as useCallback12 } from "react";
|
|
2740
2744
|
var useComposerAddAttachment = () => {
|
2741
2745
|
const disabled = useComposer((c) => !c.isEditing);
|
2742
2746
|
const threadComposerStore = useThreadComposerStore();
|
2743
|
-
const threadRuntimeStore =
|
2747
|
+
const threadRuntimeStore = useThreadComposerStore();
|
2744
2748
|
const callback = useCallback12(() => {
|
2745
2749
|
const { addAttachment } = threadComposerStore.getState();
|
2746
|
-
const { attachmentAccept } = threadRuntimeStore.getState()
|
2750
|
+
const { attachmentAccept } = threadRuntimeStore.getState();
|
2747
2751
|
const input = document.createElement("input");
|
2748
2752
|
input.type = "file";
|
2749
2753
|
if (attachmentAccept !== "*") {
|