@assistant-ui/react 0.5.55 → 0.5.56
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.mts +28 -9
- package/dist/index.d.ts +28 -9
- package/dist/index.js +14 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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,23 @@ 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
|
messages: [],
|
1842
1843
|
onNew: this.store.onNew
|
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
|
messages: [],
|
1852
1853
|
onNew: this.store.onNew
|
1853
1854
|
});
|
1854
|
-
this.store.
|
1855
|
+
this.store.onSwitchToThread(threadId);
|
1855
1856
|
} else {
|
1856
1857
|
this.switchToNewThread();
|
1857
1858
|
}
|
@@ -2266,10 +2267,11 @@ var ThreadProvider = ({
|
|
2266
2267
|
);
|
2267
2268
|
}
|
2268
2269
|
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) {
|
2270
|
+
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
2271
|
writableStore(context.useComposer).setState({
|
2271
2272
|
isEmpty: thread.composer.isEmpty,
|
2272
2273
|
text: thread.composer.text,
|
2274
|
+
attachmentAccept: thread.composer.attachmentAccept,
|
2273
2275
|
attachments: thread.composer.attachments,
|
2274
2276
|
canCancel: state.capabilities.cancel
|
2275
2277
|
});
|
@@ -2298,6 +2300,7 @@ import { create as create9 } from "zustand";
|
|
2298
2300
|
var makeAssistantActionsStore = (runtimeRef) => create9(
|
2299
2301
|
() => Object.freeze({
|
2300
2302
|
switchToThread: () => runtimeRef.current.switchToThread(null),
|
2303
|
+
switchToNewThread: () => runtimeRef.current.switchToNewThread(),
|
2301
2304
|
registerModelConfigProvider: (provider) => runtimeRef.current.registerModelConfigProvider(provider),
|
2302
2305
|
getRuntime: () => runtimeRef.current
|
2303
2306
|
})
|
@@ -2441,7 +2444,7 @@ var useSwitchToNewThread = () => {
|
|
2441
2444
|
const assistantActionsStore = useAssistantActionsStore();
|
2442
2445
|
const threadComposerStore = useThreadComposerStore();
|
2443
2446
|
const switchToNewThread = useCallback2(() => {
|
2444
|
-
assistantActionsStore.getState().
|
2447
|
+
assistantActionsStore.getState().switchToNewThread();
|
2445
2448
|
threadComposerStore.getState().focus();
|
2446
2449
|
}, [assistantActionsStore, threadComposerStore]);
|
2447
2450
|
return switchToNewThread;
|
@@ -2504,13 +2507,13 @@ var makeAssistantToolUI = (tool) => {
|
|
2504
2507
|
// src/model-config/useAssistantInstructions.tsx
|
2505
2508
|
import { useEffect as useEffect7 } from "react";
|
2506
2509
|
var useAssistantInstructions = (instruction) => {
|
2507
|
-
const
|
2510
|
+
const actionsStore = useAssistantActionsStore();
|
2508
2511
|
useEffect7(() => {
|
2509
2512
|
const config = {
|
2510
2513
|
system: instruction
|
2511
2514
|
};
|
2512
|
-
return
|
2513
|
-
}, [
|
2515
|
+
return actionsStore.getState().registerModelConfigProvider({ getModelConfig: () => config });
|
2516
|
+
}, [actionsStore, instruction]);
|
2514
2517
|
};
|
2515
2518
|
|
2516
2519
|
// src/primitive-hooks/actionBar/useActionBarCopy.tsx
|
@@ -2740,10 +2743,10 @@ import { useCallback as useCallback12 } from "react";
|
|
2740
2743
|
var useComposerAddAttachment = () => {
|
2741
2744
|
const disabled = useComposer((c) => !c.isEditing);
|
2742
2745
|
const threadComposerStore = useThreadComposerStore();
|
2743
|
-
const threadRuntimeStore =
|
2746
|
+
const threadRuntimeStore = useThreadComposerStore();
|
2744
2747
|
const callback = useCallback12(() => {
|
2745
2748
|
const { addAttachment } = threadComposerStore.getState();
|
2746
|
-
const { attachmentAccept } = threadRuntimeStore.getState()
|
2749
|
+
const { attachmentAccept } = threadRuntimeStore.getState();
|
2747
2750
|
const input = document.createElement("input");
|
2748
2751
|
input.type = "file";
|
2749
2752
|
if (attachmentAccept !== "*") {
|