@assistant-ui/react 0.0.29 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/AssistantRuntime-BM_jVV3g.d.mts +23 -0
- package/dist/AssistantRuntime-CBMSAJqH.d.mts +23 -0
- package/dist/AssistantRuntime-C_BvM7ZT.d.ts +23 -0
- package/dist/AssistantRuntime-DELpXWfG.d.ts +23 -0
- package/dist/ModelConfigTypes-B9UY4zxv.d.mts +55 -0
- package/dist/ModelConfigTypes-B9UY4zxv.d.ts +55 -0
- package/dist/ModelConfigTypes-BF5HxVrH.d.mts +55 -0
- package/dist/ModelConfigTypes-BF5HxVrH.d.ts +55 -0
- package/dist/ModelConfigTypes-Cf3yjaDu.d.mts +55 -0
- package/dist/ModelConfigTypes-Cf3yjaDu.d.ts +55 -0
- package/dist/ModelConfigTypes-CzmXY3sn.d.mts +55 -0
- package/dist/ModelConfigTypes-CzmXY3sn.d.ts +55 -0
- package/dist/Thread-BMASJT4a.d.ts +15 -0
- package/dist/Thread-UEVsUmvl.d.mts +15 -0
- package/dist/chunk-3XZUKECF.mjs +207 -0
- package/dist/chunk-3XZUKECF.mjs.map +1 -0
- package/dist/chunk-4DQ2CIAD.mjs +69 -0
- package/dist/chunk-4DQ2CIAD.mjs.map +1 -0
- package/dist/chunk-5YONSDN4.mjs +200 -0
- package/dist/chunk-5YONSDN4.mjs.map +1 -0
- package/dist/chunk-CY4TTHR7.mjs +76 -0
- package/dist/chunk-CY4TTHR7.mjs.map +1 -0
- package/dist/chunk-DKAWDNW5.mjs +22 -0
- package/dist/chunk-DKAWDNW5.mjs.map +1 -0
- package/dist/chunk-GQKH2ADD.mjs +165 -0
- package/dist/chunk-GQKH2ADD.mjs.map +1 -0
- package/dist/chunk-J5LGTIGS.mjs +10 -0
- package/dist/chunk-J5LGTIGS.mjs.map +1 -0
- package/dist/chunk-NSBOH42A.mjs +200 -0
- package/dist/chunk-NSBOH42A.mjs.map +1 -0
- package/dist/chunk-X4HBDEFP.mjs +30 -0
- package/dist/chunk-X4HBDEFP.mjs.map +1 -0
- package/dist/experimental.d.mts +86 -0
- package/dist/experimental.d.ts +86 -0
- package/dist/experimental.js +123 -0
- package/dist/experimental.js.map +1 -0
- package/dist/experimental.mjs +34 -0
- package/dist/experimental.mjs.map +1 -0
- package/dist/index.d.mts +11 -230
- package/dist/index.d.ts +11 -230
- package/dist/index.js +189 -577
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +140 -757
- package/dist/index.mjs.map +1 -1
- package/dist/internal-dlLjX30u.d.mts +75 -0
- package/dist/internal-dlLjX30u.d.ts +75 -0
- package/dist/internal.d.mts +25 -0
- package/dist/internal.d.ts +25 -0
- package/dist/internal.js +225 -0
- package/dist/internal.js.map +1 -0
- package/dist/internal.mjs +10 -0
- package/dist/internal.mjs.map +1 -0
- package/package.json +23 -3
package/dist/index.d.ts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
import * as react from 'react';
|
2
2
|
import { FC, ReactNode, PropsWithChildren, ComponentType } from 'react';
|
3
3
|
import { TextareaAutosizeProps } from 'react-textarea-autosize';
|
4
|
-
import {
|
5
|
-
|
6
|
-
import {
|
7
|
-
import
|
4
|
+
import { T as TextContentPart, I as ImageContentPart, U as UIContentPart, a as ToolCallContentPart, M as ModelConfigProvider, b as ThreadMessage, c as ModelConfig, A as AssistantContentPart, d as AppendMessage } from './ModelConfigTypes-CzmXY3sn.js';
|
5
|
+
export { h as AppendContentPart, e as AssistantMessage, g as UserContentPart, f as UserMessage } from './ModelConfigTypes-CzmXY3sn.js';
|
6
|
+
import { T as ThreadState, U as Unsubscribe } from './Thread-BMASJT4a.js';
|
7
|
+
import 'zod';
|
8
8
|
|
9
9
|
declare const useCopyMessage: ({ copiedDuration }: {
|
10
10
|
copiedDuration?: number | undefined;
|
@@ -133,46 +133,6 @@ type MessageIfProps = RequireAtLeastOne<MessageIfFilters> & {
|
|
133
133
|
};
|
134
134
|
declare const MessageIf: FC<MessageIfProps>;
|
135
135
|
|
136
|
-
type TextContentPart = {
|
137
|
-
type: "text";
|
138
|
-
text: string;
|
139
|
-
};
|
140
|
-
type ImageContentPart = {
|
141
|
-
type: "image";
|
142
|
-
image: string;
|
143
|
-
};
|
144
|
-
type UIContentPart = {
|
145
|
-
type: "ui";
|
146
|
-
display: ReactNode;
|
147
|
-
};
|
148
|
-
type ToolCallContentPart = {
|
149
|
-
type: "tool-call";
|
150
|
-
name: string;
|
151
|
-
args: object;
|
152
|
-
result?: object;
|
153
|
-
};
|
154
|
-
type UserContentPart = TextContentPart | ImageContentPart | UIContentPart;
|
155
|
-
type AssistantContentPart = TextContentPart | UIContentPart | ToolCallContentPart;
|
156
|
-
type AppendContentPart = TextContentPart | ImageContentPart;
|
157
|
-
type BaseMessage = {
|
158
|
-
id: string;
|
159
|
-
createdAt: Date;
|
160
|
-
};
|
161
|
-
type UserMessage = BaseMessage & {
|
162
|
-
role: "user";
|
163
|
-
content: UserContentPart[];
|
164
|
-
};
|
165
|
-
type AssistantMessage = BaseMessage & {
|
166
|
-
role: "assistant";
|
167
|
-
content: AssistantContentPart[];
|
168
|
-
status: "in_progress" | "done" | "error";
|
169
|
-
};
|
170
|
-
type AppendMessage = {
|
171
|
-
parentId: string | null;
|
172
|
-
content: AppendContentPart[];
|
173
|
-
};
|
174
|
-
type ThreadMessage = UserMessage | AssistantMessage;
|
175
|
-
|
176
136
|
type MessageContentProps = {
|
177
137
|
components?: {
|
178
138
|
Text?: ComponentType<{
|
@@ -275,206 +235,25 @@ declare namespace index {
|
|
275
235
|
export { ContentPartInProgressIndicator as InProgressIndicator };
|
276
236
|
}
|
277
237
|
|
278
|
-
type VercelRSCMessage = {
|
279
|
-
id: string;
|
280
|
-
role: "user" | "assistant";
|
281
|
-
display: ReactNode;
|
282
|
-
createdAt?: Date;
|
283
|
-
};
|
284
|
-
|
285
|
-
type RSCMessageConverter<T> = {
|
286
|
-
convertMessage: (message: T) => VercelRSCMessage;
|
287
|
-
};
|
288
|
-
type VercelRSCAdapterBase<T> = {
|
289
|
-
messages: T[];
|
290
|
-
append: (message: AppendMessage) => Promise<void>;
|
291
|
-
edit?: (message: AppendMessage) => Promise<void>;
|
292
|
-
reload?: (parentId: string | null) => Promise<void>;
|
293
|
-
convertMessage?: (message: T) => VercelRSCMessage;
|
294
|
-
};
|
295
|
-
type VercelRSCAdapter<T = VercelRSCMessage> = VercelRSCAdapterBase<T> & (T extends VercelRSCMessage ? object : RSCMessageConverter<T>);
|
296
|
-
|
297
|
-
declare class VercelRSCRuntime<T extends WeakKey = VercelRSCMessage> implements AssistantRuntime, ReactThreadRuntime {
|
298
|
-
adapter: VercelRSCAdapter<T>;
|
299
|
-
private useAdapter;
|
300
|
-
private _subscriptions;
|
301
|
-
isRunning: boolean;
|
302
|
-
messages: ThreadMessage[];
|
303
|
-
constructor(adapter: VercelRSCAdapter<T>);
|
304
|
-
private withRunning;
|
305
|
-
getBranches(): readonly string[];
|
306
|
-
switchToBranch(): void;
|
307
|
-
append(message: AppendMessage): Promise<void>;
|
308
|
-
startRun(parentId: string | null): Promise<void>;
|
309
|
-
cancelRun(): void;
|
310
|
-
subscribe(callback: () => void): () => void;
|
311
|
-
onAdapterUpdated(): void;
|
312
|
-
private updateData;
|
313
|
-
unstable_synchronizer: () => null;
|
314
|
-
}
|
315
|
-
|
316
|
-
declare const useVercelRSCRuntime: <T extends WeakKey>(adapter: VercelRSCAdapter<T>) => VercelRSCRuntime<T>;
|
317
|
-
|
318
|
-
declare const getVercelRSCMessage: <T>(message: ThreadMessage) => T | undefined;
|
319
|
-
|
320
|
-
type VercelHelpers = UseChatHelpers | UseAssistantHelpers;
|
321
|
-
|
322
|
-
declare class VercelAIRuntime implements AssistantRuntime, ReactThreadRuntime {
|
323
|
-
vercel: VercelHelpers;
|
324
|
-
private _subscriptions;
|
325
|
-
private repository;
|
326
|
-
private assistantOptimisticId;
|
327
|
-
private useVercel;
|
328
|
-
messages: ThreadMessage[];
|
329
|
-
isRunning: boolean;
|
330
|
-
constructor(vercel: VercelHelpers);
|
331
|
-
getBranches(messageId: string): string[];
|
332
|
-
switchToBranch(branchId: string): void;
|
333
|
-
append(message: AppendMessage): Promise<void>;
|
334
|
-
startRun(parentId: string | null): Promise<void>;
|
335
|
-
cancelRun(): void;
|
336
|
-
subscribe(callback: () => void): () => void;
|
337
|
-
private updateVercelMessages;
|
338
|
-
onVercelUpdated(): void;
|
339
|
-
private updateData;
|
340
|
-
unstable_synchronizer: () => null;
|
341
|
-
}
|
342
|
-
|
343
|
-
declare const useVercelUseChatRuntime: (chatHelpers: UseChatHelpers) => VercelAIRuntime;
|
344
|
-
|
345
|
-
declare const useVercelUseAssistantRuntime: (assistantHelpers: UseAssistantHelpers) => VercelAIRuntime;
|
346
|
-
|
347
|
-
declare const getVercelAIMessage: (message: ThreadMessage) => Message[] | undefined;
|
348
|
-
|
349
|
-
type ContentPartState = Readonly<{
|
350
|
-
status: "in_progress" | "done" | "error";
|
351
|
-
part: ThreadMessage["content"][number];
|
352
|
-
}>;
|
353
|
-
|
354
|
-
type MessageState = Readonly<{
|
355
|
-
message: Readonly<ThreadMessage>;
|
356
|
-
parentId: string | null;
|
357
|
-
branches: readonly string[];
|
358
|
-
isLast: boolean;
|
359
|
-
inProgressIndicator: ReactNode | null;
|
360
|
-
setInProgressIndicator: (value: ReactNode | null) => void;
|
361
|
-
isCopied: boolean;
|
362
|
-
setIsCopied: (value: boolean) => void;
|
363
|
-
isHovering: boolean;
|
364
|
-
setIsHovering: (value: boolean) => void;
|
365
|
-
}>;
|
366
|
-
|
367
|
-
type BaseComposerState = Readonly<{
|
368
|
-
value: string;
|
369
|
-
setValue: (value: string) => void;
|
370
|
-
}>;
|
371
|
-
|
372
|
-
type EditComposerState = BaseComposerState & Readonly<{
|
373
|
-
isEditing: boolean;
|
374
|
-
edit: () => void;
|
375
|
-
send: () => void;
|
376
|
-
cancel: () => boolean;
|
377
|
-
}>;
|
378
|
-
|
379
|
-
type ThreadState = {
|
380
|
-
messages: readonly ThreadMessage[];
|
381
|
-
isRunning: boolean;
|
382
|
-
getBranches: (messageId: string) => readonly string[];
|
383
|
-
switchToBranch: (branchId: string) => void;
|
384
|
-
append: (message: AppendMessage) => void;
|
385
|
-
startRun: (parentId: string | null) => void;
|
386
|
-
cancelRun: () => void;
|
387
|
-
};
|
388
|
-
|
389
|
-
type ComposerState = BaseComposerState & Readonly<{
|
390
|
-
isEditing: true;
|
391
|
-
send: () => void;
|
392
|
-
cancel: () => boolean;
|
393
|
-
}>;
|
394
|
-
|
395
|
-
type ThreadViewportState = {
|
396
|
-
isAtBottom: boolean;
|
397
|
-
scrollToBottom: () => void;
|
398
|
-
onScrollToBottom: (callback: () => void) => () => void;
|
399
|
-
};
|
400
|
-
|
401
|
-
type ThreadContextValue = {
|
402
|
-
useThread: UseBoundStore<StoreApi<ThreadState>>;
|
403
|
-
useComposer: UseBoundStore<StoreApi<ComposerState>>;
|
404
|
-
useViewport: UseBoundStore<StoreApi<ThreadViewportState>>;
|
405
|
-
};
|
406
|
-
declare const useThreadContext: () => ThreadContextValue;
|
407
|
-
|
408
|
-
type ComposerContextValue = {
|
409
|
-
useComposer: UseBoundStore<StoreApi<EditComposerState | ComposerState>>;
|
410
|
-
type: "edit" | "new";
|
411
|
-
};
|
412
|
-
declare const useComposerContext: () => ComposerContextValue;
|
413
|
-
|
414
|
-
type MessageContextValue = {
|
415
|
-
useMessage: UseBoundStore<StoreApi<MessageState>>;
|
416
|
-
useComposer: UseBoundStore<StoreApi<EditComposerState>>;
|
417
|
-
};
|
418
|
-
declare const useMessageContext: () => MessageContextValue;
|
419
|
-
|
420
|
-
type ContentPartContextValue = {
|
421
|
-
useContentPart: UseBoundStore<StoreApi<ContentPartState>>;
|
422
|
-
};
|
423
|
-
declare const useContentPartContext: () => ContentPartContextValue;
|
424
|
-
|
425
|
-
type Unsubscribe = () => void;
|
426
238
|
type ThreadRuntime = Readonly<ThreadState & {
|
427
239
|
subscribe: (callback: () => void) => Unsubscribe;
|
428
240
|
}>;
|
429
241
|
|
430
|
-
type AssistantRuntime = ThreadRuntime
|
242
|
+
type AssistantRuntime = ThreadRuntime & {
|
243
|
+
registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
|
244
|
+
};
|
431
245
|
|
432
246
|
type ReactThreadRuntime = ThreadRuntime & {
|
433
247
|
unstable_synchronizer?: ComponentType;
|
434
248
|
};
|
435
249
|
|
436
|
-
declare class MessageRepository {
|
437
|
-
private messages;
|
438
|
-
private head;
|
439
|
-
private root;
|
440
|
-
private performOp;
|
441
|
-
getMessages(): ThreadMessage[];
|
442
|
-
addOrUpdateMessage(parentId: string | null, message: ThreadMessage): void;
|
443
|
-
appendOptimisticMessage(parentId: string | null, message: Omit<ThreadMessage, "id" | "createdAt">): string;
|
444
|
-
deleteMessage(messageId: string, replacementId?: string | null | undefined): void;
|
445
|
-
getBranches(messageId: string): string[];
|
446
|
-
switchToBranch(messageId: string): void;
|
447
|
-
resetHead(messageId: string | null): void;
|
448
|
-
}
|
449
|
-
|
450
|
-
/**
|
451
|
-
* @deprecated Will be removed in 0.1.0.
|
452
|
-
*/
|
453
|
-
type VercelAIAssistantProviderProps = PropsWithChildren<{
|
454
|
-
chat: UseChatHelpers;
|
455
|
-
} | {
|
456
|
-
assistant: UseAssistantHelpers;
|
457
|
-
}>;
|
458
|
-
/**
|
459
|
-
* @deprecated `const runtime = useVercelUseChatRuntime(chat)` and `<AssistantRuntimeProvider runtime={...} />`. Will be removed in 0.1.0.
|
460
|
-
*/
|
461
|
-
declare const VercelAIAssistantProvider: FC<VercelAIAssistantProviderProps>;
|
462
|
-
|
463
|
-
/**
|
464
|
-
* @deprecated Will be removed in 0.1.0.
|
465
|
-
*/
|
466
|
-
type VercelRSCAssistantProviderProps<T> = PropsWithChildren<VercelRSCAdapter<T>>;
|
467
|
-
/**
|
468
|
-
* @deprecated Replaced with `const runtime = useVercelRSCRuntime({ messages, append })` and `<AssistantRuntimeProvider runtime={runtime} />`. Will be removed in 0.1.0.
|
469
|
-
*/
|
470
|
-
declare const VercelRSCAssistantProvider: <T extends WeakKey = VercelRSCMessage>({ children, ...adapter }: VercelRSCAssistantProviderProps<T>) => react_jsx_runtime.JSX.Element;
|
471
|
-
|
472
250
|
type ChatModelRunResult = {
|
473
251
|
content: AssistantContentPart[];
|
474
252
|
};
|
475
253
|
type ChatModelRunOptions = {
|
476
254
|
messages: ThreadMessage[];
|
477
255
|
abortSignal: AbortSignal;
|
256
|
+
config: ModelConfig;
|
478
257
|
onUpdate: (result: ChatModelRunResult) => void;
|
479
258
|
};
|
480
259
|
type ChatModelAdapter = {
|
@@ -484,6 +263,7 @@ type ChatModelAdapter = {
|
|
484
263
|
declare class LocalRuntime implements AssistantRuntime {
|
485
264
|
adapter: ChatModelAdapter;
|
486
265
|
private _subscriptions;
|
266
|
+
private _configProviders;
|
487
267
|
private abortController;
|
488
268
|
private repository;
|
489
269
|
get messages(): ThreadMessage[];
|
@@ -496,6 +276,7 @@ declare class LocalRuntime implements AssistantRuntime {
|
|
496
276
|
cancelRun(): void;
|
497
277
|
private notifySubscribers;
|
498
278
|
subscribe(callback: () => void): Unsubscribe;
|
279
|
+
registerModelConfigProvider(provider: ModelConfigProvider): () => boolean;
|
499
280
|
}
|
500
281
|
|
501
282
|
declare const useLocalRuntime: (adapter: ChatModelAdapter) => LocalRuntime;
|
@@ -505,4 +286,4 @@ type AssistantRuntimeProviderProps = {
|
|
505
286
|
};
|
506
287
|
declare const AssistantRuntimeProvider: react.NamedExoticComponent<PropsWithChildren<AssistantRuntimeProviderProps>>;
|
507
288
|
|
508
|
-
export { index$1 as ActionBarPrimitive,
|
289
|
+
export { index$1 as ActionBarPrimitive, AppendMessage, AssistantContentPart, type AssistantRuntime, AssistantRuntimeProvider, index$2 as BranchPickerPrimitive, type ChatModelAdapter, type ChatModelRunOptions, index$4 as ComposerPrimitive, index as ContentPartPrimitive, index$3 as MessagePrimitive, type ReactThreadRuntime, TextContentPart, ThreadMessage, index$5 as ThreadPrimitive, type ThreadRuntime, Unsubscribe, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useLocalRuntime, useReloadMessage };
|