@assistant-ui/react 0.0.19 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.mts +33 -37
- package/dist/index.d.ts +33 -37
- package/dist/index.js +301 -383
- package/dist/index.mjs +311 -397
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
@@ -153,6 +153,15 @@ type AppendMessage = {
|
|
153
153
|
content: AppendContentPart[];
|
154
154
|
};
|
155
155
|
type ThreadMessage = UserMessage | AssistantMessage;
|
156
|
+
type ThreadState = {
|
157
|
+
messages: ThreadMessage[];
|
158
|
+
isRunning: boolean;
|
159
|
+
getBranches: (messageId: string) => readonly string[];
|
160
|
+
switchToBranch: (branchId: string) => void;
|
161
|
+
append: (message: AppendMessage) => void;
|
162
|
+
startRun: (parentId: string | null) => void;
|
163
|
+
cancelRun: () => void;
|
164
|
+
};
|
156
165
|
|
157
166
|
type MessageProviderProps = PropsWithChildren<{
|
158
167
|
message: ThreadMessage;
|
@@ -293,43 +302,34 @@ type VercelAIAssistantProviderProps = PropsWithChildren<{
|
|
293
302
|
}>;
|
294
303
|
declare const VercelAIAssistantProvider: FC<VercelAIAssistantProviderProps>;
|
295
304
|
|
305
|
+
type Unsubscribe = () => void;
|
306
|
+
type AssistantRuntime = Readonly<ThreadState> & {
|
307
|
+
subscribe: (callback: () => void) => Unsubscribe;
|
308
|
+
};
|
309
|
+
|
296
310
|
type VercelRSCMessage = {
|
297
311
|
id: string;
|
298
312
|
role: "user" | "assistant";
|
299
313
|
display: ReactNode;
|
300
314
|
createdAt?: Date;
|
301
315
|
};
|
302
|
-
type
|
316
|
+
type RSCMessageConverter<T> = {
|
317
|
+
convertMessage: (message: T) => VercelRSCMessage;
|
318
|
+
};
|
319
|
+
type VercelRSCAdapterBase<T> = {
|
303
320
|
messages: T[];
|
304
321
|
append: (message: AppendMessage) => Promise<void>;
|
305
322
|
edit?: (message: AppendMessage) => Promise<void>;
|
306
323
|
reload?: (parentId: string | null) => Promise<void>;
|
307
324
|
convertMessage?: (message: T) => VercelRSCMessage;
|
308
|
-
}>;
|
309
|
-
type RSCMessageConverter<T> = {
|
310
|
-
convertMessage: (message: T) => VercelRSCMessage;
|
311
325
|
};
|
312
|
-
type
|
313
|
-
declare const VercelRSCAssistantProvider: <T extends WeakKey = VercelRSCMessage>({ children, convertMessage, messages: vercelMessages, append: appendCallback, edit, reload, }: VercelRSCAssistantProviderProps<T>) => react_jsx_runtime.JSX.Element;
|
326
|
+
type VercelRSCAdapter<T = VercelRSCMessage> = VercelRSCAdapterBase<T> & (T extends VercelRSCMessage ? object : RSCMessageConverter<T>);
|
314
327
|
|
315
|
-
type
|
316
|
-
|
317
|
-
type Unsubscribe = () => void;
|
318
|
-
type ThreadRuntime = {
|
319
|
-
append(message: AppendMessage): Promise<{
|
320
|
-
parentId: string;
|
321
|
-
id: string;
|
322
|
-
}>;
|
323
|
-
startRun(parentId: string | null): Promise<{
|
324
|
-
id: string;
|
325
|
-
}>;
|
326
|
-
cancelRun(): void;
|
327
|
-
subscribeToMessageUpdates(callback: MessageUpdateCallback): Unsubscribe;
|
328
|
-
subscribeToStatusUpdates(callback: StatusUpdateCallback): Unsubscribe;
|
329
|
-
};
|
328
|
+
type VercelRSCAssistantProviderProps<T> = PropsWithChildren<VercelRSCAdapter<T>>;
|
329
|
+
declare const VercelRSCAssistantProvider: <T extends WeakKey = VercelRSCMessage>({ children, ...adapter }: VercelRSCAssistantProviderProps<T>) => react_jsx_runtime.JSX.Element;
|
330
330
|
|
331
331
|
type AssistantProviderProps = {
|
332
|
-
runtime:
|
332
|
+
runtime: AssistantRuntime;
|
333
333
|
};
|
334
334
|
declare const AssistantProvider: FC<PropsWithChildren<AssistantProviderProps>>;
|
335
335
|
|
@@ -345,25 +345,21 @@ type ChatModelAdapter = {
|
|
345
345
|
run: (options: ChatModelRunOptions) => Promise<ChatModelRunResult>;
|
346
346
|
};
|
347
347
|
|
348
|
-
declare class LocalRuntime implements
|
348
|
+
declare class LocalRuntime implements AssistantRuntime {
|
349
349
|
adapter: ChatModelAdapter;
|
350
|
-
private
|
351
|
-
private _statusUpdateCallbacks;
|
350
|
+
private _subscriptions;
|
352
351
|
private abortController;
|
353
352
|
private repository;
|
353
|
+
get messages(): ThreadMessage[];
|
354
|
+
get isRunning(): boolean;
|
354
355
|
constructor(adapter: ChatModelAdapter);
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
startRun(parentId: string | null): Promise<{
|
360
|
-
id: string;
|
361
|
-
}>;
|
362
|
-
private addOrUpdateMessage;
|
363
|
-
private run;
|
356
|
+
getBranches(messageId: string): string[];
|
357
|
+
switchToBranch(branchId: string): void;
|
358
|
+
append(message: AppendMessage): Promise<void>;
|
359
|
+
startRun(parentId: string | null): Promise<void>;
|
364
360
|
cancelRun(): void;
|
365
|
-
|
366
|
-
|
361
|
+
private notifySubscribers;
|
362
|
+
subscribe(callback: () => void): Unsubscribe;
|
367
363
|
}
|
368
364
|
|
369
365
|
declare const useLocalRuntime: (adapter: ChatModelAdapter) => LocalRuntime;
|
@@ -410,4 +406,4 @@ declare const useGoToNextBranch: () => (() => void) | null;
|
|
410
406
|
|
411
407
|
declare const useGoToPreviousBranch: () => (() => void) | null;
|
412
408
|
|
413
|
-
export { index$1 as ActionBarPrimitive, type AppendContentPart, type AppendMessage, index$2 as BranchPickerPrimitive, index$4 as ComposerPrimitive, index as ContentPartPrimitive, type ImageContentPart, index$3 as MessagePrimitive, type VercelRSCMessage as RSCMessage, type TextContentPart, index$5 as ThreadPrimitive, VercelAIAssistantProvider, type VercelAIAssistantProviderProps, VercelRSCAssistantProvider, type VercelRSCAssistantProviderProps, AssistantProvider as unstable_AssistantProvider, type ChatModelAdapter as unstable_ChatModelAdapter, type ChatModelRunOptions as unstable_ChatModelRunOptions, VercelModelAdapter as unstable_VercelModelAdapter, getVercelMessage as unstable_getVercelMessage, getVercelRSCMessage as unstable_getVercelRSCMessage, useLocalRuntime as unstable_useLocalRuntime, useMessageContext as unstable_useMessageContext, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useReloadMessage };
|
409
|
+
export { index$1 as ActionBarPrimitive, type AppendContentPart, type AppendMessage, index$2 as BranchPickerPrimitive, index$4 as ComposerPrimitive, index as ContentPartPrimitive, type ImageContentPart, index$3 as MessagePrimitive, type VercelRSCMessage as RSCMessage, type TextContentPart, index$5 as ThreadPrimitive, VercelAIAssistantProvider, type VercelAIAssistantProviderProps, VercelRSCAssistantProvider, type VercelRSCAssistantProviderProps, type VercelRSCMessage, AssistantProvider as unstable_AssistantProvider, type ChatModelAdapter as unstable_ChatModelAdapter, type ChatModelRunOptions as unstable_ChatModelRunOptions, VercelModelAdapter as unstable_VercelModelAdapter, getVercelMessage as unstable_getVercelMessage, getVercelRSCMessage as unstable_getVercelRSCMessage, useLocalRuntime as unstable_useLocalRuntime, useMessageContext as unstable_useMessageContext, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useReloadMessage };
|
package/dist/index.d.ts
CHANGED
@@ -153,6 +153,15 @@ type AppendMessage = {
|
|
153
153
|
content: AppendContentPart[];
|
154
154
|
};
|
155
155
|
type ThreadMessage = UserMessage | AssistantMessage;
|
156
|
+
type ThreadState = {
|
157
|
+
messages: ThreadMessage[];
|
158
|
+
isRunning: boolean;
|
159
|
+
getBranches: (messageId: string) => readonly string[];
|
160
|
+
switchToBranch: (branchId: string) => void;
|
161
|
+
append: (message: AppendMessage) => void;
|
162
|
+
startRun: (parentId: string | null) => void;
|
163
|
+
cancelRun: () => void;
|
164
|
+
};
|
156
165
|
|
157
166
|
type MessageProviderProps = PropsWithChildren<{
|
158
167
|
message: ThreadMessage;
|
@@ -293,43 +302,34 @@ type VercelAIAssistantProviderProps = PropsWithChildren<{
|
|
293
302
|
}>;
|
294
303
|
declare const VercelAIAssistantProvider: FC<VercelAIAssistantProviderProps>;
|
295
304
|
|
305
|
+
type Unsubscribe = () => void;
|
306
|
+
type AssistantRuntime = Readonly<ThreadState> & {
|
307
|
+
subscribe: (callback: () => void) => Unsubscribe;
|
308
|
+
};
|
309
|
+
|
296
310
|
type VercelRSCMessage = {
|
297
311
|
id: string;
|
298
312
|
role: "user" | "assistant";
|
299
313
|
display: ReactNode;
|
300
314
|
createdAt?: Date;
|
301
315
|
};
|
302
|
-
type
|
316
|
+
type RSCMessageConverter<T> = {
|
317
|
+
convertMessage: (message: T) => VercelRSCMessage;
|
318
|
+
};
|
319
|
+
type VercelRSCAdapterBase<T> = {
|
303
320
|
messages: T[];
|
304
321
|
append: (message: AppendMessage) => Promise<void>;
|
305
322
|
edit?: (message: AppendMessage) => Promise<void>;
|
306
323
|
reload?: (parentId: string | null) => Promise<void>;
|
307
324
|
convertMessage?: (message: T) => VercelRSCMessage;
|
308
|
-
}>;
|
309
|
-
type RSCMessageConverter<T> = {
|
310
|
-
convertMessage: (message: T) => VercelRSCMessage;
|
311
325
|
};
|
312
|
-
type
|
313
|
-
declare const VercelRSCAssistantProvider: <T extends WeakKey = VercelRSCMessage>({ children, convertMessage, messages: vercelMessages, append: appendCallback, edit, reload, }: VercelRSCAssistantProviderProps<T>) => react_jsx_runtime.JSX.Element;
|
326
|
+
type VercelRSCAdapter<T = VercelRSCMessage> = VercelRSCAdapterBase<T> & (T extends VercelRSCMessage ? object : RSCMessageConverter<T>);
|
314
327
|
|
315
|
-
type
|
316
|
-
|
317
|
-
type Unsubscribe = () => void;
|
318
|
-
type ThreadRuntime = {
|
319
|
-
append(message: AppendMessage): Promise<{
|
320
|
-
parentId: string;
|
321
|
-
id: string;
|
322
|
-
}>;
|
323
|
-
startRun(parentId: string | null): Promise<{
|
324
|
-
id: string;
|
325
|
-
}>;
|
326
|
-
cancelRun(): void;
|
327
|
-
subscribeToMessageUpdates(callback: MessageUpdateCallback): Unsubscribe;
|
328
|
-
subscribeToStatusUpdates(callback: StatusUpdateCallback): Unsubscribe;
|
329
|
-
};
|
328
|
+
type VercelRSCAssistantProviderProps<T> = PropsWithChildren<VercelRSCAdapter<T>>;
|
329
|
+
declare const VercelRSCAssistantProvider: <T extends WeakKey = VercelRSCMessage>({ children, ...adapter }: VercelRSCAssistantProviderProps<T>) => react_jsx_runtime.JSX.Element;
|
330
330
|
|
331
331
|
type AssistantProviderProps = {
|
332
|
-
runtime:
|
332
|
+
runtime: AssistantRuntime;
|
333
333
|
};
|
334
334
|
declare const AssistantProvider: FC<PropsWithChildren<AssistantProviderProps>>;
|
335
335
|
|
@@ -345,25 +345,21 @@ type ChatModelAdapter = {
|
|
345
345
|
run: (options: ChatModelRunOptions) => Promise<ChatModelRunResult>;
|
346
346
|
};
|
347
347
|
|
348
|
-
declare class LocalRuntime implements
|
348
|
+
declare class LocalRuntime implements AssistantRuntime {
|
349
349
|
adapter: ChatModelAdapter;
|
350
|
-
private
|
351
|
-
private _statusUpdateCallbacks;
|
350
|
+
private _subscriptions;
|
352
351
|
private abortController;
|
353
352
|
private repository;
|
353
|
+
get messages(): ThreadMessage[];
|
354
|
+
get isRunning(): boolean;
|
354
355
|
constructor(adapter: ChatModelAdapter);
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
startRun(parentId: string | null): Promise<{
|
360
|
-
id: string;
|
361
|
-
}>;
|
362
|
-
private addOrUpdateMessage;
|
363
|
-
private run;
|
356
|
+
getBranches(messageId: string): string[];
|
357
|
+
switchToBranch(branchId: string): void;
|
358
|
+
append(message: AppendMessage): Promise<void>;
|
359
|
+
startRun(parentId: string | null): Promise<void>;
|
364
360
|
cancelRun(): void;
|
365
|
-
|
366
|
-
|
361
|
+
private notifySubscribers;
|
362
|
+
subscribe(callback: () => void): Unsubscribe;
|
367
363
|
}
|
368
364
|
|
369
365
|
declare const useLocalRuntime: (adapter: ChatModelAdapter) => LocalRuntime;
|
@@ -410,4 +406,4 @@ declare const useGoToNextBranch: () => (() => void) | null;
|
|
410
406
|
|
411
407
|
declare const useGoToPreviousBranch: () => (() => void) | null;
|
412
408
|
|
413
|
-
export { index$1 as ActionBarPrimitive, type AppendContentPart, type AppendMessage, index$2 as BranchPickerPrimitive, index$4 as ComposerPrimitive, index as ContentPartPrimitive, type ImageContentPart, index$3 as MessagePrimitive, type VercelRSCMessage as RSCMessage, type TextContentPart, index$5 as ThreadPrimitive, VercelAIAssistantProvider, type VercelAIAssistantProviderProps, VercelRSCAssistantProvider, type VercelRSCAssistantProviderProps, AssistantProvider as unstable_AssistantProvider, type ChatModelAdapter as unstable_ChatModelAdapter, type ChatModelRunOptions as unstable_ChatModelRunOptions, VercelModelAdapter as unstable_VercelModelAdapter, getVercelMessage as unstable_getVercelMessage, getVercelRSCMessage as unstable_getVercelRSCMessage, useLocalRuntime as unstable_useLocalRuntime, useMessageContext as unstable_useMessageContext, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useReloadMessage };
|
409
|
+
export { index$1 as ActionBarPrimitive, type AppendContentPart, type AppendMessage, index$2 as BranchPickerPrimitive, index$4 as ComposerPrimitive, index as ContentPartPrimitive, type ImageContentPart, index$3 as MessagePrimitive, type VercelRSCMessage as RSCMessage, type TextContentPart, index$5 as ThreadPrimitive, VercelAIAssistantProvider, type VercelAIAssistantProviderProps, VercelRSCAssistantProvider, type VercelRSCAssistantProviderProps, type VercelRSCMessage, AssistantProvider as unstable_AssistantProvider, type ChatModelAdapter as unstable_ChatModelAdapter, type ChatModelRunOptions as unstable_ChatModelRunOptions, VercelModelAdapter as unstable_VercelModelAdapter, getVercelMessage as unstable_getVercelMessage, getVercelRSCMessage as unstable_getVercelRSCMessage, useLocalRuntime as unstable_useLocalRuntime, useMessageContext as unstable_useMessageContext, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useReloadMessage };
|