@assistant-ui/react 0.0.6 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.mts +66 -13
- package/dist/index.d.ts +66 -13
- package/dist/index.js +410 -209
- package/dist/index.mjs +402 -198
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import * as react from 'react';
|
2
|
-
import { FC, PropsWithChildren } from 'react';
|
2
|
+
import { FC, PropsWithChildren, ReactNode, ComponentType } from 'react';
|
3
3
|
import { TextareaAutosizeProps } from 'react-textarea-autosize';
|
4
|
-
import { UseChatHelpers } from 'ai/react';
|
4
|
+
import { UseChatHelpers, UseAssistantHelpers } from 'ai/react';
|
5
5
|
import { UseBoundStore, StoreApi } from 'zustand';
|
6
6
|
|
7
7
|
declare const ThreadRoot: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
@@ -30,7 +30,9 @@ declare const ThreadViewport: react.ForwardRefExoticComponent<Pick<Omit<react.De
|
|
30
30
|
ref?: ((instance: HTMLDivElement | null) => void) | react.RefObject<HTMLDivElement> | null | undefined;
|
31
31
|
} & {
|
32
32
|
asChild?: boolean;
|
33
|
-
}, "key" | keyof react.HTMLAttributes<HTMLDivElement> | "asChild"> &
|
33
|
+
}, "key" | keyof react.HTMLAttributes<HTMLDivElement> | "asChild"> & {
|
34
|
+
autoScroll?: boolean;
|
35
|
+
} & react.RefAttributes<HTMLDivElement>>;
|
34
36
|
|
35
37
|
type ThreadMessagesProps = {
|
36
38
|
components: {
|
@@ -47,8 +49,14 @@ type ThreadMessagesProps = {
|
|
47
49
|
};
|
48
50
|
declare const ThreadMessages: FC<ThreadMessagesProps>;
|
49
51
|
|
52
|
+
declare const ThreadScrollToBottom: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
53
|
+
ref?: ((instance: HTMLButtonElement | null) => void) | react.RefObject<HTMLButtonElement> | null | undefined;
|
54
|
+
} & {
|
55
|
+
asChild?: boolean;
|
56
|
+
}, "key" | "asChild" | keyof react.ButtonHTMLAttributes<HTMLButtonElement>> & react.RefAttributes<HTMLButtonElement>>;
|
57
|
+
|
50
58
|
declare namespace index$4 {
|
51
|
-
export { ThreadEmpty as Empty, ThreadIf as If, ThreadMessages as Messages, ThreadRoot as Root, ThreadViewport as Viewport };
|
59
|
+
export { ThreadEmpty as Empty, ThreadIf as If, ThreadMessages as Messages, ThreadRoot as Root, ThreadScrollToBottom as ScrollToBottom, ThreadViewport as Viewport };
|
52
60
|
}
|
53
61
|
|
54
62
|
declare const ComposerRoot: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, "ref"> & {
|
@@ -101,16 +109,26 @@ type ComposerStore = {
|
|
101
109
|
useComposer: UseBoundStore<StoreApi<ComposerState>>;
|
102
110
|
};
|
103
111
|
|
104
|
-
type
|
112
|
+
type ThreadMessageTextPart = {
|
105
113
|
type: "text";
|
106
114
|
text: string;
|
107
115
|
};
|
108
|
-
type
|
116
|
+
type ThreadMessageImagePart = {
|
109
117
|
type: "image";
|
110
118
|
image: string;
|
111
119
|
};
|
112
|
-
type
|
113
|
-
type
|
120
|
+
type ThreadMessageUIPart = {
|
121
|
+
type: "ui";
|
122
|
+
display: ReactNode;
|
123
|
+
};
|
124
|
+
type ThreadMessageToolCallPart = {
|
125
|
+
type: "tool-call";
|
126
|
+
name: string;
|
127
|
+
args: object;
|
128
|
+
result?: object;
|
129
|
+
};
|
130
|
+
type ThreadUserMessageContent = ThreadMessageTextPart | ThreadMessageImagePart | ThreadMessageUIPart;
|
131
|
+
type ThreadAssistantMessageContent = ThreadMessageTextPart | ThreadMessageImagePart | ThreadMessageUIPart | ThreadMessageToolCallPart;
|
114
132
|
type ThreadUserMessage = {
|
115
133
|
id: string;
|
116
134
|
role: "user";
|
@@ -122,6 +140,7 @@ type ThreadAssistantMessage = {
|
|
122
140
|
content: ThreadAssistantMessageContent[];
|
123
141
|
};
|
124
142
|
type ThreadMessage = ThreadUserMessage | ThreadAssistantMessage;
|
143
|
+
type CreateThreadMessage = Omit<ThreadUserMessage, "id">;
|
125
144
|
|
126
145
|
type MessageProviderProps = {
|
127
146
|
children?: React.ReactNode;
|
@@ -147,7 +166,28 @@ type MessageIfProps = RequireAtLeastOne<MessageIfFilters> & {
|
|
147
166
|
};
|
148
167
|
declare const MessageIf: FC<MessageIfProps>;
|
149
168
|
|
150
|
-
|
169
|
+
type MessageContentProps = {
|
170
|
+
components?: {
|
171
|
+
Text?: ComponentType<{
|
172
|
+
part: ThreadMessageTextPart;
|
173
|
+
}>;
|
174
|
+
Image?: ComponentType<{
|
175
|
+
part: ThreadMessageImagePart;
|
176
|
+
}>;
|
177
|
+
UI?: ComponentType<{
|
178
|
+
part: ThreadMessageUIPart;
|
179
|
+
}>;
|
180
|
+
tools?: {
|
181
|
+
by_name?: Record<string, ComponentType<{
|
182
|
+
part: ThreadMessageToolCallPart;
|
183
|
+
}>>;
|
184
|
+
Fallback?: ComponentType<{
|
185
|
+
part: ThreadMessageToolCallPart;
|
186
|
+
}>;
|
187
|
+
};
|
188
|
+
};
|
189
|
+
};
|
190
|
+
declare const MessageContent: FC<MessageContentProps>;
|
151
191
|
|
152
192
|
declare namespace index$2 {
|
153
193
|
export { MessageContent as Content, MessageIf as If, MessageProvider as Provider, MessageRoot as Root };
|
@@ -216,11 +256,23 @@ declare namespace index {
|
|
216
256
|
export { ActionBarCopy as Copy, ActionBarEdit as Edit, ActionBarReload as Reload, ActionBarRoot as Root };
|
217
257
|
}
|
218
258
|
|
219
|
-
type
|
259
|
+
type VercelAIAssistantProviderProps$1 = PropsWithChildren<{
|
220
260
|
chat: UseChatHelpers;
|
221
|
-
|
261
|
+
} | {
|
262
|
+
assistant: UseAssistantHelpers;
|
263
|
+
}>;
|
264
|
+
declare const VercelAIAssistantProvider: FC<VercelAIAssistantProviderProps$1>;
|
265
|
+
|
266
|
+
type RSCMessage = {
|
267
|
+
id: string;
|
268
|
+
role: "user" | "assistant";
|
269
|
+
display: ReactNode;
|
222
270
|
};
|
223
|
-
|
271
|
+
type VercelAIAssistantProviderProps = PropsWithChildren<{
|
272
|
+
messages: RSCMessage[];
|
273
|
+
append: (message: CreateThreadMessage) => Promise<void>;
|
274
|
+
}>;
|
275
|
+
declare const VercelRSCAssistantProvider: FC<VercelAIAssistantProviderProps>;
|
224
276
|
|
225
277
|
type MessageState = {
|
226
278
|
message: ThreadMessage;
|
@@ -234,6 +286,7 @@ type MessageState = {
|
|
234
286
|
type MessageStore = ComposerStore & {
|
235
287
|
useMessage: UseBoundStore<StoreApi<MessageState>>;
|
236
288
|
};
|
289
|
+
|
237
290
|
declare const useMessageContext: () => MessageStore;
|
238
291
|
|
239
292
|
declare const useCopyMessage: ({ copiedDuration }: {
|
@@ -248,4 +301,4 @@ declare const useGoToNextBranch: () => (() => void) | null;
|
|
248
301
|
|
249
302
|
declare const useGoToPreviousBranch: () => (() => void) | null;
|
250
303
|
|
251
|
-
export { index as ActionBarPrimitive, index$1 as BranchPickerPrimitive, index$3 as ComposerPrimitive, index$2 as MessagePrimitive, index$4 as ThreadPrimitive,
|
304
|
+
export { index as ActionBarPrimitive, index$1 as BranchPickerPrimitive, index$3 as ComposerPrimitive, index$2 as MessagePrimitive, index$4 as ThreadPrimitive, VercelAIAssistantProvider, VercelRSCAssistantProvider as unstable_VercelRSCAssistantProvider, useMessageContext as unstable_useMessageContext, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useReloadMessage };
|
package/dist/index.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import * as react from 'react';
|
2
|
-
import { FC, PropsWithChildren } from 'react';
|
2
|
+
import { FC, PropsWithChildren, ReactNode, ComponentType } from 'react';
|
3
3
|
import { TextareaAutosizeProps } from 'react-textarea-autosize';
|
4
|
-
import { UseChatHelpers } from 'ai/react';
|
4
|
+
import { UseChatHelpers, UseAssistantHelpers } from 'ai/react';
|
5
5
|
import { UseBoundStore, StoreApi } from 'zustand';
|
6
6
|
|
7
7
|
declare const ThreadRoot: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
@@ -30,7 +30,9 @@ declare const ThreadViewport: react.ForwardRefExoticComponent<Pick<Omit<react.De
|
|
30
30
|
ref?: ((instance: HTMLDivElement | null) => void) | react.RefObject<HTMLDivElement> | null | undefined;
|
31
31
|
} & {
|
32
32
|
asChild?: boolean;
|
33
|
-
}, "key" | keyof react.HTMLAttributes<HTMLDivElement> | "asChild"> &
|
33
|
+
}, "key" | keyof react.HTMLAttributes<HTMLDivElement> | "asChild"> & {
|
34
|
+
autoScroll?: boolean;
|
35
|
+
} & react.RefAttributes<HTMLDivElement>>;
|
34
36
|
|
35
37
|
type ThreadMessagesProps = {
|
36
38
|
components: {
|
@@ -47,8 +49,14 @@ type ThreadMessagesProps = {
|
|
47
49
|
};
|
48
50
|
declare const ThreadMessages: FC<ThreadMessagesProps>;
|
49
51
|
|
52
|
+
declare const ThreadScrollToBottom: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
53
|
+
ref?: ((instance: HTMLButtonElement | null) => void) | react.RefObject<HTMLButtonElement> | null | undefined;
|
54
|
+
} & {
|
55
|
+
asChild?: boolean;
|
56
|
+
}, "key" | "asChild" | keyof react.ButtonHTMLAttributes<HTMLButtonElement>> & react.RefAttributes<HTMLButtonElement>>;
|
57
|
+
|
50
58
|
declare namespace index$4 {
|
51
|
-
export { ThreadEmpty as Empty, ThreadIf as If, ThreadMessages as Messages, ThreadRoot as Root, ThreadViewport as Viewport };
|
59
|
+
export { ThreadEmpty as Empty, ThreadIf as If, ThreadMessages as Messages, ThreadRoot as Root, ThreadScrollToBottom as ScrollToBottom, ThreadViewport as Viewport };
|
52
60
|
}
|
53
61
|
|
54
62
|
declare const ComposerRoot: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, "ref"> & {
|
@@ -101,16 +109,26 @@ type ComposerStore = {
|
|
101
109
|
useComposer: UseBoundStore<StoreApi<ComposerState>>;
|
102
110
|
};
|
103
111
|
|
104
|
-
type
|
112
|
+
type ThreadMessageTextPart = {
|
105
113
|
type: "text";
|
106
114
|
text: string;
|
107
115
|
};
|
108
|
-
type
|
116
|
+
type ThreadMessageImagePart = {
|
109
117
|
type: "image";
|
110
118
|
image: string;
|
111
119
|
};
|
112
|
-
type
|
113
|
-
type
|
120
|
+
type ThreadMessageUIPart = {
|
121
|
+
type: "ui";
|
122
|
+
display: ReactNode;
|
123
|
+
};
|
124
|
+
type ThreadMessageToolCallPart = {
|
125
|
+
type: "tool-call";
|
126
|
+
name: string;
|
127
|
+
args: object;
|
128
|
+
result?: object;
|
129
|
+
};
|
130
|
+
type ThreadUserMessageContent = ThreadMessageTextPart | ThreadMessageImagePart | ThreadMessageUIPart;
|
131
|
+
type ThreadAssistantMessageContent = ThreadMessageTextPart | ThreadMessageImagePart | ThreadMessageUIPart | ThreadMessageToolCallPart;
|
114
132
|
type ThreadUserMessage = {
|
115
133
|
id: string;
|
116
134
|
role: "user";
|
@@ -122,6 +140,7 @@ type ThreadAssistantMessage = {
|
|
122
140
|
content: ThreadAssistantMessageContent[];
|
123
141
|
};
|
124
142
|
type ThreadMessage = ThreadUserMessage | ThreadAssistantMessage;
|
143
|
+
type CreateThreadMessage = Omit<ThreadUserMessage, "id">;
|
125
144
|
|
126
145
|
type MessageProviderProps = {
|
127
146
|
children?: React.ReactNode;
|
@@ -147,7 +166,28 @@ type MessageIfProps = RequireAtLeastOne<MessageIfFilters> & {
|
|
147
166
|
};
|
148
167
|
declare const MessageIf: FC<MessageIfProps>;
|
149
168
|
|
150
|
-
|
169
|
+
type MessageContentProps = {
|
170
|
+
components?: {
|
171
|
+
Text?: ComponentType<{
|
172
|
+
part: ThreadMessageTextPart;
|
173
|
+
}>;
|
174
|
+
Image?: ComponentType<{
|
175
|
+
part: ThreadMessageImagePart;
|
176
|
+
}>;
|
177
|
+
UI?: ComponentType<{
|
178
|
+
part: ThreadMessageUIPart;
|
179
|
+
}>;
|
180
|
+
tools?: {
|
181
|
+
by_name?: Record<string, ComponentType<{
|
182
|
+
part: ThreadMessageToolCallPart;
|
183
|
+
}>>;
|
184
|
+
Fallback?: ComponentType<{
|
185
|
+
part: ThreadMessageToolCallPart;
|
186
|
+
}>;
|
187
|
+
};
|
188
|
+
};
|
189
|
+
};
|
190
|
+
declare const MessageContent: FC<MessageContentProps>;
|
151
191
|
|
152
192
|
declare namespace index$2 {
|
153
193
|
export { MessageContent as Content, MessageIf as If, MessageProvider as Provider, MessageRoot as Root };
|
@@ -216,11 +256,23 @@ declare namespace index {
|
|
216
256
|
export { ActionBarCopy as Copy, ActionBarEdit as Edit, ActionBarReload as Reload, ActionBarRoot as Root };
|
217
257
|
}
|
218
258
|
|
219
|
-
type
|
259
|
+
type VercelAIAssistantProviderProps$1 = PropsWithChildren<{
|
220
260
|
chat: UseChatHelpers;
|
221
|
-
|
261
|
+
} | {
|
262
|
+
assistant: UseAssistantHelpers;
|
263
|
+
}>;
|
264
|
+
declare const VercelAIAssistantProvider: FC<VercelAIAssistantProviderProps$1>;
|
265
|
+
|
266
|
+
type RSCMessage = {
|
267
|
+
id: string;
|
268
|
+
role: "user" | "assistant";
|
269
|
+
display: ReactNode;
|
222
270
|
};
|
223
|
-
|
271
|
+
type VercelAIAssistantProviderProps = PropsWithChildren<{
|
272
|
+
messages: RSCMessage[];
|
273
|
+
append: (message: CreateThreadMessage) => Promise<void>;
|
274
|
+
}>;
|
275
|
+
declare const VercelRSCAssistantProvider: FC<VercelAIAssistantProviderProps>;
|
224
276
|
|
225
277
|
type MessageState = {
|
226
278
|
message: ThreadMessage;
|
@@ -234,6 +286,7 @@ type MessageState = {
|
|
234
286
|
type MessageStore = ComposerStore & {
|
235
287
|
useMessage: UseBoundStore<StoreApi<MessageState>>;
|
236
288
|
};
|
289
|
+
|
237
290
|
declare const useMessageContext: () => MessageStore;
|
238
291
|
|
239
292
|
declare const useCopyMessage: ({ copiedDuration }: {
|
@@ -248,4 +301,4 @@ declare const useGoToNextBranch: () => (() => void) | null;
|
|
248
301
|
|
249
302
|
declare const useGoToPreviousBranch: () => (() => void) | null;
|
250
303
|
|
251
|
-
export { index as ActionBarPrimitive, index$1 as BranchPickerPrimitive, index$3 as ComposerPrimitive, index$2 as MessagePrimitive, index$4 as ThreadPrimitive,
|
304
|
+
export { index as ActionBarPrimitive, index$1 as BranchPickerPrimitive, index$3 as ComposerPrimitive, index$2 as MessagePrimitive, index$4 as ThreadPrimitive, VercelAIAssistantProvider, VercelRSCAssistantProvider as unstable_VercelRSCAssistantProvider, useMessageContext as unstable_useMessageContext, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useReloadMessage };
|