@assistant-ui/react 0.0.15 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.mts CHANGED
@@ -3,6 +3,7 @@ import { FC, ReactNode, PropsWithChildren, ComponentType } from 'react';
3
3
  import { TextareaAutosizeProps } from 'react-textarea-autosize';
4
4
  import { UseChatHelpers, UseAssistantHelpers } from 'ai/react';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
+ import { Message } from 'ai';
6
7
  import { UseBoundStore, StoreApi } from 'zustand';
7
8
 
8
9
  declare const ThreadRoot: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
@@ -66,7 +67,7 @@ declare const ThreadSuggestion: react.ForwardRefExoticComponent<Pick<Omit<react.
66
67
  autoSend?: boolean;
67
68
  } & react.RefAttributes<HTMLButtonElement>>;
68
69
 
69
- declare namespace index$4 {
70
+ declare namespace index$5 {
70
71
  export { ThreadEmpty as Empty, ThreadIf as If, ThreadMessages as Messages, ThreadRoot as Root, ThreadScrollToBottom as ScrollToBottom, ThreadSuggestion as Suggestion, ThreadViewport as Viewport };
71
72
  }
72
73
 
@@ -98,7 +99,7 @@ type ComposerIfFilters = {
98
99
  type ComposerIfProps = PropsWithChildren<RequireAtLeastOne<ComposerIfFilters>>;
99
100
  declare const ComposerIf: FC<ComposerIfProps>;
100
101
 
101
- declare namespace index$3 {
102
+ declare namespace index$4 {
102
103
  export { ComposerCancel as Cancel, ComposerIf as If, ComposerInput as Input, ComposerRoot as Root, ComposerSend as Send };
103
104
  }
104
105
 
@@ -145,6 +146,7 @@ type UserMessage = BaseMessage & {
145
146
  type AssistantMessage = BaseMessage & {
146
147
  role: "assistant";
147
148
  content: AssistantContentPart[];
149
+ status: "in_progress" | "done" | "error";
148
150
  };
149
151
  type AppendMessage = {
150
152
  parentId: string | null;
@@ -199,8 +201,14 @@ type MessageContentProps = {
199
201
  };
200
202
  declare const MessageContent: FC<MessageContentProps>;
201
203
 
202
- declare namespace index$2 {
203
- export { MessageContent as Content, MessageIf as If, MessageProvider as Provider, MessageRoot as Root };
204
+ declare const MessageInProgress: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
205
+ ref?: ((instance: HTMLDivElement | null) => void) | react.RefObject<HTMLDivElement> | null | undefined;
206
+ } & {
207
+ asChild?: boolean;
208
+ }, "key" | keyof react.HTMLAttributes<HTMLDivElement> | "asChild"> & react.RefAttributes<HTMLDivElement>>;
209
+
210
+ declare namespace index$3 {
211
+ export { MessageContent as Content, MessageIf as If, MessageInProgress as InProgress, MessageProvider as Provider, MessageRoot as Root };
204
212
  }
205
213
 
206
214
  declare const BranchPickerNext: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
@@ -227,7 +235,7 @@ declare const BranchPickerRoot: react.ForwardRefExoticComponent<Pick<Omit<react.
227
235
  hideWhenSingleBranch?: boolean;
228
236
  } & react.RefAttributes<HTMLDivElement>>;
229
237
 
230
- declare namespace index$1 {
238
+ declare namespace index$2 {
231
239
  export { BranchPickerCount as Count, BranchPickerNext as Next, BranchPickerNumber as Number, BranchPickerPrevious as Previous, BranchPickerRoot as Root };
232
240
  }
233
241
 
@@ -262,10 +270,22 @@ declare const ActionBarEdit: react.ForwardRefExoticComponent<Pick<Omit<react.Det
262
270
  asChild?: boolean;
263
271
  }, "key" | "asChild" | keyof react.ButtonHTMLAttributes<HTMLButtonElement>> & react.RefAttributes<HTMLButtonElement>>;
264
272
 
265
- declare namespace index {
273
+ declare namespace index$1 {
266
274
  export { ActionBarCopy as Copy, ActionBarEdit as Edit, ActionBarReload as Reload, ActionBarRoot as Root };
267
275
  }
268
276
 
277
+ type ContentPartProviderProps = PropsWithChildren<{
278
+ part: ThreadMessage["content"][number];
279
+ status: "in_progress" | "done" | "error";
280
+ }>;
281
+ declare const ContentPartProvider: FC<ContentPartProviderProps>;
282
+
283
+ declare const ContentPartInProgressIndicator: FC;
284
+
285
+ declare namespace index {
286
+ export { ContentPartInProgressIndicator as InProgressIndicator, ContentPartProvider as Provider };
287
+ }
288
+
269
289
  type VercelAIAssistantProviderProps = PropsWithChildren<{
270
290
  chat: UseChatHelpers;
271
291
  } | {
@@ -292,11 +312,16 @@ type RSCMessageConverter<T> = {
292
312
  type VercelRSCAssistantProviderProps<T = VercelRSCMessage> = VercelRSCAssistantProviderBaseProps<T> & (T extends VercelRSCMessage ? object : RSCMessageConverter<T>);
293
313
  declare const VercelRSCAssistantProvider: <T extends WeakKey = VercelRSCMessage>({ children, convertMessage, messages: vercelMessages, append: appendCallback, edit, reload, }: VercelRSCAssistantProviderProps<T>) => react_jsx_runtime.JSX.Element;
294
314
 
315
+ declare const getVercelMessage: (message: ThreadMessage) => Message | undefined;
316
+ declare const getVercelRSCMessage: <T>(message: ThreadMessage) => T | undefined;
317
+
295
318
  type MessageState = {
296
319
  message: ThreadMessage;
297
320
  parentId: string | null;
298
321
  branches: string[];
299
322
  isLast: boolean;
323
+ inProgressIndicator: ReactNode | null;
324
+ setInProgressIndicator: (value: ReactNode | null) => void;
300
325
  isCopied: boolean;
301
326
  setIsCopied: (value: boolean) => void;
302
327
  isHovering: boolean;
@@ -321,4 +346,4 @@ declare const useGoToNextBranch: () => (() => void) | null;
321
346
 
322
347
  declare const useGoToPreviousBranch: () => (() => void) | null;
323
348
 
324
- export { index as ActionBarPrimitive, type AppendContentPart, type AppendMessage, index$1 as BranchPickerPrimitive, index$3 as ComposerPrimitive, type ImageContentPart, index$2 as MessagePrimitive, type VercelRSCMessage as RSCMessage, type TextContentPart, index$4 as ThreadPrimitive, VercelAIAssistantProvider, type VercelAIAssistantProviderProps, VercelRSCAssistantProvider, type VercelRSCAssistantProviderProps, useMessageContext as unstable_useMessageContext, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useReloadMessage };
349
+ 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, getVercelMessage as unstable_getVercelMessage, getVercelRSCMessage as unstable_getVercelRSCMessage, useMessageContext as unstable_useMessageContext, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useReloadMessage };
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import { FC, ReactNode, PropsWithChildren, ComponentType } from 'react';
3
3
  import { TextareaAutosizeProps } from 'react-textarea-autosize';
4
4
  import { UseChatHelpers, UseAssistantHelpers } from 'ai/react';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
+ import { Message } from 'ai';
6
7
  import { UseBoundStore, StoreApi } from 'zustand';
7
8
 
8
9
  declare const ThreadRoot: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
@@ -66,7 +67,7 @@ declare const ThreadSuggestion: react.ForwardRefExoticComponent<Pick<Omit<react.
66
67
  autoSend?: boolean;
67
68
  } & react.RefAttributes<HTMLButtonElement>>;
68
69
 
69
- declare namespace index$4 {
70
+ declare namespace index$5 {
70
71
  export { ThreadEmpty as Empty, ThreadIf as If, ThreadMessages as Messages, ThreadRoot as Root, ThreadScrollToBottom as ScrollToBottom, ThreadSuggestion as Suggestion, ThreadViewport as Viewport };
71
72
  }
72
73
 
@@ -98,7 +99,7 @@ type ComposerIfFilters = {
98
99
  type ComposerIfProps = PropsWithChildren<RequireAtLeastOne<ComposerIfFilters>>;
99
100
  declare const ComposerIf: FC<ComposerIfProps>;
100
101
 
101
- declare namespace index$3 {
102
+ declare namespace index$4 {
102
103
  export { ComposerCancel as Cancel, ComposerIf as If, ComposerInput as Input, ComposerRoot as Root, ComposerSend as Send };
103
104
  }
104
105
 
@@ -145,6 +146,7 @@ type UserMessage = BaseMessage & {
145
146
  type AssistantMessage = BaseMessage & {
146
147
  role: "assistant";
147
148
  content: AssistantContentPart[];
149
+ status: "in_progress" | "done" | "error";
148
150
  };
149
151
  type AppendMessage = {
150
152
  parentId: string | null;
@@ -199,8 +201,14 @@ type MessageContentProps = {
199
201
  };
200
202
  declare const MessageContent: FC<MessageContentProps>;
201
203
 
202
- declare namespace index$2 {
203
- export { MessageContent as Content, MessageIf as If, MessageProvider as Provider, MessageRoot as Root };
204
+ declare const MessageInProgress: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
205
+ ref?: ((instance: HTMLDivElement | null) => void) | react.RefObject<HTMLDivElement> | null | undefined;
206
+ } & {
207
+ asChild?: boolean;
208
+ }, "key" | keyof react.HTMLAttributes<HTMLDivElement> | "asChild"> & react.RefAttributes<HTMLDivElement>>;
209
+
210
+ declare namespace index$3 {
211
+ export { MessageContent as Content, MessageIf as If, MessageInProgress as InProgress, MessageProvider as Provider, MessageRoot as Root };
204
212
  }
205
213
 
206
214
  declare const BranchPickerNext: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
@@ -227,7 +235,7 @@ declare const BranchPickerRoot: react.ForwardRefExoticComponent<Pick<Omit<react.
227
235
  hideWhenSingleBranch?: boolean;
228
236
  } & react.RefAttributes<HTMLDivElement>>;
229
237
 
230
- declare namespace index$1 {
238
+ declare namespace index$2 {
231
239
  export { BranchPickerCount as Count, BranchPickerNext as Next, BranchPickerNumber as Number, BranchPickerPrevious as Previous, BranchPickerRoot as Root };
232
240
  }
233
241
 
@@ -262,10 +270,22 @@ declare const ActionBarEdit: react.ForwardRefExoticComponent<Pick<Omit<react.Det
262
270
  asChild?: boolean;
263
271
  }, "key" | "asChild" | keyof react.ButtonHTMLAttributes<HTMLButtonElement>> & react.RefAttributes<HTMLButtonElement>>;
264
272
 
265
- declare namespace index {
273
+ declare namespace index$1 {
266
274
  export { ActionBarCopy as Copy, ActionBarEdit as Edit, ActionBarReload as Reload, ActionBarRoot as Root };
267
275
  }
268
276
 
277
+ type ContentPartProviderProps = PropsWithChildren<{
278
+ part: ThreadMessage["content"][number];
279
+ status: "in_progress" | "done" | "error";
280
+ }>;
281
+ declare const ContentPartProvider: FC<ContentPartProviderProps>;
282
+
283
+ declare const ContentPartInProgressIndicator: FC;
284
+
285
+ declare namespace index {
286
+ export { ContentPartInProgressIndicator as InProgressIndicator, ContentPartProvider as Provider };
287
+ }
288
+
269
289
  type VercelAIAssistantProviderProps = PropsWithChildren<{
270
290
  chat: UseChatHelpers;
271
291
  } | {
@@ -292,11 +312,16 @@ type RSCMessageConverter<T> = {
292
312
  type VercelRSCAssistantProviderProps<T = VercelRSCMessage> = VercelRSCAssistantProviderBaseProps<T> & (T extends VercelRSCMessage ? object : RSCMessageConverter<T>);
293
313
  declare const VercelRSCAssistantProvider: <T extends WeakKey = VercelRSCMessage>({ children, convertMessage, messages: vercelMessages, append: appendCallback, edit, reload, }: VercelRSCAssistantProviderProps<T>) => react_jsx_runtime.JSX.Element;
294
314
 
315
+ declare const getVercelMessage: (message: ThreadMessage) => Message | undefined;
316
+ declare const getVercelRSCMessage: <T>(message: ThreadMessage) => T | undefined;
317
+
295
318
  type MessageState = {
296
319
  message: ThreadMessage;
297
320
  parentId: string | null;
298
321
  branches: string[];
299
322
  isLast: boolean;
323
+ inProgressIndicator: ReactNode | null;
324
+ setInProgressIndicator: (value: ReactNode | null) => void;
300
325
  isCopied: boolean;
301
326
  setIsCopied: (value: boolean) => void;
302
327
  isHovering: boolean;
@@ -321,4 +346,4 @@ declare const useGoToNextBranch: () => (() => void) | null;
321
346
 
322
347
  declare const useGoToPreviousBranch: () => (() => void) | null;
323
348
 
324
- export { index as ActionBarPrimitive, type AppendContentPart, type AppendMessage, index$1 as BranchPickerPrimitive, index$3 as ComposerPrimitive, type ImageContentPart, index$2 as MessagePrimitive, type VercelRSCMessage as RSCMessage, type TextContentPart, index$4 as ThreadPrimitive, VercelAIAssistantProvider, type VercelAIAssistantProviderProps, VercelRSCAssistantProvider, type VercelRSCAssistantProviderProps, useMessageContext as unstable_useMessageContext, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useReloadMessage };
349
+ 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, getVercelMessage as unstable_getVercelMessage, getVercelRSCMessage as unstable_getVercelRSCMessage, useMessageContext as unstable_useMessageContext, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useReloadMessage };