@assistant-ui/react 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/edge.js +111 -115
- package/dist/edge.js.map +1 -1
- package/dist/edge.mjs +111 -115
- package/dist/edge.mjs.map +1 -1
- package/dist/index.d.mts +66 -58
- package/dist/index.d.ts +66 -58
- package/dist/index.js +480 -245
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +477 -246
- package/dist/index.mjs.map +1 -1
- package/dist/styles/index.css +155 -155
- package/dist/styles/index.css.map +1 -1
- package/dist/styles/modal.css +22 -22
- package/dist/styles/modal.css.map +1 -1
- package/dist/styles/tailwindcss/base-components.css +11 -11
- package/dist/styles/tailwindcss/modal.css +5 -5
- package/dist/styles/tailwindcss/thread.css +35 -35
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
@@ -2,7 +2,7 @@ import * as react from 'react';
|
|
2
2
|
import { ReactNode, ComponentType, PropsWithChildren, ComponentPropsWithoutRef, FC } from 'react';
|
3
3
|
import { z } from 'zod';
|
4
4
|
import { JSONSchema7 } from 'json-schema';
|
5
|
-
import { LanguageModelV1FinishReason, LanguageModelV1LogProbs } from '@ai-sdk/provider';
|
5
|
+
import { LanguageModelV1FinishReason, LanguageModelV1LogProbs, LanguageModelV1Message } from '@ai-sdk/provider';
|
6
6
|
import { UseBoundStore, StoreApi } from 'zustand';
|
7
7
|
import { Primitive } from '@radix-ui/react-primitive';
|
8
8
|
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
@@ -16,14 +16,16 @@ type ToolExecuteFunction<TArgs, TResult> = (args: TArgs) => TResult | Promise<TR
|
|
16
16
|
type Tool<TArgs = unknown, TResult = unknown> = {
|
17
17
|
description?: string | undefined;
|
18
18
|
parameters: z.ZodSchema<TArgs> | JSONSchema7;
|
19
|
-
execute
|
19
|
+
execute?: ToolExecuteFunction<TArgs, TResult>;
|
20
20
|
};
|
21
21
|
type ModelConfig = {
|
22
22
|
priority?: number | undefined;
|
23
23
|
system?: string | undefined;
|
24
24
|
tools?: Record<string, Tool<any, any>> | undefined;
|
25
25
|
};
|
26
|
-
type ModelConfigProvider =
|
26
|
+
type ModelConfigProvider = {
|
27
|
+
getModelConfig: () => ModelConfig;
|
28
|
+
};
|
27
29
|
|
28
30
|
type Unsubscribe = () => void;
|
29
31
|
|
@@ -43,12 +45,13 @@ type ToolCallContentPart<TArgs = unknown, TResult = unknown> = {
|
|
43
45
|
type: "tool-call";
|
44
46
|
toolCallId: string;
|
45
47
|
toolName: string;
|
48
|
+
argsText: string;
|
46
49
|
args: TArgs;
|
47
50
|
result?: TResult;
|
51
|
+
isError?: boolean;
|
48
52
|
};
|
49
53
|
type ThreadUserContentPart = TextContentPart | ImageContentPart | UIContentPart;
|
50
54
|
type ThreadAssistantContentPart = TextContentPart | ToolCallContentPart | UIContentPart;
|
51
|
-
type AppendContentPart = TextContentPart | ImageContentPart;
|
52
55
|
type MessageCommonProps = {
|
53
56
|
id: string;
|
54
57
|
createdAt: Date;
|
@@ -80,25 +83,26 @@ type ThreadAssistantMessage = MessageCommonProps & {
|
|
80
83
|
content: ThreadAssistantContentPart[];
|
81
84
|
status: MessageStatus;
|
82
85
|
};
|
83
|
-
type AppendMessage = {
|
86
|
+
type AppendMessage = CoreMessage & {
|
84
87
|
parentId: string | null;
|
85
|
-
role: "user";
|
86
|
-
content: AppendContentPart[];
|
87
88
|
};
|
88
89
|
type ThreadMessage = ThreadSystemMessage | ThreadUserMessage | ThreadAssistantMessage;
|
89
90
|
/** Core Message Types (without UI content parts) */
|
90
91
|
type CoreUserContentPart = TextContentPart | ImageContentPart;
|
91
92
|
type CoreAssistantContentPart = TextContentPart | ToolCallContentPart;
|
92
|
-
type
|
93
|
+
type CoreSystemMessage = {
|
94
|
+
role: "system";
|
95
|
+
content: [TextContentPart];
|
96
|
+
};
|
97
|
+
type CoreUserMessage = {
|
93
98
|
role: "user";
|
94
99
|
content: CoreUserContentPart[];
|
95
100
|
};
|
96
|
-
type CoreAssistantMessage =
|
101
|
+
type CoreAssistantMessage = {
|
97
102
|
role: "assistant";
|
98
103
|
content: CoreAssistantContentPart[];
|
99
|
-
status: MessageStatus;
|
100
104
|
};
|
101
|
-
type
|
105
|
+
type CoreMessage = CoreSystemMessage | CoreUserMessage | CoreAssistantMessage;
|
102
106
|
|
103
107
|
type ReactThreadRuntime = ThreadRuntime & {
|
104
108
|
unstable_synchronizer?: ComponentType;
|
@@ -123,41 +127,25 @@ type ChatModelAdapter = {
|
|
123
127
|
|
124
128
|
declare abstract class BaseAssistantRuntime<TThreadRuntime extends ReactThreadRuntime> implements AssistantRuntime {
|
125
129
|
private _thread;
|
126
|
-
get capabilities(): Readonly<{
|
127
|
-
edit: boolean;
|
128
|
-
reload: boolean;
|
129
|
-
cancel: boolean;
|
130
|
-
copy: boolean;
|
131
|
-
}>;
|
132
130
|
constructor(_thread: TThreadRuntime);
|
133
|
-
private _unsubscribe;
|
134
131
|
get thread(): TThreadRuntime;
|
135
132
|
set thread(thread: TThreadRuntime);
|
136
133
|
abstract registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;
|
137
134
|
abstract switchToThread(threadId: string | null): void;
|
138
|
-
get messages(): readonly ThreadMessage[];
|
139
|
-
get isRunning(): boolean;
|
140
|
-
getBranches(messageId: string): readonly string[];
|
141
|
-
switchToBranch(branchId: string): void;
|
142
|
-
append(message: AppendMessage): void;
|
143
|
-
startRun(parentId: string | null): void;
|
144
|
-
cancelRun(): void;
|
145
|
-
addToolResult(options: AddToolResultOptions): void;
|
146
135
|
private _subscriptions;
|
147
136
|
subscribe(callback: () => void): Unsubscribe;
|
148
137
|
private subscriptionHandler;
|
149
|
-
get unstable_synchronizer(): react.ComponentType | undefined;
|
150
138
|
}
|
151
139
|
|
152
140
|
declare class LocalRuntime extends BaseAssistantRuntime<LocalThreadRuntime> {
|
153
|
-
private readonly
|
141
|
+
private readonly _proxyConfigProvider;
|
154
142
|
constructor(adapter: ChatModelAdapter);
|
155
143
|
set adapter(adapter: ChatModelAdapter);
|
156
|
-
registerModelConfigProvider(provider: ModelConfigProvider): () =>
|
144
|
+
registerModelConfigProvider(provider: ModelConfigProvider): () => void;
|
157
145
|
switchToThread(threadId: string | null): LocalThreadRuntime;
|
158
146
|
}
|
159
147
|
declare class LocalThreadRuntime implements ThreadRuntime {
|
160
|
-
private
|
148
|
+
private configProvider;
|
161
149
|
adapter: ChatModelAdapter;
|
162
150
|
private _subscriptions;
|
163
151
|
private abortController;
|
@@ -170,7 +158,7 @@ declare class LocalThreadRuntime implements ThreadRuntime {
|
|
170
158
|
}>;
|
171
159
|
get messages(): ThreadMessage[];
|
172
160
|
get isRunning(): boolean;
|
173
|
-
constructor(
|
161
|
+
constructor(configProvider: ModelConfigProvider, adapter: ChatModelAdapter);
|
174
162
|
getBranches(messageId: string): string[];
|
175
163
|
switchToBranch(branchId: string): void;
|
176
164
|
append(message: AppendMessage): Promise<void>;
|
@@ -186,27 +174,13 @@ declare const useLocalRuntime: (adapter: ChatModelAdapter) => LocalRuntime;
|
|
186
174
|
type EdgeRuntimeOptions = {
|
187
175
|
api: string;
|
188
176
|
};
|
189
|
-
declare
|
177
|
+
declare class EdgeChatAdapter implements ChatModelAdapter {
|
178
|
+
private options;
|
179
|
+
constructor(options: EdgeRuntimeOptions);
|
180
|
+
run({ messages, abortSignal, config, onUpdate }: ChatModelRunOptions): Promise<ChatModelRunResult>;
|
181
|
+
}
|
190
182
|
|
191
|
-
|
192
|
-
messageId: string;
|
193
|
-
toolCallId: string;
|
194
|
-
result: any;
|
195
|
-
};
|
196
|
-
type ThreadActionsState = Readonly<{
|
197
|
-
capabilities: Readonly<{
|
198
|
-
edit: boolean;
|
199
|
-
reload: boolean;
|
200
|
-
cancel: boolean;
|
201
|
-
copy: boolean;
|
202
|
-
}>;
|
203
|
-
getBranches: (messageId: string) => readonly string[];
|
204
|
-
switchToBranch: (branchId: string) => void;
|
205
|
-
append: (message: AppendMessage) => void;
|
206
|
-
startRun: (parentId: string | null) => void;
|
207
|
-
cancelRun: () => void;
|
208
|
-
addToolResult: (options: AddToolResultOptions) => void;
|
209
|
-
}>;
|
183
|
+
declare const useEdgeRuntime: (options: EdgeRuntimeOptions) => LocalRuntime;
|
210
184
|
|
211
185
|
type TextContentPartProps = {
|
212
186
|
part: TextContentPart;
|
@@ -230,12 +204,43 @@ type ToolCallContentPartProps<TArgs = any, TResult = any> = {
|
|
230
204
|
};
|
231
205
|
type ToolCallContentPartComponent<TArgs = any, TResult = any> = ComponentType<ToolCallContentPartProps<TArgs, TResult>>;
|
232
206
|
|
233
|
-
|
207
|
+
declare function toLanguageModelMessages(message: readonly CoreMessage[] | readonly ThreadMessage[]): LanguageModelV1Message[];
|
208
|
+
|
209
|
+
declare const fromLanguageModelMessages: (lm: LanguageModelV1Message[], mergeRoundtrips: boolean) => CoreMessage[];
|
210
|
+
|
211
|
+
declare const fromCoreMessages: (message: CoreMessage[]) => ThreadMessage[];
|
212
|
+
|
213
|
+
type AddToolResultOptions = {
|
214
|
+
messageId: string;
|
215
|
+
toolCallId: string;
|
216
|
+
result: any;
|
217
|
+
};
|
218
|
+
type ThreadActionsState = Readonly<{
|
219
|
+
capabilities: Readonly<{
|
220
|
+
edit: boolean;
|
221
|
+
reload: boolean;
|
222
|
+
cancel: boolean;
|
223
|
+
copy: boolean;
|
224
|
+
}>;
|
225
|
+
getBranches: (messageId: string) => readonly string[];
|
226
|
+
switchToBranch: (branchId: string) => void;
|
227
|
+
append: (message: AppendMessage) => void;
|
228
|
+
startRun: (parentId: string | null) => void;
|
229
|
+
cancelRun: () => void;
|
230
|
+
addToolResult: (options: AddToolResultOptions) => void;
|
231
|
+
getRuntime: () => ThreadRuntime;
|
232
|
+
}>;
|
233
|
+
|
234
|
+
type ThreadRuntime = Readonly<ThreadState & Omit<ThreadActionsState, "getRuntime"> & {
|
234
235
|
messages: readonly ThreadMessage[];
|
235
236
|
subscribe: (callback: () => void) => Unsubscribe;
|
236
237
|
}>;
|
237
238
|
|
238
|
-
type
|
239
|
+
type ThreadRuntimeWithSubscribe = {
|
240
|
+
readonly thread: ThreadRuntime;
|
241
|
+
subscribe: (callback: () => void) => Unsubscribe;
|
242
|
+
};
|
243
|
+
type AssistantRuntime = ThreadRuntimeWithSubscribe & {
|
239
244
|
switchToThread: (threadId: string | null) => void;
|
240
245
|
registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
|
241
246
|
};
|
@@ -247,10 +252,10 @@ declare const AssistantRuntimeProvider: react.NamedExoticComponent<PropsWithChil
|
|
247
252
|
|
248
253
|
type AssistantActionsState = Readonly<{
|
249
254
|
switchToThread: (threadId: string | null) => void;
|
255
|
+
getRuntime: () => AssistantRuntime;
|
250
256
|
}>;
|
251
257
|
|
252
|
-
type AssistantModelConfigState = Readonly<{
|
253
|
-
getModelConfig: ModelConfigProvider;
|
258
|
+
type AssistantModelConfigState = Readonly<ModelConfigProvider & {
|
254
259
|
registerModelConfigProvider: (provider: ModelConfigProvider) => () => void;
|
255
260
|
}>;
|
256
261
|
|
@@ -1016,7 +1021,7 @@ declare const exports: {
|
|
1016
1021
|
Text: FC<TextContentPartProps>;
|
1017
1022
|
};
|
1018
1023
|
|
1019
|
-
declare class ProxyConfigProvider {
|
1024
|
+
declare class ProxyConfigProvider implements ModelConfigProvider {
|
1020
1025
|
private _providers;
|
1021
1026
|
getModelConfig(): ModelConfig;
|
1022
1027
|
registerModelConfigProvider(provider: ModelConfigProvider): () => void;
|
@@ -1042,6 +1047,8 @@ declare class MessageRepository {
|
|
1042
1047
|
|
1043
1048
|
declare const useSmooth: (text: string, smooth?: boolean) => string;
|
1044
1049
|
|
1050
|
+
declare const generateId: (size?: number) => string;
|
1051
|
+
|
1045
1052
|
type internal_BaseAssistantRuntime<TThreadRuntime extends ReactThreadRuntime> = BaseAssistantRuntime<TThreadRuntime>;
|
1046
1053
|
declare const internal_BaseAssistantRuntime: typeof BaseAssistantRuntime;
|
1047
1054
|
type internal_MessageRepository = MessageRepository;
|
@@ -1049,9 +1056,10 @@ declare const internal_MessageRepository: typeof MessageRepository;
|
|
1049
1056
|
type internal_ProxyConfigProvider = ProxyConfigProvider;
|
1050
1057
|
declare const internal_ProxyConfigProvider: typeof ProxyConfigProvider;
|
1051
1058
|
declare const internal_TooltipIconButton: typeof TooltipIconButton;
|
1059
|
+
declare const internal_generateId: typeof generateId;
|
1052
1060
|
declare const internal_useSmooth: typeof useSmooth;
|
1053
1061
|
declare namespace internal {
|
1054
|
-
export { internal_BaseAssistantRuntime as BaseAssistantRuntime, internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider, internal_TooltipIconButton as TooltipIconButton, internal_useSmooth as useSmooth };
|
1062
|
+
export { internal_BaseAssistantRuntime as BaseAssistantRuntime, internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider, internal_TooltipIconButton as TooltipIconButton, internal_generateId as generateId, internal_useSmooth as useSmooth };
|
1055
1063
|
}
|
1056
1064
|
|
1057
|
-
export { index$6 as ActionBarPrimitive, type ActionBarPrimitiveCopyProps, type ActionBarPrimitiveEditProps, type ActionBarPrimitiveReloadProps, type ActionBarPrimitiveRootProps, type AddToolResultOptions, type
|
1065
|
+
export { index$6 as ActionBarPrimitive, type ActionBarPrimitiveCopyProps, type ActionBarPrimitiveEditProps, type ActionBarPrimitiveReloadProps, type ActionBarPrimitiveRootProps, type AddToolResultOptions, type AppendMessage, _default$9 as AssistantActionBar, type AssistantActionsState, type AssistantContextValue, _default$8 as AssistantMessage, type AssistantMessageConfig, type AssistantMessageContentProps, _default$7 as AssistantModal, index$5 as AssistantModalPrimitive, type AssistantModalPrimitiveContentProps, type AssistantModalPrimitiveRootProps, type AssistantModalPrimitiveTriggerProps, type AssistantModelConfigState, type AssistantRuntime, AssistantRuntimeProvider, type AssistantToolProps, type AssistantToolUIProps, type AssistantToolUIsState, _default$6 as BranchPicker, index$4 as BranchPickerPrimitive, type BranchPickerPrimitiveCountProps, type BranchPickerPrimitiveNextProps, type BranchPickerPrimitiveNumberProps, type BranchPickerPrimitivePreviousProps, type BranchPickerPrimitiveRootProps, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, _default$5 as Composer, type ComposerContextValue, type ComposerInputProps, index$3 as ComposerPrimitive, type ComposerPrimitiveCancelProps, type ComposerPrimitiveIfProps, type ComposerPrimitiveInputProps, type ComposerPrimitiveRootProps, type ComposerPrimitiveSendProps, type ComposerState, exports as ContentPart, type ContentPartContextValue, index$2 as ContentPartPrimitive, type ContentPartPrimitiveDisplayProps, type ContentPartPrimitiveImageProps, type ContentPartPrimitiveInProgressProps, type ContentPartPrimitiveTextProps, type ContentPartState, type CoreAssistantContentPart, type CoreAssistantMessage, type CoreMessage, type CoreSystemMessage, type CoreUserContentPart, type CoreUserMessage, EdgeChatAdapter, type EdgeRuntimeOptions, _default$4 as EditComposer, type EditComposerState, internal as INTERNAL, type ImageContentPart, type ImageContentPartComponent, type ImageContentPartProps, type MessageContextValue, index$1 as MessagePrimitive, type MessagePrimitiveContentProps, type MessagePrimitiveIfProps, type MessagePrimitiveInProgressProps, type MessagePrimitiveRootProps, type MessageState, type MessageStatus, type MessageUtilsState, type ModelConfig, type ModelConfigProvider, type ReactThreadRuntime, type StringsConfig, type SuggestionConfig, type TextContentPart, type TextContentPartComponent, type TextContentPartProps, _default$3 as Thread, type ThreadActionsState, type ThreadAssistantContentPart, type ThreadAssistantMessage, type ThreadConfig, ThreadConfigProvider, type ThreadConfigProviderProps, type ThreadContextValue, type ThreadMessage, type ThreadMessagesState, index as ThreadPrimitive, type ThreadPrimitiveEmptyProps, type ThreadPrimitiveIfProps, type ThreadPrimitiveMessagesProps, type ThreadPrimitiveRootProps, type ThreadPrimitiveScrollToBottomProps, type ThreadPrimitiveSuggestionProps, type ThreadPrimitiveViewportProps, type ThreadRootProps, type ThreadRuntime, type ThreadState, type ThreadSystemMessage, type ThreadUserContentPart, type ThreadUserMessage, type ThreadViewportState, _default as ThreadWelcome, type ThreadWelcomeConfig, type ThreadWelcomeMessageProps, type ThreadWelcomeSuggestionProps, type Tool, type ToolCallContentPart, type ToolCallContentPartComponent, type ToolCallContentPartProps, type UIContentPart, type UIContentPartComponent, type UIContentPartProps, type Unsubscribe, type UseActionBarCopyProps, _default$1 as UserActionBar, _default$2 as UserMessage, type UserMessageConfig, type UserMessageContentProps, fromCoreMessages, fromLanguageModelMessages, makeAssistantTool, makeAssistantToolUI, toLanguageModelMessages, useActionBarCopy, useActionBarEdit, useActionBarReload, useAppendMessage, useAssistantContext, useAssistantInstructions, useAssistantTool, useAssistantToolUI, useBranchPickerCount, useBranchPickerNext, useBranchPickerNumber, useBranchPickerPrevious, useComposerCancel, useComposerContext, useComposerIf, useComposerSend, useContentPartContext, useContentPartDisplay, useContentPartImage, useContentPartText, useEdgeRuntime, useLocalRuntime, useMessageContext, useMessageIf, useSwitchToNewThread, useThreadConfig, useThreadContext, useThreadEmpty, useThreadIf, useThreadScrollToBottom, useThreadSuggestion };
|
package/dist/index.d.ts
CHANGED
@@ -2,7 +2,7 @@ import * as react from 'react';
|
|
2
2
|
import { ReactNode, ComponentType, PropsWithChildren, ComponentPropsWithoutRef, FC } from 'react';
|
3
3
|
import { z } from 'zod';
|
4
4
|
import { JSONSchema7 } from 'json-schema';
|
5
|
-
import { LanguageModelV1FinishReason, LanguageModelV1LogProbs } from '@ai-sdk/provider';
|
5
|
+
import { LanguageModelV1FinishReason, LanguageModelV1LogProbs, LanguageModelV1Message } from '@ai-sdk/provider';
|
6
6
|
import { UseBoundStore, StoreApi } from 'zustand';
|
7
7
|
import { Primitive } from '@radix-ui/react-primitive';
|
8
8
|
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
@@ -16,14 +16,16 @@ type ToolExecuteFunction<TArgs, TResult> = (args: TArgs) => TResult | Promise<TR
|
|
16
16
|
type Tool<TArgs = unknown, TResult = unknown> = {
|
17
17
|
description?: string | undefined;
|
18
18
|
parameters: z.ZodSchema<TArgs> | JSONSchema7;
|
19
|
-
execute
|
19
|
+
execute?: ToolExecuteFunction<TArgs, TResult>;
|
20
20
|
};
|
21
21
|
type ModelConfig = {
|
22
22
|
priority?: number | undefined;
|
23
23
|
system?: string | undefined;
|
24
24
|
tools?: Record<string, Tool<any, any>> | undefined;
|
25
25
|
};
|
26
|
-
type ModelConfigProvider =
|
26
|
+
type ModelConfigProvider = {
|
27
|
+
getModelConfig: () => ModelConfig;
|
28
|
+
};
|
27
29
|
|
28
30
|
type Unsubscribe = () => void;
|
29
31
|
|
@@ -43,12 +45,13 @@ type ToolCallContentPart<TArgs = unknown, TResult = unknown> = {
|
|
43
45
|
type: "tool-call";
|
44
46
|
toolCallId: string;
|
45
47
|
toolName: string;
|
48
|
+
argsText: string;
|
46
49
|
args: TArgs;
|
47
50
|
result?: TResult;
|
51
|
+
isError?: boolean;
|
48
52
|
};
|
49
53
|
type ThreadUserContentPart = TextContentPart | ImageContentPart | UIContentPart;
|
50
54
|
type ThreadAssistantContentPart = TextContentPart | ToolCallContentPart | UIContentPart;
|
51
|
-
type AppendContentPart = TextContentPart | ImageContentPart;
|
52
55
|
type MessageCommonProps = {
|
53
56
|
id: string;
|
54
57
|
createdAt: Date;
|
@@ -80,25 +83,26 @@ type ThreadAssistantMessage = MessageCommonProps & {
|
|
80
83
|
content: ThreadAssistantContentPart[];
|
81
84
|
status: MessageStatus;
|
82
85
|
};
|
83
|
-
type AppendMessage = {
|
86
|
+
type AppendMessage = CoreMessage & {
|
84
87
|
parentId: string | null;
|
85
|
-
role: "user";
|
86
|
-
content: AppendContentPart[];
|
87
88
|
};
|
88
89
|
type ThreadMessage = ThreadSystemMessage | ThreadUserMessage | ThreadAssistantMessage;
|
89
90
|
/** Core Message Types (without UI content parts) */
|
90
91
|
type CoreUserContentPart = TextContentPart | ImageContentPart;
|
91
92
|
type CoreAssistantContentPart = TextContentPart | ToolCallContentPart;
|
92
|
-
type
|
93
|
+
type CoreSystemMessage = {
|
94
|
+
role: "system";
|
95
|
+
content: [TextContentPart];
|
96
|
+
};
|
97
|
+
type CoreUserMessage = {
|
93
98
|
role: "user";
|
94
99
|
content: CoreUserContentPart[];
|
95
100
|
};
|
96
|
-
type CoreAssistantMessage =
|
101
|
+
type CoreAssistantMessage = {
|
97
102
|
role: "assistant";
|
98
103
|
content: CoreAssistantContentPart[];
|
99
|
-
status: MessageStatus;
|
100
104
|
};
|
101
|
-
type
|
105
|
+
type CoreMessage = CoreSystemMessage | CoreUserMessage | CoreAssistantMessage;
|
102
106
|
|
103
107
|
type ReactThreadRuntime = ThreadRuntime & {
|
104
108
|
unstable_synchronizer?: ComponentType;
|
@@ -123,41 +127,25 @@ type ChatModelAdapter = {
|
|
123
127
|
|
124
128
|
declare abstract class BaseAssistantRuntime<TThreadRuntime extends ReactThreadRuntime> implements AssistantRuntime {
|
125
129
|
private _thread;
|
126
|
-
get capabilities(): Readonly<{
|
127
|
-
edit: boolean;
|
128
|
-
reload: boolean;
|
129
|
-
cancel: boolean;
|
130
|
-
copy: boolean;
|
131
|
-
}>;
|
132
130
|
constructor(_thread: TThreadRuntime);
|
133
|
-
private _unsubscribe;
|
134
131
|
get thread(): TThreadRuntime;
|
135
132
|
set thread(thread: TThreadRuntime);
|
136
133
|
abstract registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;
|
137
134
|
abstract switchToThread(threadId: string | null): void;
|
138
|
-
get messages(): readonly ThreadMessage[];
|
139
|
-
get isRunning(): boolean;
|
140
|
-
getBranches(messageId: string): readonly string[];
|
141
|
-
switchToBranch(branchId: string): void;
|
142
|
-
append(message: AppendMessage): void;
|
143
|
-
startRun(parentId: string | null): void;
|
144
|
-
cancelRun(): void;
|
145
|
-
addToolResult(options: AddToolResultOptions): void;
|
146
135
|
private _subscriptions;
|
147
136
|
subscribe(callback: () => void): Unsubscribe;
|
148
137
|
private subscriptionHandler;
|
149
|
-
get unstable_synchronizer(): react.ComponentType | undefined;
|
150
138
|
}
|
151
139
|
|
152
140
|
declare class LocalRuntime extends BaseAssistantRuntime<LocalThreadRuntime> {
|
153
|
-
private readonly
|
141
|
+
private readonly _proxyConfigProvider;
|
154
142
|
constructor(adapter: ChatModelAdapter);
|
155
143
|
set adapter(adapter: ChatModelAdapter);
|
156
|
-
registerModelConfigProvider(provider: ModelConfigProvider): () =>
|
144
|
+
registerModelConfigProvider(provider: ModelConfigProvider): () => void;
|
157
145
|
switchToThread(threadId: string | null): LocalThreadRuntime;
|
158
146
|
}
|
159
147
|
declare class LocalThreadRuntime implements ThreadRuntime {
|
160
|
-
private
|
148
|
+
private configProvider;
|
161
149
|
adapter: ChatModelAdapter;
|
162
150
|
private _subscriptions;
|
163
151
|
private abortController;
|
@@ -170,7 +158,7 @@ declare class LocalThreadRuntime implements ThreadRuntime {
|
|
170
158
|
}>;
|
171
159
|
get messages(): ThreadMessage[];
|
172
160
|
get isRunning(): boolean;
|
173
|
-
constructor(
|
161
|
+
constructor(configProvider: ModelConfigProvider, adapter: ChatModelAdapter);
|
174
162
|
getBranches(messageId: string): string[];
|
175
163
|
switchToBranch(branchId: string): void;
|
176
164
|
append(message: AppendMessage): Promise<void>;
|
@@ -186,27 +174,13 @@ declare const useLocalRuntime: (adapter: ChatModelAdapter) => LocalRuntime;
|
|
186
174
|
type EdgeRuntimeOptions = {
|
187
175
|
api: string;
|
188
176
|
};
|
189
|
-
declare
|
177
|
+
declare class EdgeChatAdapter implements ChatModelAdapter {
|
178
|
+
private options;
|
179
|
+
constructor(options: EdgeRuntimeOptions);
|
180
|
+
run({ messages, abortSignal, config, onUpdate }: ChatModelRunOptions): Promise<ChatModelRunResult>;
|
181
|
+
}
|
190
182
|
|
191
|
-
|
192
|
-
messageId: string;
|
193
|
-
toolCallId: string;
|
194
|
-
result: any;
|
195
|
-
};
|
196
|
-
type ThreadActionsState = Readonly<{
|
197
|
-
capabilities: Readonly<{
|
198
|
-
edit: boolean;
|
199
|
-
reload: boolean;
|
200
|
-
cancel: boolean;
|
201
|
-
copy: boolean;
|
202
|
-
}>;
|
203
|
-
getBranches: (messageId: string) => readonly string[];
|
204
|
-
switchToBranch: (branchId: string) => void;
|
205
|
-
append: (message: AppendMessage) => void;
|
206
|
-
startRun: (parentId: string | null) => void;
|
207
|
-
cancelRun: () => void;
|
208
|
-
addToolResult: (options: AddToolResultOptions) => void;
|
209
|
-
}>;
|
183
|
+
declare const useEdgeRuntime: (options: EdgeRuntimeOptions) => LocalRuntime;
|
210
184
|
|
211
185
|
type TextContentPartProps = {
|
212
186
|
part: TextContentPart;
|
@@ -230,12 +204,43 @@ type ToolCallContentPartProps<TArgs = any, TResult = any> = {
|
|
230
204
|
};
|
231
205
|
type ToolCallContentPartComponent<TArgs = any, TResult = any> = ComponentType<ToolCallContentPartProps<TArgs, TResult>>;
|
232
206
|
|
233
|
-
|
207
|
+
declare function toLanguageModelMessages(message: readonly CoreMessage[] | readonly ThreadMessage[]): LanguageModelV1Message[];
|
208
|
+
|
209
|
+
declare const fromLanguageModelMessages: (lm: LanguageModelV1Message[], mergeRoundtrips: boolean) => CoreMessage[];
|
210
|
+
|
211
|
+
declare const fromCoreMessages: (message: CoreMessage[]) => ThreadMessage[];
|
212
|
+
|
213
|
+
type AddToolResultOptions = {
|
214
|
+
messageId: string;
|
215
|
+
toolCallId: string;
|
216
|
+
result: any;
|
217
|
+
};
|
218
|
+
type ThreadActionsState = Readonly<{
|
219
|
+
capabilities: Readonly<{
|
220
|
+
edit: boolean;
|
221
|
+
reload: boolean;
|
222
|
+
cancel: boolean;
|
223
|
+
copy: boolean;
|
224
|
+
}>;
|
225
|
+
getBranches: (messageId: string) => readonly string[];
|
226
|
+
switchToBranch: (branchId: string) => void;
|
227
|
+
append: (message: AppendMessage) => void;
|
228
|
+
startRun: (parentId: string | null) => void;
|
229
|
+
cancelRun: () => void;
|
230
|
+
addToolResult: (options: AddToolResultOptions) => void;
|
231
|
+
getRuntime: () => ThreadRuntime;
|
232
|
+
}>;
|
233
|
+
|
234
|
+
type ThreadRuntime = Readonly<ThreadState & Omit<ThreadActionsState, "getRuntime"> & {
|
234
235
|
messages: readonly ThreadMessage[];
|
235
236
|
subscribe: (callback: () => void) => Unsubscribe;
|
236
237
|
}>;
|
237
238
|
|
238
|
-
type
|
239
|
+
type ThreadRuntimeWithSubscribe = {
|
240
|
+
readonly thread: ThreadRuntime;
|
241
|
+
subscribe: (callback: () => void) => Unsubscribe;
|
242
|
+
};
|
243
|
+
type AssistantRuntime = ThreadRuntimeWithSubscribe & {
|
239
244
|
switchToThread: (threadId: string | null) => void;
|
240
245
|
registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
|
241
246
|
};
|
@@ -247,10 +252,10 @@ declare const AssistantRuntimeProvider: react.NamedExoticComponent<PropsWithChil
|
|
247
252
|
|
248
253
|
type AssistantActionsState = Readonly<{
|
249
254
|
switchToThread: (threadId: string | null) => void;
|
255
|
+
getRuntime: () => AssistantRuntime;
|
250
256
|
}>;
|
251
257
|
|
252
|
-
type AssistantModelConfigState = Readonly<{
|
253
|
-
getModelConfig: ModelConfigProvider;
|
258
|
+
type AssistantModelConfigState = Readonly<ModelConfigProvider & {
|
254
259
|
registerModelConfigProvider: (provider: ModelConfigProvider) => () => void;
|
255
260
|
}>;
|
256
261
|
|
@@ -1016,7 +1021,7 @@ declare const exports: {
|
|
1016
1021
|
Text: FC<TextContentPartProps>;
|
1017
1022
|
};
|
1018
1023
|
|
1019
|
-
declare class ProxyConfigProvider {
|
1024
|
+
declare class ProxyConfigProvider implements ModelConfigProvider {
|
1020
1025
|
private _providers;
|
1021
1026
|
getModelConfig(): ModelConfig;
|
1022
1027
|
registerModelConfigProvider(provider: ModelConfigProvider): () => void;
|
@@ -1042,6 +1047,8 @@ declare class MessageRepository {
|
|
1042
1047
|
|
1043
1048
|
declare const useSmooth: (text: string, smooth?: boolean) => string;
|
1044
1049
|
|
1050
|
+
declare const generateId: (size?: number) => string;
|
1051
|
+
|
1045
1052
|
type internal_BaseAssistantRuntime<TThreadRuntime extends ReactThreadRuntime> = BaseAssistantRuntime<TThreadRuntime>;
|
1046
1053
|
declare const internal_BaseAssistantRuntime: typeof BaseAssistantRuntime;
|
1047
1054
|
type internal_MessageRepository = MessageRepository;
|
@@ -1049,9 +1056,10 @@ declare const internal_MessageRepository: typeof MessageRepository;
|
|
1049
1056
|
type internal_ProxyConfigProvider = ProxyConfigProvider;
|
1050
1057
|
declare const internal_ProxyConfigProvider: typeof ProxyConfigProvider;
|
1051
1058
|
declare const internal_TooltipIconButton: typeof TooltipIconButton;
|
1059
|
+
declare const internal_generateId: typeof generateId;
|
1052
1060
|
declare const internal_useSmooth: typeof useSmooth;
|
1053
1061
|
declare namespace internal {
|
1054
|
-
export { internal_BaseAssistantRuntime as BaseAssistantRuntime, internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider, internal_TooltipIconButton as TooltipIconButton, internal_useSmooth as useSmooth };
|
1062
|
+
export { internal_BaseAssistantRuntime as BaseAssistantRuntime, internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider, internal_TooltipIconButton as TooltipIconButton, internal_generateId as generateId, internal_useSmooth as useSmooth };
|
1055
1063
|
}
|
1056
1064
|
|
1057
|
-
export { index$6 as ActionBarPrimitive, type ActionBarPrimitiveCopyProps, type ActionBarPrimitiveEditProps, type ActionBarPrimitiveReloadProps, type ActionBarPrimitiveRootProps, type AddToolResultOptions, type
|
1065
|
+
export { index$6 as ActionBarPrimitive, type ActionBarPrimitiveCopyProps, type ActionBarPrimitiveEditProps, type ActionBarPrimitiveReloadProps, type ActionBarPrimitiveRootProps, type AddToolResultOptions, type AppendMessage, _default$9 as AssistantActionBar, type AssistantActionsState, type AssistantContextValue, _default$8 as AssistantMessage, type AssistantMessageConfig, type AssistantMessageContentProps, _default$7 as AssistantModal, index$5 as AssistantModalPrimitive, type AssistantModalPrimitiveContentProps, type AssistantModalPrimitiveRootProps, type AssistantModalPrimitiveTriggerProps, type AssistantModelConfigState, type AssistantRuntime, AssistantRuntimeProvider, type AssistantToolProps, type AssistantToolUIProps, type AssistantToolUIsState, _default$6 as BranchPicker, index$4 as BranchPickerPrimitive, type BranchPickerPrimitiveCountProps, type BranchPickerPrimitiveNextProps, type BranchPickerPrimitiveNumberProps, type BranchPickerPrimitivePreviousProps, type BranchPickerPrimitiveRootProps, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, _default$5 as Composer, type ComposerContextValue, type ComposerInputProps, index$3 as ComposerPrimitive, type ComposerPrimitiveCancelProps, type ComposerPrimitiveIfProps, type ComposerPrimitiveInputProps, type ComposerPrimitiveRootProps, type ComposerPrimitiveSendProps, type ComposerState, exports as ContentPart, type ContentPartContextValue, index$2 as ContentPartPrimitive, type ContentPartPrimitiveDisplayProps, type ContentPartPrimitiveImageProps, type ContentPartPrimitiveInProgressProps, type ContentPartPrimitiveTextProps, type ContentPartState, type CoreAssistantContentPart, type CoreAssistantMessage, type CoreMessage, type CoreSystemMessage, type CoreUserContentPart, type CoreUserMessage, EdgeChatAdapter, type EdgeRuntimeOptions, _default$4 as EditComposer, type EditComposerState, internal as INTERNAL, type ImageContentPart, type ImageContentPartComponent, type ImageContentPartProps, type MessageContextValue, index$1 as MessagePrimitive, type MessagePrimitiveContentProps, type MessagePrimitiveIfProps, type MessagePrimitiveInProgressProps, type MessagePrimitiveRootProps, type MessageState, type MessageStatus, type MessageUtilsState, type ModelConfig, type ModelConfigProvider, type ReactThreadRuntime, type StringsConfig, type SuggestionConfig, type TextContentPart, type TextContentPartComponent, type TextContentPartProps, _default$3 as Thread, type ThreadActionsState, type ThreadAssistantContentPart, type ThreadAssistantMessage, type ThreadConfig, ThreadConfigProvider, type ThreadConfigProviderProps, type ThreadContextValue, type ThreadMessage, type ThreadMessagesState, index as ThreadPrimitive, type ThreadPrimitiveEmptyProps, type ThreadPrimitiveIfProps, type ThreadPrimitiveMessagesProps, type ThreadPrimitiveRootProps, type ThreadPrimitiveScrollToBottomProps, type ThreadPrimitiveSuggestionProps, type ThreadPrimitiveViewportProps, type ThreadRootProps, type ThreadRuntime, type ThreadState, type ThreadSystemMessage, type ThreadUserContentPart, type ThreadUserMessage, type ThreadViewportState, _default as ThreadWelcome, type ThreadWelcomeConfig, type ThreadWelcomeMessageProps, type ThreadWelcomeSuggestionProps, type Tool, type ToolCallContentPart, type ToolCallContentPartComponent, type ToolCallContentPartProps, type UIContentPart, type UIContentPartComponent, type UIContentPartProps, type Unsubscribe, type UseActionBarCopyProps, _default$1 as UserActionBar, _default$2 as UserMessage, type UserMessageConfig, type UserMessageContentProps, fromCoreMessages, fromLanguageModelMessages, makeAssistantTool, makeAssistantToolUI, toLanguageModelMessages, useActionBarCopy, useActionBarEdit, useActionBarReload, useAppendMessage, useAssistantContext, useAssistantInstructions, useAssistantTool, useAssistantToolUI, useBranchPickerCount, useBranchPickerNext, useBranchPickerNumber, useBranchPickerPrevious, useComposerCancel, useComposerContext, useComposerIf, useComposerSend, useContentPartContext, useContentPartDisplay, useContentPartImage, useContentPartText, useEdgeRuntime, useLocalRuntime, useMessageContext, useMessageIf, useSwitchToNewThread, useThreadConfig, useThreadContext, useThreadEmpty, useThreadIf, useThreadScrollToBottom, useThreadSuggestion };
|