@assistant-ui/react 0.0.12 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.mts +48 -30
- package/dist/index.d.ts +48 -30
- package/dist/index.js +311 -228
- package/dist/index.mjs +293 -208
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
@@ -2,6 +2,7 @@ import * as react from 'react';
|
|
2
2
|
import { FC, ReactNode, PropsWithChildren, ComponentType } from 'react';
|
3
3
|
import { TextareaAutosizeProps } from 'react-textarea-autosize';
|
4
4
|
import { UseChatHelpers, UseAssistantHelpers } from 'ai/react';
|
5
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
5
6
|
import { UseBoundStore, StoreApi } from 'zustand';
|
6
7
|
|
7
8
|
declare const ThreadRoot: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
@@ -55,8 +56,18 @@ declare const ThreadScrollToBottom: react.ForwardRefExoticComponent<Pick<Omit<re
|
|
55
56
|
asChild?: boolean;
|
56
57
|
}, "key" | "asChild" | keyof react.ButtonHTMLAttributes<HTMLButtonElement>> & react.RefAttributes<HTMLButtonElement>>;
|
57
58
|
|
59
|
+
declare const ThreadSuggestion: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
60
|
+
ref?: ((instance: HTMLButtonElement | null) => void) | react.RefObject<HTMLButtonElement> | null | undefined;
|
61
|
+
} & {
|
62
|
+
asChild?: boolean;
|
63
|
+
}, "key" | "asChild" | keyof react.ButtonHTMLAttributes<HTMLButtonElement>> & {
|
64
|
+
prompt: string;
|
65
|
+
method: "replace";
|
66
|
+
autoSend?: boolean;
|
67
|
+
} & react.RefAttributes<HTMLButtonElement>>;
|
68
|
+
|
58
69
|
declare namespace index$4 {
|
59
|
-
export { ThreadEmpty as Empty, ThreadIf as If, ThreadMessages as Messages, ThreadRoot as Root, ThreadScrollToBottom as ScrollToBottom, ThreadViewport as Viewport };
|
70
|
+
export { ThreadEmpty as Empty, ThreadIf as If, ThreadMessages as Messages, ThreadRoot as Root, ThreadScrollToBottom as ScrollToBottom, ThreadSuggestion as Suggestion, ThreadViewport as Viewport };
|
60
71
|
}
|
61
72
|
|
62
73
|
declare const ComposerRoot: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, "ref"> & {
|
@@ -102,50 +113,49 @@ type MessageComposerState = BaseComposerState & {
|
|
102
113
|
cancel: () => boolean;
|
103
114
|
};
|
104
115
|
|
105
|
-
type
|
116
|
+
type TextContentPart = {
|
106
117
|
type: "text";
|
107
118
|
text: string;
|
108
119
|
};
|
109
|
-
type
|
120
|
+
type ImageContentPart = {
|
110
121
|
type: "image";
|
111
122
|
image: string;
|
112
123
|
};
|
113
|
-
type
|
124
|
+
type UIContentPart = {
|
114
125
|
type: "ui";
|
115
126
|
display: ReactNode;
|
116
127
|
};
|
117
|
-
type
|
128
|
+
type ToolCallContentPart = {
|
118
129
|
type: "tool-call";
|
119
130
|
name: string;
|
120
131
|
args: object;
|
121
132
|
result?: object;
|
122
133
|
};
|
123
|
-
type
|
124
|
-
type
|
125
|
-
type
|
126
|
-
type
|
134
|
+
type UserContentPart = TextContentPart | ImageContentPart | UIContentPart;
|
135
|
+
type AssistantContentPart = TextContentPart | ImageContentPart | UIContentPart | ToolCallContentPart;
|
136
|
+
type AppendContentPart = TextContentPart | ImageContentPart;
|
137
|
+
type BaseMessage = {
|
127
138
|
id: string;
|
128
|
-
parentId: string | null;
|
129
139
|
createdAt: Date;
|
130
140
|
};
|
131
|
-
type
|
141
|
+
type UserMessage = BaseMessage & {
|
132
142
|
role: "user";
|
133
|
-
content:
|
143
|
+
content: UserContentPart[];
|
134
144
|
};
|
135
|
-
type
|
145
|
+
type AssistantMessage = BaseMessage & {
|
136
146
|
role: "assistant";
|
137
|
-
content:
|
147
|
+
content: AssistantContentPart[];
|
138
148
|
};
|
139
|
-
type
|
149
|
+
type AppendMessage = {
|
140
150
|
parentId: string | null;
|
141
|
-
content:
|
151
|
+
content: AppendContentPart[];
|
142
152
|
};
|
143
|
-
type ThreadMessage =
|
153
|
+
type ThreadMessage = UserMessage | AssistantMessage;
|
144
154
|
|
145
|
-
type MessageProviderProps = {
|
146
|
-
children?: ReactNode;
|
155
|
+
type MessageProviderProps = PropsWithChildren<{
|
147
156
|
message: ThreadMessage;
|
148
|
-
|
157
|
+
parentId: string | null;
|
158
|
+
}>;
|
149
159
|
declare const MessageProvider: FC<MessageProviderProps>;
|
150
160
|
|
151
161
|
declare const MessageRoot: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
@@ -169,20 +179,20 @@ declare const MessageIf: FC<MessageIfProps>;
|
|
169
179
|
type MessageContentProps = {
|
170
180
|
components?: {
|
171
181
|
Text?: ComponentType<{
|
172
|
-
part:
|
182
|
+
part: TextContentPart;
|
173
183
|
}>;
|
174
184
|
Image?: ComponentType<{
|
175
|
-
part:
|
185
|
+
part: ImageContentPart;
|
176
186
|
}>;
|
177
187
|
UI?: ComponentType<{
|
178
|
-
part:
|
188
|
+
part: UIContentPart;
|
179
189
|
}>;
|
180
190
|
tools?: {
|
181
191
|
by_name?: Record<string, ComponentType<{
|
182
|
-
part:
|
192
|
+
part: ToolCallContentPart;
|
183
193
|
}>>;
|
184
194
|
Fallback?: ComponentType<{
|
185
|
-
part:
|
195
|
+
part: ToolCallContentPart;
|
186
196
|
}>;
|
187
197
|
};
|
188
198
|
};
|
@@ -269,14 +279,22 @@ type VercelRSCMessage = {
|
|
269
279
|
display: ReactNode;
|
270
280
|
createdAt?: Date;
|
271
281
|
};
|
272
|
-
type
|
273
|
-
messages:
|
274
|
-
append: (message:
|
282
|
+
type VercelRSCAssistantProviderBaseProps<T> = PropsWithChildren<{
|
283
|
+
messages: T[];
|
284
|
+
append: (message: AppendMessage) => Promise<void>;
|
285
|
+
edit?: (message: AppendMessage) => Promise<void>;
|
286
|
+
reload?: (parentId: string | null) => Promise<void>;
|
287
|
+
convertMessage?: (message: T) => VercelRSCMessage;
|
275
288
|
}>;
|
276
|
-
|
289
|
+
type RSCMessageConverter<T> = {
|
290
|
+
convertMessage: (message: T) => VercelRSCMessage;
|
291
|
+
};
|
292
|
+
type VercelRSCAssistantProviderProps<T = VercelRSCMessage> = VercelRSCAssistantProviderBaseProps<T> & (T extends VercelRSCMessage ? object : RSCMessageConverter<T>);
|
293
|
+
declare const VercelRSCAssistantProvider: <T extends WeakKey = VercelRSCMessage>({ children, convertMessage, messages: vercelMessages, append: appendCallback, edit, reload, }: VercelRSCAssistantProviderProps<T>) => react_jsx_runtime.JSX.Element;
|
277
294
|
|
278
295
|
type MessageState = {
|
279
296
|
message: ThreadMessage;
|
297
|
+
parentId: string | null;
|
280
298
|
branches: string[];
|
281
299
|
isLast: boolean;
|
282
300
|
isCopied: boolean;
|
@@ -303,4 +321,4 @@ declare const useGoToNextBranch: () => (() => void) | null;
|
|
303
321
|
|
304
322
|
declare const useGoToPreviousBranch: () => (() => void) | null;
|
305
323
|
|
306
|
-
export { index as ActionBarPrimitive, index$1 as BranchPickerPrimitive, index$3 as ComposerPrimitive, type
|
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 };
|
package/dist/index.d.ts
CHANGED
@@ -2,6 +2,7 @@ import * as react from 'react';
|
|
2
2
|
import { FC, ReactNode, PropsWithChildren, ComponentType } from 'react';
|
3
3
|
import { TextareaAutosizeProps } from 'react-textarea-autosize';
|
4
4
|
import { UseChatHelpers, UseAssistantHelpers } from 'ai/react';
|
5
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
5
6
|
import { UseBoundStore, StoreApi } from 'zustand';
|
6
7
|
|
7
8
|
declare const ThreadRoot: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
@@ -55,8 +56,18 @@ declare const ThreadScrollToBottom: react.ForwardRefExoticComponent<Pick<Omit<re
|
|
55
56
|
asChild?: boolean;
|
56
57
|
}, "key" | "asChild" | keyof react.ButtonHTMLAttributes<HTMLButtonElement>> & react.RefAttributes<HTMLButtonElement>>;
|
57
58
|
|
59
|
+
declare const ThreadSuggestion: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
60
|
+
ref?: ((instance: HTMLButtonElement | null) => void) | react.RefObject<HTMLButtonElement> | null | undefined;
|
61
|
+
} & {
|
62
|
+
asChild?: boolean;
|
63
|
+
}, "key" | "asChild" | keyof react.ButtonHTMLAttributes<HTMLButtonElement>> & {
|
64
|
+
prompt: string;
|
65
|
+
method: "replace";
|
66
|
+
autoSend?: boolean;
|
67
|
+
} & react.RefAttributes<HTMLButtonElement>>;
|
68
|
+
|
58
69
|
declare namespace index$4 {
|
59
|
-
export { ThreadEmpty as Empty, ThreadIf as If, ThreadMessages as Messages, ThreadRoot as Root, ThreadScrollToBottom as ScrollToBottom, ThreadViewport as Viewport };
|
70
|
+
export { ThreadEmpty as Empty, ThreadIf as If, ThreadMessages as Messages, ThreadRoot as Root, ThreadScrollToBottom as ScrollToBottom, ThreadSuggestion as Suggestion, ThreadViewport as Viewport };
|
60
71
|
}
|
61
72
|
|
62
73
|
declare const ComposerRoot: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, "ref"> & {
|
@@ -102,50 +113,49 @@ type MessageComposerState = BaseComposerState & {
|
|
102
113
|
cancel: () => boolean;
|
103
114
|
};
|
104
115
|
|
105
|
-
type
|
116
|
+
type TextContentPart = {
|
106
117
|
type: "text";
|
107
118
|
text: string;
|
108
119
|
};
|
109
|
-
type
|
120
|
+
type ImageContentPart = {
|
110
121
|
type: "image";
|
111
122
|
image: string;
|
112
123
|
};
|
113
|
-
type
|
124
|
+
type UIContentPart = {
|
114
125
|
type: "ui";
|
115
126
|
display: ReactNode;
|
116
127
|
};
|
117
|
-
type
|
128
|
+
type ToolCallContentPart = {
|
118
129
|
type: "tool-call";
|
119
130
|
name: string;
|
120
131
|
args: object;
|
121
132
|
result?: object;
|
122
133
|
};
|
123
|
-
type
|
124
|
-
type
|
125
|
-
type
|
126
|
-
type
|
134
|
+
type UserContentPart = TextContentPart | ImageContentPart | UIContentPart;
|
135
|
+
type AssistantContentPart = TextContentPart | ImageContentPart | UIContentPart | ToolCallContentPart;
|
136
|
+
type AppendContentPart = TextContentPart | ImageContentPart;
|
137
|
+
type BaseMessage = {
|
127
138
|
id: string;
|
128
|
-
parentId: string | null;
|
129
139
|
createdAt: Date;
|
130
140
|
};
|
131
|
-
type
|
141
|
+
type UserMessage = BaseMessage & {
|
132
142
|
role: "user";
|
133
|
-
content:
|
143
|
+
content: UserContentPart[];
|
134
144
|
};
|
135
|
-
type
|
145
|
+
type AssistantMessage = BaseMessage & {
|
136
146
|
role: "assistant";
|
137
|
-
content:
|
147
|
+
content: AssistantContentPart[];
|
138
148
|
};
|
139
|
-
type
|
149
|
+
type AppendMessage = {
|
140
150
|
parentId: string | null;
|
141
|
-
content:
|
151
|
+
content: AppendContentPart[];
|
142
152
|
};
|
143
|
-
type ThreadMessage =
|
153
|
+
type ThreadMessage = UserMessage | AssistantMessage;
|
144
154
|
|
145
|
-
type MessageProviderProps = {
|
146
|
-
children?: ReactNode;
|
155
|
+
type MessageProviderProps = PropsWithChildren<{
|
147
156
|
message: ThreadMessage;
|
148
|
-
|
157
|
+
parentId: string | null;
|
158
|
+
}>;
|
149
159
|
declare const MessageProvider: FC<MessageProviderProps>;
|
150
160
|
|
151
161
|
declare const MessageRoot: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
@@ -169,20 +179,20 @@ declare const MessageIf: FC<MessageIfProps>;
|
|
169
179
|
type MessageContentProps = {
|
170
180
|
components?: {
|
171
181
|
Text?: ComponentType<{
|
172
|
-
part:
|
182
|
+
part: TextContentPart;
|
173
183
|
}>;
|
174
184
|
Image?: ComponentType<{
|
175
|
-
part:
|
185
|
+
part: ImageContentPart;
|
176
186
|
}>;
|
177
187
|
UI?: ComponentType<{
|
178
|
-
part:
|
188
|
+
part: UIContentPart;
|
179
189
|
}>;
|
180
190
|
tools?: {
|
181
191
|
by_name?: Record<string, ComponentType<{
|
182
|
-
part:
|
192
|
+
part: ToolCallContentPart;
|
183
193
|
}>>;
|
184
194
|
Fallback?: ComponentType<{
|
185
|
-
part:
|
195
|
+
part: ToolCallContentPart;
|
186
196
|
}>;
|
187
197
|
};
|
188
198
|
};
|
@@ -269,14 +279,22 @@ type VercelRSCMessage = {
|
|
269
279
|
display: ReactNode;
|
270
280
|
createdAt?: Date;
|
271
281
|
};
|
272
|
-
type
|
273
|
-
messages:
|
274
|
-
append: (message:
|
282
|
+
type VercelRSCAssistantProviderBaseProps<T> = PropsWithChildren<{
|
283
|
+
messages: T[];
|
284
|
+
append: (message: AppendMessage) => Promise<void>;
|
285
|
+
edit?: (message: AppendMessage) => Promise<void>;
|
286
|
+
reload?: (parentId: string | null) => Promise<void>;
|
287
|
+
convertMessage?: (message: T) => VercelRSCMessage;
|
275
288
|
}>;
|
276
|
-
|
289
|
+
type RSCMessageConverter<T> = {
|
290
|
+
convertMessage: (message: T) => VercelRSCMessage;
|
291
|
+
};
|
292
|
+
type VercelRSCAssistantProviderProps<T = VercelRSCMessage> = VercelRSCAssistantProviderBaseProps<T> & (T extends VercelRSCMessage ? object : RSCMessageConverter<T>);
|
293
|
+
declare const VercelRSCAssistantProvider: <T extends WeakKey = VercelRSCMessage>({ children, convertMessage, messages: vercelMessages, append: appendCallback, edit, reload, }: VercelRSCAssistantProviderProps<T>) => react_jsx_runtime.JSX.Element;
|
277
294
|
|
278
295
|
type MessageState = {
|
279
296
|
message: ThreadMessage;
|
297
|
+
parentId: string | null;
|
280
298
|
branches: string[];
|
281
299
|
isLast: boolean;
|
282
300
|
isCopied: boolean;
|
@@ -303,4 +321,4 @@ declare const useGoToNextBranch: () => (() => void) | null;
|
|
303
321
|
|
304
322
|
declare const useGoToPreviousBranch: () => (() => void) | null;
|
305
323
|
|
306
|
-
export { index as ActionBarPrimitive, index$1 as BranchPickerPrimitive, index$3 as ComposerPrimitive, type
|
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 };
|