@assistant-ui/react 0.7.35 → 0.7.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/MessageRuntime.d.ts.map +1 -1
- package/dist/api/MessageRuntime.js +1 -0
- package/dist/api/MessageRuntime.js.map +1 -1
- package/dist/api/MessageRuntime.mjs +1 -0
- package/dist/api/MessageRuntime.mjs.map +1 -1
- package/dist/api/ThreadRuntime.d.ts +6 -1
- package/dist/api/ThreadRuntime.d.ts.map +1 -1
- package/dist/api/ThreadRuntime.js +4 -1
- package/dist/api/ThreadRuntime.js.map +1 -1
- package/dist/api/ThreadRuntime.mjs +4 -1
- package/dist/api/ThreadRuntime.mjs.map +1 -1
- package/dist/internal.d.ts +3 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +10 -1
- package/dist/internal.js.map +1 -1
- package/dist/internal.mjs +7 -1
- package/dist/internal.mjs.map +1 -1
- package/dist/primitive-hooks/contentPart/useContentPartDisplay.d.ts +3 -0
- package/dist/primitive-hooks/contentPart/useContentPartDisplay.d.ts.map +1 -1
- package/dist/primitive-hooks/contentPart/useContentPartDisplay.js.map +1 -1
- package/dist/primitive-hooks/contentPart/useContentPartDisplay.mjs.map +1 -1
- package/dist/primitives/message/MessageContent.d.ts +2 -1
- package/dist/primitives/message/MessageContent.d.ts.map +1 -1
- package/dist/primitives/message/MessageContent.js +6 -2
- package/dist/primitives/message/MessageContent.js.map +1 -1
- package/dist/primitives/message/MessageContent.mjs +6 -2
- package/dist/primitives/message/MessageContent.mjs.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.js +1 -0
- package/dist/runtimes/composer/BaseComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs +1 -0
- package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.d.ts +2 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js +4 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs +4 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.d.ts +1 -1
- package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.js +2 -1
- package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.mjs +2 -1
- package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/core/ComposerRuntimeCore.d.ts +1 -1
- package/dist/runtimes/core/ComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/ComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/ThreadRuntimeCore.d.ts +2 -1
- package/dist/runtimes/core/ThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/ThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/edge/EdgeRuntimeRequestOptions.d.ts +28 -0
- package/dist/runtimes/edge/EdgeRuntimeRequestOptions.d.ts.map +1 -1
- package/dist/runtimes/edge/EdgeRuntimeRequestOptions.js +6 -0
- package/dist/runtimes/edge/EdgeRuntimeRequestOptions.js.map +1 -1
- package/dist/runtimes/edge/EdgeRuntimeRequestOptions.mjs +6 -0
- package/dist/runtimes/edge/EdgeRuntimeRequestOptions.mjs.map +1 -1
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.d.ts.map +1 -1
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.js +8 -1
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.js.map +1 -1
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.mjs +8 -1
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.mjs.map +1 -1
- package/dist/runtimes/edge/converters/toLanguageModelMessages.d.ts.map +1 -1
- package/dist/runtimes/edge/converters/toLanguageModelMessages.js +7 -0
- package/dist/runtimes/edge/converters/toLanguageModelMessages.js.map +1 -1
- package/dist/runtimes/edge/converters/toLanguageModelMessages.mjs +7 -0
- package/dist/runtimes/edge/converters/toLanguageModelMessages.mjs.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.d.ts +3 -3
- package/dist/runtimes/external-store/ThreadMessageLike.d.ts.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.js +7 -2
- package/dist/runtimes/external-store/ThreadMessageLike.js.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.mjs +7 -2
- package/dist/runtimes/external-store/ThreadMessageLike.mjs.map +1 -1
- package/dist/runtimes/local/LocalRuntimeCore.d.ts +2 -1
- package/dist/runtimes/local/LocalRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalRuntimeCore.js +7 -2
- package/dist/runtimes/local/LocalRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalRuntimeCore.mjs +7 -2
- package/dist/runtimes/local/LocalRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/local/LocalRuntimeOptions.d.ts +3 -3
- package/dist/runtimes/local/LocalRuntimeOptions.d.ts.map +1 -1
- package/dist/runtimes/local/LocalRuntimeOptions.js.map +1 -1
- package/dist/runtimes/local/LocalRuntimeOptions.mjs.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.js +1 -0
- package/dist/runtimes/local/LocalThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.mjs +1 -0
- package/dist/runtimes/local/LocalThreadRuntimeCore.mjs.map +1 -1
- package/dist/styles/index.css +1 -0
- package/dist/styles/index.css.map +1 -1
- package/dist/styles/tailwindcss/thread.css +1 -1
- package/dist/styles/tailwindcss/thread.css.json +1 -1
- package/dist/types/AssistantTypes.d.ts +47 -4
- package/dist/types/AssistantTypes.d.ts.map +1 -1
- package/dist/types/AssistantTypes.js.map +1 -1
- package/dist/types/ContentPartComponentTypes.d.ts +3 -1
- package/dist/types/ContentPartComponentTypes.d.ts.map +1 -1
- package/dist/types/ContentPartComponentTypes.js.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/MessageRuntime.ts +1 -0
- package/src/api/ThreadRuntime.ts +10 -1
- package/src/internal.ts +3 -0
- package/src/primitive-hooks/contentPart/useContentPartDisplay.tsx +3 -0
- package/src/primitives/message/MessageContent.tsx +9 -1
- package/src/runtimes/composer/BaseComposerRuntimeCore.tsx +5 -2
- package/src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx +7 -2
- package/src/runtimes/composer/DefaultThreadComposerRuntimeCore.tsx +4 -1
- package/src/runtimes/core/ComposerRuntimeCore.tsx +1 -1
- package/src/runtimes/core/ThreadRuntimeCore.tsx +2 -1
- package/src/runtimes/edge/EdgeRuntimeRequestOptions.ts +7 -0
- package/src/runtimes/edge/converters/fromLanguageModelMessages.ts +9 -2
- package/src/runtimes/edge/converters/toLanguageModelMessages.ts +15 -1
- package/src/runtimes/external-store/ThreadMessageLike.tsx +11 -4
- package/src/runtimes/local/LocalRuntimeCore.tsx +10 -4
- package/src/runtimes/local/LocalRuntimeOptions.tsx +2 -2
- package/src/runtimes/local/LocalThreadRuntimeCore.tsx +1 -0
- package/src/styles/tailwindcss/thread.css +1 -1
- package/src/types/AssistantTypes.ts +50 -2
- package/src/types/ContentPartComponentTypes.tsx +4 -0
- package/src/types/index.ts +6 -5
|
@@ -13,6 +13,12 @@ export type ImageContentPart = {
|
|
|
13
13
|
readonly image: string;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
+
export type FileContentPart = {
|
|
17
|
+
readonly type: "file";
|
|
18
|
+
readonly data: string;
|
|
19
|
+
readonly mimeType: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
16
22
|
export type Unstable_AudioContentPart = {
|
|
17
23
|
readonly type: "audio";
|
|
18
24
|
readonly audio: {
|
|
@@ -21,6 +27,43 @@ export type Unstable_AudioContentPart = {
|
|
|
21
27
|
};
|
|
22
28
|
};
|
|
23
29
|
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated UI content parts are deprecated and will be removed in v0.8.0.
|
|
32
|
+
* Migration guide for external-store users using UI content parts:
|
|
33
|
+
* If you must, store UI elements on your external store messages, update your
|
|
34
|
+
* external store converter:
|
|
35
|
+
* ```ts
|
|
36
|
+
* const UI_PLACEHOLDER = Object.freeze({ type: "text", text: "UI content placeholder" });
|
|
37
|
+
* const convertMessage = (message: TMessage): ThreadMessageLike => ({
|
|
38
|
+
* content: [
|
|
39
|
+
* // other content parts,
|
|
40
|
+
* UI_PLACEHOLDER
|
|
41
|
+
* ],
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* Then, define a custom `TextContentPartComponent`:
|
|
46
|
+
*
|
|
47
|
+
* ```tsx
|
|
48
|
+
* const MyText: FC = () => {
|
|
49
|
+
* const isUIPlaceholder = useContentPart(p => p === UI_PLACEHOLDER);
|
|
50
|
+
*
|
|
51
|
+
* // this assumes that you have a `display` field on your original message objects before conversion.
|
|
52
|
+
* const ui = useMessage(m => isUIPlaceholder ? getExternalStoreMessage(m).display : undefined);
|
|
53
|
+
* if (ui) {
|
|
54
|
+
* return ui;
|
|
55
|
+
* }
|
|
56
|
+
*
|
|
57
|
+
* return <MarkdownText />; // your default text component
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* Pass this component to your Thread:
|
|
62
|
+
*
|
|
63
|
+
* ```tsx
|
|
64
|
+
* <Thread assistantMessage={{ components: { Text: MyText } }} userMessage={{ components: { Text: MyText } }} />
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
24
67
|
export type UIContentPart = {
|
|
25
68
|
readonly type: "ui";
|
|
26
69
|
readonly display: ReactNode;
|
|
@@ -48,6 +91,7 @@ export type ToolCallContentPart<
|
|
|
48
91
|
export type ThreadUserContentPart =
|
|
49
92
|
| TextContentPart
|
|
50
93
|
| ImageContentPart
|
|
94
|
+
| FileContentPart
|
|
51
95
|
| Unstable_AudioContentPart
|
|
52
96
|
| UIContentPart;
|
|
53
97
|
|
|
@@ -154,10 +198,13 @@ export type RunConfig = {
|
|
|
154
198
|
|
|
155
199
|
export type AppendMessage = CoreMessage & {
|
|
156
200
|
parentId: string | null;
|
|
201
|
+
|
|
202
|
+
/** The ID of the message that was edited or undefined. */
|
|
203
|
+
sourceId: string | null;
|
|
204
|
+
runConfig: RunConfig | undefined;
|
|
205
|
+
|
|
157
206
|
attachments: readonly CompleteAttachment[];
|
|
158
207
|
startRun?: boolean | undefined;
|
|
159
|
-
/** TODO: make required in 0.8.0 */
|
|
160
|
-
runConfig?: RunConfig | undefined;
|
|
161
208
|
};
|
|
162
209
|
|
|
163
210
|
type BaseThreadMessage = {
|
|
@@ -178,6 +225,7 @@ export type ThreadMessage = BaseThreadMessage &
|
|
|
178
225
|
export type CoreUserContentPart =
|
|
179
226
|
| TextContentPart
|
|
180
227
|
| ImageContentPart
|
|
228
|
+
| FileContentPart
|
|
181
229
|
| Unstable_AudioContentPart;
|
|
182
230
|
export type CoreAssistantContentPart =
|
|
183
231
|
| TextContentPart
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ComponentType } from "react";
|
|
2
2
|
import type {
|
|
3
3
|
ContentPartStatus,
|
|
4
|
+
FileContentPart,
|
|
4
5
|
ImageContentPart,
|
|
5
6
|
TextContentPart,
|
|
6
7
|
ToolCallContentPart,
|
|
@@ -20,6 +21,9 @@ export type TextContentPartComponent = ComponentType<TextContentPartProps>;
|
|
|
20
21
|
export type ImageContentPartProps = ContentPartState & ImageContentPart;
|
|
21
22
|
export type ImageContentPartComponent = ComponentType<ImageContentPartProps>;
|
|
22
23
|
|
|
24
|
+
export type FileContentPartProps = ContentPartState & FileContentPart;
|
|
25
|
+
export type FileContentPartComponent = ComponentType<FileContentPartProps>;
|
|
26
|
+
|
|
23
27
|
export type Unstable_AudioContentPartProps = ContentPartState &
|
|
24
28
|
Unstable_AudioContentPart;
|
|
25
29
|
export type Unstable_AudioContentPartComponent =
|
package/src/types/index.ts
CHANGED
|
@@ -9,6 +9,8 @@ export type {
|
|
|
9
9
|
AppendMessage,
|
|
10
10
|
TextContentPart,
|
|
11
11
|
ImageContentPart,
|
|
12
|
+
FileContentPart,
|
|
13
|
+
Unstable_AudioContentPart,
|
|
12
14
|
ToolCallContentPart,
|
|
13
15
|
UIContentPart,
|
|
14
16
|
MessageStatus,
|
|
@@ -28,9 +30,6 @@ export type {
|
|
|
28
30
|
CoreUserMessage,
|
|
29
31
|
CoreAssistantMessage,
|
|
30
32
|
CoreMessage,
|
|
31
|
-
|
|
32
|
-
// TODO
|
|
33
|
-
Unstable_AudioContentPart,
|
|
34
33
|
} from "./AssistantTypes";
|
|
35
34
|
|
|
36
35
|
export type {
|
|
@@ -40,12 +39,14 @@ export type {
|
|
|
40
39
|
TextContentPartComponent,
|
|
41
40
|
ImageContentPartProps,
|
|
42
41
|
ImageContentPartComponent,
|
|
42
|
+
FileContentPartProps,
|
|
43
|
+
FileContentPartComponent,
|
|
44
|
+
Unstable_AudioContentPartProps,
|
|
45
|
+
Unstable_AudioContentPartComponent,
|
|
43
46
|
UIContentPartProps,
|
|
44
47
|
UIContentPartComponent,
|
|
45
48
|
ToolCallContentPartProps,
|
|
46
49
|
ToolCallContentPartComponent,
|
|
47
|
-
Unstable_AudioContentPartProps,
|
|
48
|
-
Unstable_AudioContentPartComponent,
|
|
49
50
|
} from "./ContentPartComponentTypes";
|
|
50
51
|
|
|
51
52
|
export type {
|