@assistant-ui/react 0.7.35 → 0.7.37
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -9,6 +9,11 @@ export type ImageContentPart = {
|
|
9
9
|
readonly type: "image";
|
10
10
|
readonly image: string;
|
11
11
|
};
|
12
|
+
export type FileContentPart = {
|
13
|
+
readonly type: "file";
|
14
|
+
readonly data: string;
|
15
|
+
readonly mimeType: string;
|
16
|
+
};
|
12
17
|
export type Unstable_AudioContentPart = {
|
13
18
|
readonly type: "audio";
|
14
19
|
readonly audio: {
|
@@ -16,6 +21,43 @@ export type Unstable_AudioContentPart = {
|
|
16
21
|
readonly format: "mp3" | "wav";
|
17
22
|
};
|
18
23
|
};
|
24
|
+
/**
|
25
|
+
* @deprecated UI content parts are deprecated and will be removed in v0.8.0.
|
26
|
+
* Migration guide for external-store users using UI content parts:
|
27
|
+
* If you must, store UI elements on your external store messages, update your
|
28
|
+
* external store converter:
|
29
|
+
* ```ts
|
30
|
+
* const UI_PLACEHOLDER = Object.freeze({ type: "text", text: "UI content placeholder" });
|
31
|
+
* const convertMessage = (message: TMessage): ThreadMessageLike => ({
|
32
|
+
* content: [
|
33
|
+
* // other content parts,
|
34
|
+
* UI_PLACEHOLDER
|
35
|
+
* ],
|
36
|
+
* });
|
37
|
+
* ```
|
38
|
+
*
|
39
|
+
* Then, define a custom `TextContentPartComponent`:
|
40
|
+
*
|
41
|
+
* ```tsx
|
42
|
+
* const MyText: FC = () => {
|
43
|
+
* const isUIPlaceholder = useContentPart(p => p === UI_PLACEHOLDER);
|
44
|
+
*
|
45
|
+
* // this assumes that you have a `display` field on your original message objects before conversion.
|
46
|
+
* const ui = useMessage(m => isUIPlaceholder ? getExternalStoreMessage(m).display : undefined);
|
47
|
+
* if (ui) {
|
48
|
+
* return ui;
|
49
|
+
* }
|
50
|
+
*
|
51
|
+
* return <MarkdownText />; // your default text component
|
52
|
+
* }
|
53
|
+
* ```
|
54
|
+
*
|
55
|
+
* Pass this component to your Thread:
|
56
|
+
*
|
57
|
+
* ```tsx
|
58
|
+
* <Thread assistantMessage={{ components: { Text: MyText } }} userMessage={{ components: { Text: MyText } }} />
|
59
|
+
* ```
|
60
|
+
*/
|
19
61
|
export type UIContentPart = {
|
20
62
|
readonly type: "ui";
|
21
63
|
readonly display: ReactNode;
|
@@ -31,7 +73,7 @@ export type CoreToolCallContentPart<TArgs extends Record<string, unknown> = Reco
|
|
31
73
|
export type ToolCallContentPart<TArgs extends Record<string, unknown> = Record<string | number, unknown>, TResult = unknown> = CoreToolCallContentPart<TArgs, TResult> & {
|
32
74
|
readonly argsText: string;
|
33
75
|
};
|
34
|
-
export type ThreadUserContentPart = TextContentPart | ImageContentPart | Unstable_AudioContentPart | UIContentPart;
|
76
|
+
export type ThreadUserContentPart = TextContentPart | ImageContentPart | FileContentPart | Unstable_AudioContentPart | UIContentPart;
|
35
77
|
export type ThreadAssistantContentPart = TextContentPart | ToolCallContentPart | UIContentPart;
|
36
78
|
type MessageCommonProps = {
|
37
79
|
readonly id: string;
|
@@ -99,10 +141,11 @@ export type RunConfig = {
|
|
99
141
|
};
|
100
142
|
export type AppendMessage = CoreMessage & {
|
101
143
|
parentId: string | null;
|
144
|
+
/** The ID of the message that was edited or undefined. */
|
145
|
+
sourceId: string | null;
|
146
|
+
runConfig: RunConfig | undefined;
|
102
147
|
attachments: readonly CompleteAttachment[];
|
103
148
|
startRun?: boolean | undefined;
|
104
|
-
/** TODO: make required in 0.8.0 */
|
105
|
-
runConfig?: RunConfig | undefined;
|
106
149
|
};
|
107
150
|
type BaseThreadMessage = {
|
108
151
|
readonly status?: ThreadAssistantMessage["status"];
|
@@ -115,7 +158,7 @@ type BaseThreadMessage = {
|
|
115
158
|
};
|
116
159
|
export type ThreadMessage = BaseThreadMessage & (ThreadSystemMessage | ThreadUserMessage | ThreadAssistantMessage);
|
117
160
|
/** Core Message Types (without UI content parts) */
|
118
|
-
export type CoreUserContentPart = TextContentPart | ImageContentPart | Unstable_AudioContentPart;
|
161
|
+
export type CoreUserContentPart = TextContentPart | ImageContentPart | FileContentPart | Unstable_AudioContentPart;
|
119
162
|
export type CoreAssistantContentPart = TextContentPart | CoreToolCallContentPart;
|
120
163
|
export type CoreSystemMessage = {
|
121
164
|
role: "system";
|
@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MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,SAAS,CAAC,eAAe,CAAC,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,SAAS,mBAAmB,EAAE,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,SAAS,wBAAwB,EAAE,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,WAAW,GACnB,iBAAiB,GACjB,eAAe,GACf,oBAAoB,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/types/AssistantTypes.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { CompleteAttachment } from \"./AttachmentTypes\";\n\nexport type MessageRole = \"user\" | \"assistant\" | \"system\";\n\nexport type TextContentPart = {\n readonly type: \"text\";\n readonly text: string;\n};\n\nexport type ImageContentPart = {\n readonly type: \"image\";\n readonly image: string;\n};\n\nexport type Unstable_AudioContentPart = {\n readonly type: \"audio\";\n readonly audio: {\n readonly data: string;\n readonly format: \"mp3\" | \"wav\";\n };\n};\n\nexport type UIContentPart = {\n readonly type: \"ui\";\n readonly display: ReactNode;\n};\n\nexport type CoreToolCallContentPart<\n TArgs extends Record<string, unknown> = Record<string | number, unknown>,\n TResult = unknown,\n> = {\n readonly type: \"tool-call\";\n readonly toolCallId: string;\n readonly toolName: string;\n readonly args: TArgs;\n readonly result?: TResult | undefined;\n readonly isError?: boolean | undefined;\n};\n\nexport type ToolCallContentPart<\n TArgs extends Record<string, unknown> = Record<string | number, unknown>,\n TResult = unknown,\n> = CoreToolCallContentPart<TArgs, TResult> & {\n readonly argsText: string;\n};\n\nexport type ThreadUserContentPart =\n | TextContentPart\n | ImageContentPart\n | Unstable_AudioContentPart\n | UIContentPart;\n\nexport type ThreadAssistantContentPart =\n | TextContentPart\n | ToolCallContentPart\n | UIContentPart;\n\ntype MessageCommonProps = {\n readonly id: string;\n readonly createdAt: Date;\n};\n\nexport type ThreadStep = {\n readonly usage?:\n | {\n readonly promptTokens: number;\n readonly completionTokens: number;\n }\n | undefined;\n};\n\nexport type ContentPartStatus =\n | {\n readonly type: \"running\";\n }\n | {\n readonly type: \"complete\";\n }\n | {\n readonly type: \"incomplete\";\n readonly reason:\n | \"cancelled\"\n | \"length\"\n | \"content-filter\"\n | \"other\"\n | \"error\";\n readonly error?: unknown;\n };\n\nexport type ToolCallContentPartStatus =\n | {\n readonly type: \"requires-action\";\n readonly reason: \"tool-calls\";\n }\n | ContentPartStatus;\n\nexport type MessageStatus =\n | {\n readonly type: \"running\";\n }\n | {\n readonly type: \"requires-action\";\n readonly reason: \"tool-calls\";\n }\n | {\n readonly type: \"complete\";\n readonly reason: \"stop\" | \"unknown\";\n }\n | {\n readonly type: \"incomplete\";\n readonly reason:\n | \"cancelled\"\n | \"tool-calls\"\n | \"length\"\n | \"content-filter\"\n | \"other\"\n | \"error\";\n readonly error?: unknown;\n };\n\nexport type ThreadSystemMessage = MessageCommonProps & {\n readonly role: \"system\";\n readonly content: readonly [TextContentPart];\n readonly metadata: {\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type ThreadUserMessage = MessageCommonProps & {\n readonly role: \"user\";\n readonly content: readonly ThreadUserContentPart[];\n readonly attachments: readonly CompleteAttachment[];\n readonly metadata: {\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type ThreadAssistantMessage = MessageCommonProps & {\n readonly role: \"assistant\";\n readonly content: readonly ThreadAssistantContentPart[];\n readonly status: MessageStatus;\n readonly metadata: {\n readonly unstable_data: readonly unknown[];\n readonly steps: readonly ThreadStep[];\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type RunConfig = {\n // TODO allow user customization via global type overrides\n readonly custom?: Record<string, unknown>;\n};\n\nexport type AppendMessage = CoreMessage & {\n parentId: string | null;\n
|
1
|
+
{"version":3,"sources":["../../src/types/AssistantTypes.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { CompleteAttachment } from \"./AttachmentTypes\";\n\nexport type MessageRole = \"user\" | \"assistant\" | \"system\";\n\nexport type TextContentPart = {\n readonly type: \"text\";\n readonly text: string;\n};\n\nexport type ImageContentPart = {\n readonly type: \"image\";\n readonly image: string;\n};\n\nexport type FileContentPart = {\n readonly type: \"file\";\n readonly data: string;\n readonly mimeType: string;\n};\n\nexport type Unstable_AudioContentPart = {\n readonly type: \"audio\";\n readonly audio: {\n readonly data: string;\n readonly format: \"mp3\" | \"wav\";\n };\n};\n\n/**\n * @deprecated UI content parts are deprecated and will be removed in v0.8.0.\n * Migration guide for external-store users using UI content parts:\n * If you must, store UI elements on your external store messages, update your\n * external store converter:\n * ```ts\n * const UI_PLACEHOLDER = Object.freeze({ type: \"text\", text: \"UI content placeholder\" });\n * const convertMessage = (message: TMessage): ThreadMessageLike => ({\n * content: [\n * // other content parts,\n * UI_PLACEHOLDER\n * ],\n * });\n * ```\n *\n * Then, define a custom `TextContentPartComponent`:\n *\n * ```tsx\n * const MyText: FC = () => {\n * const isUIPlaceholder = useContentPart(p => p === UI_PLACEHOLDER);\n *\n * // this assumes that you have a `display` field on your original message objects before conversion.\n * const ui = useMessage(m => isUIPlaceholder ? getExternalStoreMessage(m).display : undefined);\n * if (ui) {\n * return ui;\n * }\n *\n * return <MarkdownText />; // your default text component\n * }\n * ```\n *\n * Pass this component to your Thread:\n *\n * ```tsx\n * <Thread assistantMessage={{ components: { Text: MyText } }} userMessage={{ components: { Text: MyText } }} />\n * ```\n */\nexport type UIContentPart = {\n readonly type: \"ui\";\n readonly display: ReactNode;\n};\n\nexport type CoreToolCallContentPart<\n TArgs extends Record<string, unknown> = Record<string | number, unknown>,\n TResult = unknown,\n> = {\n readonly type: \"tool-call\";\n readonly toolCallId: string;\n readonly toolName: string;\n readonly args: TArgs;\n readonly result?: TResult | undefined;\n readonly isError?: boolean | undefined;\n};\n\nexport type ToolCallContentPart<\n TArgs extends Record<string, unknown> = Record<string | number, unknown>,\n TResult = unknown,\n> = CoreToolCallContentPart<TArgs, TResult> & {\n readonly argsText: string;\n};\n\nexport type ThreadUserContentPart =\n | TextContentPart\n | ImageContentPart\n | FileContentPart\n | Unstable_AudioContentPart\n | UIContentPart;\n\nexport type ThreadAssistantContentPart =\n | TextContentPart\n | ToolCallContentPart\n | UIContentPart;\n\ntype MessageCommonProps = {\n readonly id: string;\n readonly createdAt: Date;\n};\n\nexport type ThreadStep = {\n readonly usage?:\n | {\n readonly promptTokens: number;\n readonly completionTokens: number;\n }\n | undefined;\n};\n\nexport type ContentPartStatus =\n | {\n readonly type: \"running\";\n }\n | {\n readonly type: \"complete\";\n }\n | {\n readonly type: \"incomplete\";\n readonly reason:\n | \"cancelled\"\n | \"length\"\n | \"content-filter\"\n | \"other\"\n | \"error\";\n readonly error?: unknown;\n };\n\nexport type ToolCallContentPartStatus =\n | {\n readonly type: \"requires-action\";\n readonly reason: \"tool-calls\";\n }\n | ContentPartStatus;\n\nexport type MessageStatus =\n | {\n readonly type: \"running\";\n }\n | {\n readonly type: \"requires-action\";\n readonly reason: \"tool-calls\";\n }\n | {\n readonly type: \"complete\";\n readonly reason: \"stop\" | \"unknown\";\n }\n | {\n readonly type: \"incomplete\";\n readonly reason:\n | \"cancelled\"\n | \"tool-calls\"\n | \"length\"\n | \"content-filter\"\n | \"other\"\n | \"error\";\n readonly error?: unknown;\n };\n\nexport type ThreadSystemMessage = MessageCommonProps & {\n readonly role: \"system\";\n readonly content: readonly [TextContentPart];\n readonly metadata: {\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type ThreadUserMessage = MessageCommonProps & {\n readonly role: \"user\";\n readonly content: readonly ThreadUserContentPart[];\n readonly attachments: readonly CompleteAttachment[];\n readonly metadata: {\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type ThreadAssistantMessage = MessageCommonProps & {\n readonly role: \"assistant\";\n readonly content: readonly ThreadAssistantContentPart[];\n readonly status: MessageStatus;\n readonly metadata: {\n readonly unstable_data: readonly unknown[];\n readonly steps: readonly ThreadStep[];\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type RunConfig = {\n // TODO allow user customization via global type overrides\n readonly custom?: Record<string, unknown>;\n};\n\nexport type AppendMessage = CoreMessage & {\n parentId: string | null;\n\n /** The ID of the message that was edited or undefined. */\n sourceId: string | null;\n runConfig: RunConfig | undefined;\n\n attachments: readonly CompleteAttachment[];\n startRun?: boolean | undefined;\n};\n\ntype BaseThreadMessage = {\n readonly status?: ThreadAssistantMessage[\"status\"];\n readonly metadata: {\n readonly unstable_data?: readonly unknown[];\n readonly steps?: readonly ThreadStep[];\n readonly custom: Record<string, unknown>;\n };\n readonly attachments?: ThreadUserMessage[\"attachments\"];\n};\n\nexport type ThreadMessage = BaseThreadMessage &\n (ThreadSystemMessage | ThreadUserMessage | ThreadAssistantMessage);\n\n/** Core Message Types (without UI content parts) */\n\nexport type CoreUserContentPart =\n | TextContentPart\n | ImageContentPart\n | FileContentPart\n | Unstable_AudioContentPart;\nexport type CoreAssistantContentPart =\n | TextContentPart\n | CoreToolCallContentPart;\n\nexport type CoreSystemMessage = {\n role: \"system\";\n content: readonly [TextContentPart];\n};\n\nexport type CoreUserMessage = {\n role: \"user\";\n content: readonly CoreUserContentPart[];\n};\n\nexport type CoreAssistantMessage = {\n role: \"assistant\";\n content: readonly CoreAssistantContentPart[];\n};\n\nexport type CoreMessage =\n | CoreSystemMessage\n | CoreUserMessage\n | CoreAssistantMessage;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { ComponentType } from "react";
|
2
|
-
import type { ContentPartStatus, ImageContentPart, TextContentPart, ToolCallContentPart, UIContentPart, Unstable_AudioContentPart } from "./AssistantTypes";
|
2
|
+
import type { ContentPartStatus, FileContentPart, ImageContentPart, TextContentPart, ToolCallContentPart, UIContentPart, Unstable_AudioContentPart } from "./AssistantTypes";
|
3
3
|
import { ContentPartState } from "../api/ContentPartRuntime";
|
4
4
|
export type EmptyContentPartProps = {
|
5
5
|
status: ContentPartStatus;
|
@@ -9,6 +9,8 @@ export type TextContentPartProps = ContentPartState & TextContentPart;
|
|
9
9
|
export type TextContentPartComponent = ComponentType<TextContentPartProps>;
|
10
10
|
export type ImageContentPartProps = ContentPartState & ImageContentPart;
|
11
11
|
export type ImageContentPartComponent = ComponentType<ImageContentPartProps>;
|
12
|
+
export type FileContentPartProps = ContentPartState & FileContentPart;
|
13
|
+
export type FileContentPartComponent = ComponentType<FileContentPartProps>;
|
12
14
|
export type Unstable_AudioContentPartProps = ContentPartState & Unstable_AudioContentPart;
|
13
15
|
export type Unstable_AudioContentPartComponent = ComponentType<Unstable_AudioContentPartProps>;
|
14
16
|
export type UIContentPartProps = ContentPartState & UIContentPart;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ContentPartComponentTypes.d.ts","sourceRoot":"","sources":["../../src/types/ContentPartComponentTypes.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,yBAAyB,EAC1B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,iBAAiB,CAAC;CAC3B,CAAC;AACF,MAAM,MAAM,yBAAyB,GAAG,aAAa,CAAC,qBAAqB,CAAC,CAAC;AAE7E,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG,eAAe,CAAC;AACtE,MAAM,MAAM,wBAAwB,GAAG,aAAa,CAAC,oBAAoB,CAAC,CAAC;AAE3E,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AACxE,MAA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AC,CAAC;AAE7E,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG,eAAe,CAAC;AACtE,MAAM,MAAM,wBAAwB,GAAG,aAAa,CAAC,oBAAoB,CAAC,CAAC;AAE3E,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AACxE,MAAM,MAAM,yBAAyB,GAAG,aAAa,CAAC,qBAAqB,CAAC,CAAC;AAE7E,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG,eAAe,CAAC;AACtE,MAAM,MAAM,wBAAwB,GAAG,aAAa,CAAC,oBAAoB,CAAC,CAAC;AAE3E,MAAM,MAAM,8BAA8B,GAAG,gBAAgB,GAC3D,yBAAyB,CAAC;AAC5B,MAAM,MAAM,kCAAkC,GAC5C,aAAa,CAAC,8BAA8B,CAAC,CAAC;AAEhD,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,GAAG,aAAa,CAAC;AAClE,MAAM,MAAM,sBAAsB,GAAG,aAAa,CAAC,kBAAkB,CAAC,CAAC;AAEvE,MAAM,MAAM,wBAAwB,CAClC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,GAAG,EAC3C,OAAO,GAAG,OAAO,IACf,gBAAgB,GAClB,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG;IACpC,SAAS,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;CAClC,CAAC;AAEJ,MAAM,MAAM,4BAA4B,CACtC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,GAAG,EAC3C,OAAO,GAAG,GAAG,IACX,aAAa,CAAC,wBAAwB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/types/ContentPartComponentTypes.tsx"],"sourcesContent":["import type { ComponentType } from \"react\";\nimport type {\n ContentPartStatus,\n ImageContentPart,\n TextContentPart,\n ToolCallContentPart,\n UIContentPart,\n Unstable_AudioContentPart,\n} from \"./AssistantTypes\";\nimport { ContentPartState } from \"../api/ContentPartRuntime\";\n\nexport type EmptyContentPartProps = {\n status: ContentPartStatus;\n};\nexport type EmptyContentPartComponent = ComponentType<EmptyContentPartProps>;\n\nexport type TextContentPartProps = ContentPartState & TextContentPart;\nexport type TextContentPartComponent = ComponentType<TextContentPartProps>;\n\nexport type ImageContentPartProps = ContentPartState & ImageContentPart;\nexport type ImageContentPartComponent = ComponentType<ImageContentPartProps>;\n\nexport type Unstable_AudioContentPartProps = ContentPartState &\n Unstable_AudioContentPart;\nexport type Unstable_AudioContentPartComponent =\n ComponentType<Unstable_AudioContentPartProps>;\n\nexport type UIContentPartProps = ContentPartState & UIContentPart;\nexport type UIContentPartComponent = ComponentType<UIContentPartProps>;\n\nexport type ToolCallContentPartProps<\n TArgs extends Record<string, unknown> = any,\n TResult = unknown,\n> = ContentPartState &\n ToolCallContentPart<TArgs, TResult> & {\n addResult: (result: any) => void;\n };\n\nexport type ToolCallContentPartComponent<\n TArgs extends Record<string, unknown> = any,\n TResult = any,\n> = ComponentType<ToolCallContentPartProps<TArgs, TResult>>;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
1
|
+
{"version":3,"sources":["../../src/types/ContentPartComponentTypes.tsx"],"sourcesContent":["import type { ComponentType } from \"react\";\nimport type {\n ContentPartStatus,\n FileContentPart,\n ImageContentPart,\n TextContentPart,\n ToolCallContentPart,\n UIContentPart,\n Unstable_AudioContentPart,\n} from \"./AssistantTypes\";\nimport { ContentPartState } from \"../api/ContentPartRuntime\";\n\nexport type EmptyContentPartProps = {\n status: ContentPartStatus;\n};\nexport type EmptyContentPartComponent = ComponentType<EmptyContentPartProps>;\n\nexport type TextContentPartProps = ContentPartState & TextContentPart;\nexport type TextContentPartComponent = ComponentType<TextContentPartProps>;\n\nexport type ImageContentPartProps = ContentPartState & ImageContentPart;\nexport type ImageContentPartComponent = ComponentType<ImageContentPartProps>;\n\nexport type FileContentPartProps = ContentPartState & FileContentPart;\nexport type FileContentPartComponent = ComponentType<FileContentPartProps>;\n\nexport type Unstable_AudioContentPartProps = ContentPartState &\n Unstable_AudioContentPart;\nexport type Unstable_AudioContentPartComponent =\n ComponentType<Unstable_AudioContentPartProps>;\n\nexport type UIContentPartProps = ContentPartState & UIContentPart;\nexport type UIContentPartComponent = ComponentType<UIContentPartProps>;\n\nexport type ToolCallContentPartProps<\n TArgs extends Record<string, unknown> = any,\n TResult = unknown,\n> = ContentPartState &\n ToolCallContentPart<TArgs, TResult> & {\n addResult: (result: any) => void;\n };\n\nexport type ToolCallContentPartComponent<\n TArgs extends Record<string, unknown> = any,\n TResult = any,\n> = ComponentType<ToolCallContentPartProps<TArgs, TResult>>;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/types/index.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
export type { Attachment, PendingAttachment, CompleteAttachment, AttachmentStatus, } from "./AttachmentTypes";
|
2
|
-
export type { AppendMessage, TextContentPart, ImageContentPart, ToolCallContentPart, UIContentPart, MessageStatus, ThreadUserContentPart, ThreadAssistantContentPart, ThreadSystemMessage, ThreadAssistantMessage, ThreadUserMessage, ThreadMessage, CoreUserContentPart, CoreAssistantContentPart, CoreSystemMessage, CoreUserMessage, CoreAssistantMessage, CoreMessage,
|
3
|
-
export type { EmptyContentPartProps, EmptyContentPartComponent, TextContentPartProps, TextContentPartComponent, ImageContentPartProps, ImageContentPartComponent, UIContentPartProps, UIContentPartComponent, ToolCallContentPartProps, ToolCallContentPartComponent,
|
2
|
+
export type { AppendMessage, TextContentPart, ImageContentPart, FileContentPart, Unstable_AudioContentPart, ToolCallContentPart, UIContentPart, MessageStatus, ThreadUserContentPart, ThreadAssistantContentPart, ThreadSystemMessage, ThreadAssistantMessage, ThreadUserMessage, ThreadMessage, CoreUserContentPart, CoreAssistantContentPart, CoreSystemMessage, CoreUserMessage, CoreAssistantMessage, CoreMessage, } from "./AssistantTypes";
|
3
|
+
export type { EmptyContentPartProps, EmptyContentPartComponent, TextContentPartProps, TextContentPartComponent, ImageContentPartProps, ImageContentPartComponent, FileContentPartProps, FileContentPartComponent, Unstable_AudioContentPartProps, Unstable_AudioContentPartComponent, UIContentPartProps, UIContentPartComponent, ToolCallContentPartProps, ToolCallContentPartComponent, } from "./ContentPartComponentTypes";
|
4
4
|
export type { ModelConfig, ModelConfigProvider, Tool, } from "./ModelConfigTypes";
|
5
5
|
export type { Unsubscribe } from "./Unsubscribe";
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EACb,aAAa,EAGb,qBAAqB,EACrB,0BAA0B,EAC1B,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,EAGb,mBAAmB,EACnB,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,WAAW,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,yBAAyB,EACzB,mBAAmB,EACnB,aAAa,EACb,aAAa,EAGb,qBAAqB,EACrB,0BAA0B,EAC1B,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,EAGb,mBAAmB,EACnB,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EACV,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,wBAAwB,EACxB,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,wBAAwB,EACxB,8BAA8B,EAC9B,kCAAkC,EAClC,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,6BAA6B,CAAC;AAErC,YAAY,EACV,WAAW,EACX,mBAAmB,EACnB,IAAI,GACL,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/types/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["export type {\n Attachment,\n PendingAttachment,\n CompleteAttachment,\n AttachmentStatus,\n} from \"./AttachmentTypes\";\n\nexport type {\n AppendMessage,\n TextContentPart,\n ImageContentPart,\n ToolCallContentPart,\n UIContentPart,\n MessageStatus,\n\n // thread message types\n ThreadUserContentPart,\n ThreadAssistantContentPart,\n ThreadSystemMessage,\n ThreadAssistantMessage,\n ThreadUserMessage,\n ThreadMessage,\n\n // core message types\n CoreUserContentPart,\n CoreAssistantContentPart,\n CoreSystemMessage,\n CoreUserMessage,\n CoreAssistantMessage,\n CoreMessage,\n
|
1
|
+
{"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["export type {\n Attachment,\n PendingAttachment,\n CompleteAttachment,\n AttachmentStatus,\n} from \"./AttachmentTypes\";\n\nexport type {\n AppendMessage,\n TextContentPart,\n ImageContentPart,\n FileContentPart,\n Unstable_AudioContentPart,\n ToolCallContentPart,\n UIContentPart,\n MessageStatus,\n\n // thread message types\n ThreadUserContentPart,\n ThreadAssistantContentPart,\n ThreadSystemMessage,\n ThreadAssistantMessage,\n ThreadUserMessage,\n ThreadMessage,\n\n // core message types\n CoreUserContentPart,\n CoreAssistantContentPart,\n CoreSystemMessage,\n CoreUserMessage,\n CoreAssistantMessage,\n CoreMessage,\n} from \"./AssistantTypes\";\n\nexport type {\n EmptyContentPartProps,\n EmptyContentPartComponent,\n TextContentPartProps,\n TextContentPartComponent,\n ImageContentPartProps,\n ImageContentPartComponent,\n FileContentPartProps,\n FileContentPartComponent,\n Unstable_AudioContentPartProps,\n Unstable_AudioContentPartComponent,\n UIContentPartProps,\n UIContentPartComponent,\n ToolCallContentPartProps,\n ToolCallContentPartComponent,\n} from \"./ContentPartComponentTypes\";\n\nexport type {\n ModelConfig,\n ModelConfigProvider,\n Tool,\n} from \"./ModelConfigTypes\";\n\nexport type { Unsubscribe } from \"./Unsubscribe\";\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/package.json
CHANGED
package/src/api/ThreadRuntime.ts
CHANGED
@@ -41,6 +41,7 @@ export type CreateAppendMessage =
|
|
41
41
|
| string
|
42
42
|
| {
|
43
43
|
parentId?: string | null | undefined;
|
44
|
+
sourceId?: string | null | undefined;
|
44
45
|
role?: AppendMessage["role"] | undefined;
|
45
46
|
content: AppendMessage["content"];
|
46
47
|
attachments?: AppendMessage["attachments"] | undefined;
|
@@ -54,6 +55,8 @@ const toAppendMessage = (
|
|
54
55
|
if (typeof message === "string") {
|
55
56
|
return {
|
56
57
|
parentId: messages.at(-1)?.id ?? null,
|
58
|
+
sourceId: null,
|
59
|
+
runConfig: {},
|
57
60
|
role: "user",
|
58
61
|
content: [{ type: "text", text: message }],
|
59
62
|
attachments: [],
|
@@ -67,6 +70,7 @@ const toAppendMessage = (
|
|
67
70
|
return {
|
68
71
|
...message,
|
69
72
|
parentId: message.parentId ?? messages.at(-1)?.id ?? null,
|
73
|
+
sourceId: message.sourceId ?? null,
|
70
74
|
role: message.role ?? "user",
|
71
75
|
attachments: message.attachments ?? [],
|
72
76
|
} as AppendMessage;
|
@@ -287,10 +291,15 @@ export class ThreadRuntimeImpl implements ThreadRuntime {
|
|
287
291
|
return this._threadBinding.getState().getModelConfig();
|
288
292
|
}
|
289
293
|
|
294
|
+
public startRun(config: StartRunConfig): void;
|
295
|
+
/**
|
296
|
+
* @deprecated Use `startRun(parentId: string | null)` instead. This will be removed in 0.8.0.
|
297
|
+
*/
|
298
|
+
public startRun(parentId: string | null): void;
|
290
299
|
public startRun(configOrParentId: string | null | StartRunConfig) {
|
291
300
|
const config =
|
292
301
|
configOrParentId === null || typeof configOrParentId === "string"
|
293
|
-
? { parentId: configOrParentId }
|
302
|
+
? { parentId: configOrParentId, sourceId: null, runConfig: {} }
|
294
303
|
: configOrParentId;
|
295
304
|
return this._threadBinding.getState().startRun(config);
|
296
305
|
}
|
package/src/internal.ts
CHANGED
@@ -12,5 +12,8 @@ export {
|
|
12
12
|
type ThreadRuntimeCoreBinding,
|
13
13
|
type ThreadListItemRuntimeBinding,
|
14
14
|
} from "./api/ThreadRuntime";
|
15
|
+
export { fromThreadMessageLike } from "./runtimes/external-store/ThreadMessageLike";
|
16
|
+
export { getAutoStatus } from "./runtimes/external-store/auto-status";
|
17
|
+
export { EdgeRuntimeRequestOptionsSchema } from "./runtimes/edge/EdgeRuntimeRequestOptions";
|
15
18
|
|
16
19
|
export * from "./utils/smooth";
|
@@ -4,6 +4,9 @@ import { ContentPartState } from "../../api/ContentPartRuntime";
|
|
4
4
|
import { useContentPart } from "../../context/react/ContentPartContext";
|
5
5
|
import { UIContentPart } from "../../types";
|
6
6
|
|
7
|
+
/**
|
8
|
+
* @deprecated UI content parts are deprecated and will be removed in v0.8.0.
|
9
|
+
*/
|
7
10
|
export const useContentPartDisplay = () => {
|
8
11
|
const display = useContentPart((c) => {
|
9
12
|
if (c.type !== "ui")
|
@@ -22,6 +22,7 @@ import type {
|
|
22
22
|
ToolCallContentPartComponent,
|
23
23
|
ToolCallContentPartProps,
|
24
24
|
UIContentPartComponent,
|
25
|
+
FileContentPartComponent,
|
25
26
|
} from "../../types/ContentPartComponentTypes";
|
26
27
|
import { ContentPartPrimitiveInProgress } from "../contentPart/ContentPartInProgress";
|
27
28
|
import { EMPTY_CONTENT_SYMBOL } from "../../api/MessageRuntime";
|
@@ -33,6 +34,7 @@ export namespace MessagePrimitiveContent {
|
|
33
34
|
Empty?: EmptyContentPartComponent | undefined;
|
34
35
|
Text?: TextContentPartComponent | undefined;
|
35
36
|
Image?: ImageContentPartComponent | undefined;
|
37
|
+
File?: FileContentPartComponent | undefined;
|
36
38
|
Unstable_Audio?: Unstable_AudioContentPartComponent | undefined;
|
37
39
|
UI?: UIContentPartComponent | undefined;
|
38
40
|
tools?:
|
@@ -72,6 +74,7 @@ const defaultComponents = {
|
|
72
74
|
</p>
|
73
75
|
),
|
74
76
|
Image: () => <ContentPartPrimitiveImage />,
|
77
|
+
File: () => null,
|
75
78
|
Unstable_Audio: () => null,
|
76
79
|
UI: () => <ContentPartPrimitiveDisplay />,
|
77
80
|
} satisfies MessagePrimitiveContent.Props["components"];
|
@@ -85,8 +88,9 @@ const MessageContentPartComponent: FC<MessageContentPartComponentProps> = ({
|
|
85
88
|
Text = defaultComponents.Text,
|
86
89
|
Empty,
|
87
90
|
Image = defaultComponents.Image,
|
88
|
-
|
91
|
+
File = defaultComponents.File,
|
89
92
|
Unstable_Audio: Audio = defaultComponents.Unstable_Audio,
|
93
|
+
UI = defaultComponents.UI,
|
90
94
|
tools = {},
|
91
95
|
} = {},
|
92
96
|
}) => {
|
@@ -118,6 +122,9 @@ const MessageContentPartComponent: FC<MessageContentPartComponentProps> = ({
|
|
118
122
|
// eslint-disable-next-line jsx-a11y/alt-text
|
119
123
|
return <Image {...part} />;
|
120
124
|
|
125
|
+
case "file":
|
126
|
+
return <File {...part} />;
|
127
|
+
|
121
128
|
case "audio":
|
122
129
|
return <Audio {...part} />;
|
123
130
|
|
@@ -158,6 +165,7 @@ const MessageContentPart = memo(
|
|
158
165
|
prev.partIndex === next.partIndex &&
|
159
166
|
prev.components?.Text === next.components?.Text &&
|
160
167
|
prev.components?.Image === next.components?.Image &&
|
168
|
+
prev.components?.File === next.components?.File &&
|
161
169
|
prev.components?.Unstable_Audio === next.components?.Unstable_Audio &&
|
162
170
|
prev.components?.UI === next.components?.UI &&
|
163
171
|
prev.components?.tools === next.components?.tools,
|
@@ -133,7 +133,7 @@ export abstract class BaseComposerRuntimeCore
|
|
133
133
|
)
|
134
134
|
: [];
|
135
135
|
|
136
|
-
const message: Omit<AppendMessage, "parentId"> = {
|
136
|
+
const message: Omit<AppendMessage, "parentId" | "sourceId"> = {
|
137
137
|
role: this.role,
|
138
138
|
content: this.text ? [{ type: "text", text: this.text }] : [],
|
139
139
|
attachments,
|
@@ -149,7 +149,9 @@ export abstract class BaseComposerRuntimeCore
|
|
149
149
|
this.handleCancel();
|
150
150
|
}
|
151
151
|
|
152
|
-
protected abstract handleSend(
|
152
|
+
protected abstract handleSend(
|
153
|
+
message: Omit<AppendMessage, "parentId" | "sourceId">,
|
154
|
+
): void;
|
153
155
|
protected abstract handleCancel(): void;
|
154
156
|
|
155
157
|
async addAttachment(file: File) {
|
@@ -159,6 +161,7 @@ export abstract class BaseComposerRuntimeCore
|
|
159
161
|
const attachment = await adapter.add({ file });
|
160
162
|
|
161
163
|
this._attachments = [...this._attachments, attachment as PendingAttachment];
|
164
|
+
this._notifyEventSubscribers("attachment_add");
|
162
165
|
this._notifySubscribers();
|
163
166
|
}
|
164
167
|
|
@@ -16,6 +16,7 @@ export class DefaultEditComposerRuntimeCore extends BaseComposerRuntimeCore {
|
|
16
16
|
private _nonTextParts;
|
17
17
|
private _previousText;
|
18
18
|
private _parentId;
|
19
|
+
private _sourceId;
|
19
20
|
constructor(
|
20
21
|
private runtime: Omit<ThreadRuntimeCore, "composer"> & {
|
21
22
|
adapters?: { attachments?: AttachmentAdapter | undefined } | undefined;
|
@@ -25,6 +26,7 @@ export class DefaultEditComposerRuntimeCore extends BaseComposerRuntimeCore {
|
|
25
26
|
) {
|
26
27
|
super();
|
27
28
|
this._parentId = parentId;
|
29
|
+
this._sourceId = message.id;
|
28
30
|
this._previousText = getThreadMessageText(message);
|
29
31
|
this.setText(this._previousText);
|
30
32
|
|
@@ -36,13 +38,16 @@ export class DefaultEditComposerRuntimeCore extends BaseComposerRuntimeCore {
|
|
36
38
|
);
|
37
39
|
}
|
38
40
|
|
39
|
-
public async handleSend(
|
41
|
+
public async handleSend(
|
42
|
+
message: Omit<AppendMessage, "parentId" | "sourceId">,
|
43
|
+
) {
|
40
44
|
const text = getThreadMessageText(message as AppendMessage);
|
41
45
|
if (text !== this._previousText) {
|
42
46
|
this.runtime.append({
|
43
|
-
...
|
47
|
+
...message,
|
44
48
|
content: [...message.content, ...this._nonTextParts] as any,
|
45
49
|
parentId: this._parentId,
|
50
|
+
sourceId: this._sourceId,
|
46
51
|
});
|
47
52
|
}
|
48
53
|
|
@@ -39,10 +39,13 @@ export class DefaultThreadComposerRuntimeCore
|
|
39
39
|
});
|
40
40
|
}
|
41
41
|
|
42
|
-
public async handleSend(
|
42
|
+
public async handleSend(
|
43
|
+
message: Omit<AppendMessage, "parentId" | "sourceId">,
|
44
|
+
) {
|
43
45
|
this.runtime.append({
|
44
46
|
...(message as AppendMessage),
|
45
47
|
parentId: this.runtime.messages.at(-1)?.id ?? null,
|
48
|
+
sourceId: null,
|
46
49
|
});
|
47
50
|
}
|
48
51
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { Attachment, PendingAttachment, Unsubscribe } from "../../types";
|
2
2
|
import { MessageRole, RunConfig } from "../../types/AssistantTypes";
|
3
3
|
|
4
|
-
export type ComposerRuntimeEventType = "send";
|
4
|
+
export type ComposerRuntimeEventType = "send" | "attachment_add";
|
5
5
|
|
6
6
|
export type ComposerRuntimeCore = Readonly<{
|
7
7
|
isEditing: boolean;
|
@@ -24,6 +24,12 @@ const ImageContentPartSchema = z.object({
|
|
24
24
|
image: z.string(),
|
25
25
|
});
|
26
26
|
|
27
|
+
const FileContentPartSchema = z.object({
|
28
|
+
type: z.literal("file"),
|
29
|
+
data: z.string(),
|
30
|
+
mimeType: z.string(),
|
31
|
+
});
|
32
|
+
|
27
33
|
const Unstable_AudioContentPart = z.object({
|
28
34
|
type: z.literal("audio"),
|
29
35
|
audio: z.object({
|
@@ -49,6 +55,7 @@ const CoreUserMessageSchema = z.object({
|
|
49
55
|
z.discriminatedUnion("type", [
|
50
56
|
TextContentPartSchema,
|
51
57
|
ImageContentPartSchema,
|
58
|
+
FileContentPartSchema,
|
52
59
|
Unstable_AudioContentPart,
|
53
60
|
]),
|
54
61
|
)
|
@@ -49,9 +49,16 @@ export const fromLanguageModelMessages = (
|
|
49
49
|
throw new Error("Only images with URL data are supported");
|
50
50
|
}
|
51
51
|
case "file": {
|
52
|
-
|
53
|
-
|
52
|
+
if (part.data instanceof URL) {
|
53
|
+
return {
|
54
|
+
type: "file",
|
55
|
+
data: part.data.href,
|
56
|
+
mimeType: part.mimeType,
|
57
|
+
};
|
58
|
+
}
|
59
|
+
throw new Error("Only files with URL data are supported");
|
54
60
|
}
|
61
|
+
|
55
62
|
default: {
|
56
63
|
const unhandledType: never = type;
|
57
64
|
throw new Error(`Unknown content part type: ${unhandledType}`);
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import {
|
2
|
+
LanguageModelV1FilePart,
|
2
3
|
LanguageModelV1ImagePart,
|
3
4
|
LanguageModelV1Message,
|
4
5
|
LanguageModelV1TextPart,
|
@@ -90,7 +91,12 @@ export function toLanguageModelMessages(
|
|
90
91
|
const msg: LanguageModelV1Message = {
|
91
92
|
role: "user",
|
92
93
|
content: content.map(
|
93
|
-
(
|
94
|
+
(
|
95
|
+
part,
|
96
|
+
):
|
97
|
+
| LanguageModelV1TextPart
|
98
|
+
| LanguageModelV1ImagePart
|
99
|
+
| LanguageModelV1FilePart => {
|
94
100
|
const type = part.type;
|
95
101
|
switch (type) {
|
96
102
|
case "text": {
|
@@ -104,6 +110,14 @@ export function toLanguageModelMessages(
|
|
104
110
|
};
|
105
111
|
}
|
106
112
|
|
113
|
+
case "file": {
|
114
|
+
return {
|
115
|
+
type: "file",
|
116
|
+
data: new URL(part.data),
|
117
|
+
mimeType: part.mimeType,
|
118
|
+
};
|
119
|
+
}
|
120
|
+
|
107
121
|
default: {
|
108
122
|
const unhandledType: "ui" | "audio" = type;
|
109
123
|
throw new Error(
|
@@ -11,11 +11,12 @@ import {
|
|
11
11
|
ThreadUserMessage,
|
12
12
|
ThreadSystemMessage,
|
13
13
|
CompleteAttachment,
|
14
|
+
FileContentPart,
|
15
|
+
Unstable_AudioContentPart,
|
14
16
|
} from "../../types";
|
15
17
|
import {
|
16
18
|
CoreToolCallContentPart,
|
17
19
|
ThreadStep,
|
18
|
-
Unstable_AudioContentPart,
|
19
20
|
} from "../../types/AssistantTypes";
|
20
21
|
|
21
22
|
export type ThreadMessageLike = {
|
@@ -25,6 +26,7 @@ export type ThreadMessageLike = {
|
|
25
26
|
| readonly (
|
26
27
|
| TextContentPart
|
27
28
|
| ImageContentPart
|
29
|
+
| FileContentPart
|
28
30
|
| Unstable_AudioContentPart
|
29
31
|
| ToolCallContentPart<any, any>
|
30
32
|
| CoreToolCallContentPart<any, any>
|
@@ -93,8 +95,10 @@ export const fromThreadMessageLike = (
|
|
93
95
|
}
|
94
96
|
|
95
97
|
default: {
|
96
|
-
const unhandledType: "image" | "audio" = type;
|
97
|
-
throw new Error(
|
98
|
+
const unhandledType: "image" | "audio" | "file" = type;
|
99
|
+
throw new Error(
|
100
|
+
`Unsupported assistant content part type: ${unhandledType}`,
|
101
|
+
);
|
98
102
|
}
|
99
103
|
}
|
100
104
|
})
|
@@ -118,11 +122,14 @@ export const fromThreadMessageLike = (
|
|
118
122
|
case "ui":
|
119
123
|
case "image":
|
120
124
|
case "audio":
|
125
|
+
case "file":
|
121
126
|
return part;
|
122
127
|
|
123
128
|
default: {
|
124
129
|
const unhandledType: "tool-call" = type;
|
125
|
-
throw new Error(
|
130
|
+
throw new Error(
|
131
|
+
`Unsupported user content part type: ${unhandledType}`,
|
132
|
+
);
|
126
133
|
}
|
127
134
|
}
|
128
135
|
}),
|
@@ -2,14 +2,20 @@ import type { CoreMessage } from "../../types/AssistantTypes";
|
|
2
2
|
import { BaseAssistantRuntimeCore } from "../core/BaseAssistantRuntimeCore";
|
3
3
|
import { LocalThreadRuntimeCore } from "./LocalThreadRuntimeCore";
|
4
4
|
import { LocalRuntimeOptionsBase } from "./LocalRuntimeOptions";
|
5
|
-
import { fromCoreMessages } from "../edge/converters/fromCoreMessage";
|
6
5
|
import { LocalThreadListRuntimeCore } from "./LocalThreadListRuntimeCore";
|
7
6
|
import { ExportedMessageRepository } from "../utils/MessageRepository";
|
7
|
+
import { ThreadMessageLike } from "../external-store";
|
8
|
+
import { fromThreadMessageLike } from "../external-store/ThreadMessageLike";
|
9
|
+
import { generateId } from "../../internal";
|
10
|
+
import { getAutoStatus } from "../external-store/auto-status";
|
8
11
|
|
9
12
|
const getExportFromInitialMessages = (
|
10
|
-
initialMessages: readonly
|
13
|
+
initialMessages: readonly ThreadMessageLike[],
|
11
14
|
): ExportedMessageRepository => {
|
12
|
-
const messages =
|
15
|
+
const messages = initialMessages.map((i, idx) => {
|
16
|
+
const isLast = idx === initialMessages.length - 1;
|
17
|
+
return fromThreadMessageLike(i, generateId(), getAutoStatus(isLast, false));
|
18
|
+
});
|
13
19
|
return {
|
14
20
|
messages: messages.map((m, idx) => ({
|
15
21
|
parentId: messages[idx - 1]?.id ?? null,
|
@@ -26,7 +32,7 @@ export class LocalRuntimeCore extends BaseAssistantRuntimeCore {
|
|
26
32
|
|
27
33
|
constructor(
|
28
34
|
options: LocalRuntimeOptionsBase,
|
29
|
-
initialMessages: readonly
|
35
|
+
initialMessages: readonly ThreadMessageLike[] | undefined,
|
30
36
|
) {
|
31
37
|
super();
|
32
38
|
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import type { CoreMessage } from "../../types";
|
2
1
|
import { AttachmentAdapter } from "../attachment/AttachmentAdapter";
|
2
|
+
import { ThreadMessageLike } from "../external-store";
|
3
3
|
import { FeedbackAdapter } from "../feedback/FeedbackAdapter";
|
4
4
|
import { SpeechSynthesisAdapter } from "../speech/SpeechAdapterTypes";
|
5
5
|
import { ChatModelAdapter } from "./ChatModelAdapter";
|
@@ -16,7 +16,7 @@ export type LocalRuntimeOptionsBase = {
|
|
16
16
|
|
17
17
|
// TODO align LocalRuntimeOptions with LocalRuntimeOptionsBase
|
18
18
|
export type LocalRuntimeOptions = Omit<LocalRuntimeOptionsBase, "adapters"> & {
|
19
|
-
initialMessages?: readonly
|
19
|
+
initialMessages?: readonly ThreadMessageLike[] | undefined;
|
20
20
|
adapters?: Omit<LocalRuntimeOptionsBase["adapters"], "chatModel"> | undefined;
|
21
21
|
};
|
22
22
|
|