@assistant-ui/react 0.4.8 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/edge.d.mts +9 -15
- package/dist/edge.d.ts +9 -15
- package/dist/edge.js +90 -16
- package/dist/edge.js.map +1 -1
- package/dist/edge.mjs +90 -16
- package/dist/edge.mjs.map +1 -1
- package/dist/index.d.mts +51 -24
- package/dist/index.d.ts +51 -24
- package/dist/index.js +366 -233
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +366 -235
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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 {
|
5
|
+
import { LanguageModelV1LogProbs, LanguageModelV1Message, LanguageModelV1FunctionTool } 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';
|
@@ -100,19 +100,38 @@ type MessageCommonProps = {
|
|
100
100
|
id: string;
|
101
101
|
createdAt: Date;
|
102
102
|
};
|
103
|
-
type
|
104
|
-
|
105
|
-
} | {
|
106
|
-
type: "done";
|
107
|
-
finishReason?: LanguageModelV1FinishReason;
|
108
|
-
logprops?: LanguageModelV1LogProbs;
|
103
|
+
type ThreadRoundtrip = {
|
104
|
+
logprobs?: LanguageModelV1LogProbs | undefined;
|
109
105
|
usage?: {
|
110
106
|
promptTokens: number;
|
111
107
|
completionTokens: number;
|
112
|
-
};
|
108
|
+
} | undefined;
|
109
|
+
};
|
110
|
+
type ContentPartStatus = {
|
111
|
+
type: "running";
|
112
|
+
} | {
|
113
|
+
type: "complete";
|
114
|
+
} | {
|
115
|
+
type: "incomplete";
|
116
|
+
reason: "cancelled" | "length" | "content-filter" | "other" | "error";
|
117
|
+
error?: unknown;
|
118
|
+
};
|
119
|
+
type ToolContentPartStatus = {
|
120
|
+
type: "requires-action";
|
121
|
+
reason: "tool-calls";
|
122
|
+
} | ContentPartStatus;
|
123
|
+
type MessageStatus = {
|
124
|
+
type: "running";
|
125
|
+
} | {
|
126
|
+
type: "requires-action";
|
127
|
+
reason: "tool-calls";
|
128
|
+
} | {
|
129
|
+
type: "complete";
|
130
|
+
reason: "stop" | "unknown";
|
113
131
|
} | {
|
114
|
-
type: "
|
115
|
-
|
132
|
+
type: "incomplete";
|
133
|
+
reason: "cancelled" | "tool-calls" | "length" | "content-filter" | "other" | "error";
|
134
|
+
error?: unknown;
|
116
135
|
};
|
117
136
|
type ThreadSystemMessage = MessageCommonProps & {
|
118
137
|
role: "system";
|
@@ -126,6 +145,7 @@ type ThreadAssistantMessage = MessageCommonProps & {
|
|
126
145
|
role: "assistant";
|
127
146
|
content: ThreadAssistantContentPart[];
|
128
147
|
status: MessageStatus;
|
148
|
+
roundtrips?: ThreadRoundtrip[] | undefined;
|
129
149
|
};
|
130
150
|
type AppendMessage = CoreMessage & {
|
131
151
|
parentId: string | null;
|
@@ -160,12 +180,13 @@ type ChatModelRunUpdate = {
|
|
160
180
|
type ChatModelRunResult = {
|
161
181
|
content: ThreadAssistantContentPart[];
|
162
182
|
status?: MessageStatus;
|
183
|
+
roundtrips?: ThreadRoundtrip[];
|
163
184
|
};
|
164
185
|
type ChatModelRunOptions = {
|
165
186
|
messages: ThreadMessage[];
|
166
187
|
abortSignal: AbortSignal;
|
167
188
|
config: ModelConfig;
|
168
|
-
onUpdate: (result: ChatModelRunUpdate) =>
|
189
|
+
onUpdate: (result: ChatModelRunUpdate) => void;
|
169
190
|
};
|
170
191
|
type ChatModelAdapter = {
|
171
192
|
run: (options: ChatModelRunOptions) => Promise<ChatModelRunResult>;
|
@@ -185,6 +206,7 @@ declare abstract class BaseAssistantRuntime<TThreadRuntime extends ReactThreadRu
|
|
185
206
|
|
186
207
|
type LocalRuntimeOptions = {
|
187
208
|
initialMessages?: readonly CoreMessage[] | undefined;
|
209
|
+
maxToolRoundtrips?: number;
|
188
210
|
};
|
189
211
|
declare class LocalRuntime extends BaseAssistantRuntime<LocalThreadRuntime> {
|
190
212
|
private readonly _proxyConfigProvider;
|
@@ -196,6 +218,7 @@ declare class LocalRuntime extends BaseAssistantRuntime<LocalThreadRuntime> {
|
|
196
218
|
declare class LocalThreadRuntime implements ThreadRuntime {
|
197
219
|
private configProvider;
|
198
220
|
adapter: ChatModelAdapter;
|
221
|
+
private options?;
|
199
222
|
private _subscriptions;
|
200
223
|
private abortController;
|
201
224
|
private readonly repository;
|
@@ -207,11 +230,12 @@ declare class LocalThreadRuntime implements ThreadRuntime {
|
|
207
230
|
}>;
|
208
231
|
get messages(): ThreadMessage[];
|
209
232
|
get isRunning(): boolean;
|
210
|
-
constructor(configProvider: ModelConfigProvider, adapter: ChatModelAdapter, options?: LocalRuntimeOptions);
|
233
|
+
constructor(configProvider: ModelConfigProvider, adapter: ChatModelAdapter, options?: LocalRuntimeOptions | undefined);
|
211
234
|
getBranches(messageId: string): string[];
|
212
235
|
switchToBranch(branchId: string): void;
|
213
236
|
append(message: AppendMessage): Promise<void>;
|
214
237
|
startRun(parentId: string | null): Promise<void>;
|
238
|
+
private performRoundtrip;
|
215
239
|
cancelRun(): void;
|
216
240
|
private notifySubscribers;
|
217
241
|
subscribe(callback: () => void): Unsubscribe;
|
@@ -224,22 +248,22 @@ declare function toLanguageModelMessages(message: readonly CoreMessage[] | reado
|
|
224
248
|
|
225
249
|
type TextContentPartProps = {
|
226
250
|
part: TextContentPart;
|
227
|
-
status:
|
251
|
+
status: ContentPartStatus;
|
228
252
|
};
|
229
253
|
type TextContentPartComponent = ComponentType<TextContentPartProps>;
|
230
254
|
type ImageContentPartProps = {
|
231
255
|
part: ImageContentPart;
|
232
|
-
status:
|
256
|
+
status: ContentPartStatus;
|
233
257
|
};
|
234
258
|
type ImageContentPartComponent = ComponentType<ImageContentPartProps>;
|
235
259
|
type UIContentPartProps = {
|
236
260
|
part: UIContentPart;
|
237
|
-
status:
|
261
|
+
status: ContentPartStatus;
|
238
262
|
};
|
239
263
|
type UIContentPartComponent = ComponentType<UIContentPartProps>;
|
240
264
|
type ToolCallContentPartProps<TArgs extends Record<string, unknown> = any, TResult = unknown> = {
|
241
265
|
part: ToolCallContentPart<TArgs, TResult>;
|
242
|
-
status:
|
266
|
+
status: ToolContentPartStatus;
|
243
267
|
addResult: (result: any) => void;
|
244
268
|
};
|
245
269
|
type ToolCallContentPartComponent<TArgs extends Record<string, unknown> = any, TResult = any> = ComponentType<ToolCallContentPartProps<TArgs, TResult>>;
|
@@ -250,8 +274,13 @@ type fromLanguageModelMessagesOptions = {
|
|
250
274
|
declare const fromLanguageModelMessages: (lm: LanguageModelV1Message[], { mergeRoundtrips }: fromLanguageModelMessagesOptions) => CoreMessage[];
|
251
275
|
|
252
276
|
declare const fromCoreMessages: (message: readonly CoreMessage[]) => ThreadMessage[];
|
277
|
+
declare const fromCoreMessage: (message: CoreMessage, { id, status, }?: {
|
278
|
+
id?: string | undefined;
|
279
|
+
status?: MessageStatus | undefined;
|
280
|
+
}) => ThreadMessage;
|
253
281
|
|
254
282
|
declare const toCoreMessages: (message: ThreadMessage[]) => CoreMessage[];
|
283
|
+
declare const toCoreMessage: (message: ThreadMessage) => CoreMessage;
|
255
284
|
|
256
285
|
declare const fromLanguageModelTools: (tools: LanguageModelV1FunctionTool[]) => Record<string, Tool<any, any>>;
|
257
286
|
|
@@ -259,12 +288,10 @@ declare const toLanguageModelTools: (tools: Record<string, Tool<any, any>>) => L
|
|
259
288
|
|
260
289
|
type EdgeChatAdapterOptions = {
|
261
290
|
api: string;
|
262
|
-
maxToolRoundtrips?: number;
|
263
291
|
};
|
264
292
|
declare class EdgeChatAdapter implements ChatModelAdapter {
|
265
293
|
private options;
|
266
294
|
constructor(options: EdgeChatAdapterOptions);
|
267
|
-
roundtrip(initialContent: ThreadAssistantContentPart[], { messages, abortSignal, config, onUpdate }: ChatModelRunOptions): Promise<readonly [ThreadMessage | undefined, ChatModelRunResult]>;
|
268
295
|
run({ messages, abortSignal, config, onUpdate }: ChatModelRunOptions): Promise<ChatModelRunResult>;
|
269
296
|
}
|
270
297
|
|
@@ -655,7 +682,7 @@ declare function useMessageContext(options: {
|
|
655
682
|
}): MessageContextValue | null;
|
656
683
|
|
657
684
|
type ContentPartState = Readonly<{
|
658
|
-
status:
|
685
|
+
status: ToolContentPartStatus;
|
659
686
|
part: TextContentPart | ImageContentPart | UIContentPart | ToolCallContentPart;
|
660
687
|
}>;
|
661
688
|
|
@@ -735,17 +762,17 @@ declare const useComposerIf: (props: UseComposerIfProps) => boolean;
|
|
735
762
|
declare const useComposerSend: () => (() => void) | null;
|
736
763
|
|
737
764
|
declare const useContentPartDisplay: () => Readonly<{
|
738
|
-
status:
|
765
|
+
status: ContentPartStatus;
|
739
766
|
part: UIContentPart;
|
740
767
|
}>;
|
741
768
|
|
742
769
|
declare const useContentPartImage: () => Readonly<{
|
743
|
-
status:
|
770
|
+
status: ContentPartStatus;
|
744
771
|
part: ImageContentPart;
|
745
772
|
}>;
|
746
773
|
|
747
774
|
declare const useContentPartText: () => Readonly<{
|
748
|
-
status:
|
775
|
+
status: ContentPartStatus;
|
749
776
|
part: TextContentPart;
|
750
777
|
}>;
|
751
778
|
|
@@ -1349,7 +1376,7 @@ declare class MessageRepository {
|
|
1349
1376
|
parentId: string | null;
|
1350
1377
|
message: ThreadMessage;
|
1351
1378
|
};
|
1352
|
-
appendOptimisticMessage(parentId: string | null, message:
|
1379
|
+
appendOptimisticMessage(parentId: string | null, message: CoreMessage): string;
|
1353
1380
|
deleteMessage(messageId: string, replacementId?: string | null | undefined): void;
|
1354
1381
|
getBranches(messageId: string): string[];
|
1355
1382
|
switchToBranch(messageId: string): void;
|
@@ -1373,4 +1400,4 @@ declare namespace internal {
|
|
1373
1400
|
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 };
|
1374
1401
|
}
|
1375
1402
|
|
1376
|
-
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, type EdgeRuntimeRequestOptions, _default$4 as EditComposer, type EditComposerState, internal as INTERNAL, type ImageContentPart, type ImageContentPartComponent, type ImageContentPartProps, type LocalRuntimeOptions, 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, fromLanguageModelTools, makeAssistantTool, makeAssistantToolUI, toCoreMessages, toLanguageModelMessages, toLanguageModelTools, 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 };
|
1403
|
+
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, type EdgeRuntimeRequestOptions, _default$4 as EditComposer, type EditComposerState, internal as INTERNAL, type ImageContentPart, type ImageContentPartComponent, type ImageContentPartProps, type LocalRuntimeOptions, 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, fromCoreMessage, fromCoreMessages, fromLanguageModelMessages, fromLanguageModelTools, makeAssistantTool, makeAssistantToolUI, toCoreMessage, toCoreMessages, toLanguageModelMessages, toLanguageModelTools, 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 {
|
5
|
+
import { LanguageModelV1LogProbs, LanguageModelV1Message, LanguageModelV1FunctionTool } 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';
|
@@ -100,19 +100,38 @@ type MessageCommonProps = {
|
|
100
100
|
id: string;
|
101
101
|
createdAt: Date;
|
102
102
|
};
|
103
|
-
type
|
104
|
-
|
105
|
-
} | {
|
106
|
-
type: "done";
|
107
|
-
finishReason?: LanguageModelV1FinishReason;
|
108
|
-
logprops?: LanguageModelV1LogProbs;
|
103
|
+
type ThreadRoundtrip = {
|
104
|
+
logprobs?: LanguageModelV1LogProbs | undefined;
|
109
105
|
usage?: {
|
110
106
|
promptTokens: number;
|
111
107
|
completionTokens: number;
|
112
|
-
};
|
108
|
+
} | undefined;
|
109
|
+
};
|
110
|
+
type ContentPartStatus = {
|
111
|
+
type: "running";
|
112
|
+
} | {
|
113
|
+
type: "complete";
|
114
|
+
} | {
|
115
|
+
type: "incomplete";
|
116
|
+
reason: "cancelled" | "length" | "content-filter" | "other" | "error";
|
117
|
+
error?: unknown;
|
118
|
+
};
|
119
|
+
type ToolContentPartStatus = {
|
120
|
+
type: "requires-action";
|
121
|
+
reason: "tool-calls";
|
122
|
+
} | ContentPartStatus;
|
123
|
+
type MessageStatus = {
|
124
|
+
type: "running";
|
125
|
+
} | {
|
126
|
+
type: "requires-action";
|
127
|
+
reason: "tool-calls";
|
128
|
+
} | {
|
129
|
+
type: "complete";
|
130
|
+
reason: "stop" | "unknown";
|
113
131
|
} | {
|
114
|
-
type: "
|
115
|
-
|
132
|
+
type: "incomplete";
|
133
|
+
reason: "cancelled" | "tool-calls" | "length" | "content-filter" | "other" | "error";
|
134
|
+
error?: unknown;
|
116
135
|
};
|
117
136
|
type ThreadSystemMessage = MessageCommonProps & {
|
118
137
|
role: "system";
|
@@ -126,6 +145,7 @@ type ThreadAssistantMessage = MessageCommonProps & {
|
|
126
145
|
role: "assistant";
|
127
146
|
content: ThreadAssistantContentPart[];
|
128
147
|
status: MessageStatus;
|
148
|
+
roundtrips?: ThreadRoundtrip[] | undefined;
|
129
149
|
};
|
130
150
|
type AppendMessage = CoreMessage & {
|
131
151
|
parentId: string | null;
|
@@ -160,12 +180,13 @@ type ChatModelRunUpdate = {
|
|
160
180
|
type ChatModelRunResult = {
|
161
181
|
content: ThreadAssistantContentPart[];
|
162
182
|
status?: MessageStatus;
|
183
|
+
roundtrips?: ThreadRoundtrip[];
|
163
184
|
};
|
164
185
|
type ChatModelRunOptions = {
|
165
186
|
messages: ThreadMessage[];
|
166
187
|
abortSignal: AbortSignal;
|
167
188
|
config: ModelConfig;
|
168
|
-
onUpdate: (result: ChatModelRunUpdate) =>
|
189
|
+
onUpdate: (result: ChatModelRunUpdate) => void;
|
169
190
|
};
|
170
191
|
type ChatModelAdapter = {
|
171
192
|
run: (options: ChatModelRunOptions) => Promise<ChatModelRunResult>;
|
@@ -185,6 +206,7 @@ declare abstract class BaseAssistantRuntime<TThreadRuntime extends ReactThreadRu
|
|
185
206
|
|
186
207
|
type LocalRuntimeOptions = {
|
187
208
|
initialMessages?: readonly CoreMessage[] | undefined;
|
209
|
+
maxToolRoundtrips?: number;
|
188
210
|
};
|
189
211
|
declare class LocalRuntime extends BaseAssistantRuntime<LocalThreadRuntime> {
|
190
212
|
private readonly _proxyConfigProvider;
|
@@ -196,6 +218,7 @@ declare class LocalRuntime extends BaseAssistantRuntime<LocalThreadRuntime> {
|
|
196
218
|
declare class LocalThreadRuntime implements ThreadRuntime {
|
197
219
|
private configProvider;
|
198
220
|
adapter: ChatModelAdapter;
|
221
|
+
private options?;
|
199
222
|
private _subscriptions;
|
200
223
|
private abortController;
|
201
224
|
private readonly repository;
|
@@ -207,11 +230,12 @@ declare class LocalThreadRuntime implements ThreadRuntime {
|
|
207
230
|
}>;
|
208
231
|
get messages(): ThreadMessage[];
|
209
232
|
get isRunning(): boolean;
|
210
|
-
constructor(configProvider: ModelConfigProvider, adapter: ChatModelAdapter, options?: LocalRuntimeOptions);
|
233
|
+
constructor(configProvider: ModelConfigProvider, adapter: ChatModelAdapter, options?: LocalRuntimeOptions | undefined);
|
211
234
|
getBranches(messageId: string): string[];
|
212
235
|
switchToBranch(branchId: string): void;
|
213
236
|
append(message: AppendMessage): Promise<void>;
|
214
237
|
startRun(parentId: string | null): Promise<void>;
|
238
|
+
private performRoundtrip;
|
215
239
|
cancelRun(): void;
|
216
240
|
private notifySubscribers;
|
217
241
|
subscribe(callback: () => void): Unsubscribe;
|
@@ -224,22 +248,22 @@ declare function toLanguageModelMessages(message: readonly CoreMessage[] | reado
|
|
224
248
|
|
225
249
|
type TextContentPartProps = {
|
226
250
|
part: TextContentPart;
|
227
|
-
status:
|
251
|
+
status: ContentPartStatus;
|
228
252
|
};
|
229
253
|
type TextContentPartComponent = ComponentType<TextContentPartProps>;
|
230
254
|
type ImageContentPartProps = {
|
231
255
|
part: ImageContentPart;
|
232
|
-
status:
|
256
|
+
status: ContentPartStatus;
|
233
257
|
};
|
234
258
|
type ImageContentPartComponent = ComponentType<ImageContentPartProps>;
|
235
259
|
type UIContentPartProps = {
|
236
260
|
part: UIContentPart;
|
237
|
-
status:
|
261
|
+
status: ContentPartStatus;
|
238
262
|
};
|
239
263
|
type UIContentPartComponent = ComponentType<UIContentPartProps>;
|
240
264
|
type ToolCallContentPartProps<TArgs extends Record<string, unknown> = any, TResult = unknown> = {
|
241
265
|
part: ToolCallContentPart<TArgs, TResult>;
|
242
|
-
status:
|
266
|
+
status: ToolContentPartStatus;
|
243
267
|
addResult: (result: any) => void;
|
244
268
|
};
|
245
269
|
type ToolCallContentPartComponent<TArgs extends Record<string, unknown> = any, TResult = any> = ComponentType<ToolCallContentPartProps<TArgs, TResult>>;
|
@@ -250,8 +274,13 @@ type fromLanguageModelMessagesOptions = {
|
|
250
274
|
declare const fromLanguageModelMessages: (lm: LanguageModelV1Message[], { mergeRoundtrips }: fromLanguageModelMessagesOptions) => CoreMessage[];
|
251
275
|
|
252
276
|
declare const fromCoreMessages: (message: readonly CoreMessage[]) => ThreadMessage[];
|
277
|
+
declare const fromCoreMessage: (message: CoreMessage, { id, status, }?: {
|
278
|
+
id?: string | undefined;
|
279
|
+
status?: MessageStatus | undefined;
|
280
|
+
}) => ThreadMessage;
|
253
281
|
|
254
282
|
declare const toCoreMessages: (message: ThreadMessage[]) => CoreMessage[];
|
283
|
+
declare const toCoreMessage: (message: ThreadMessage) => CoreMessage;
|
255
284
|
|
256
285
|
declare const fromLanguageModelTools: (tools: LanguageModelV1FunctionTool[]) => Record<string, Tool<any, any>>;
|
257
286
|
|
@@ -259,12 +288,10 @@ declare const toLanguageModelTools: (tools: Record<string, Tool<any, any>>) => L
|
|
259
288
|
|
260
289
|
type EdgeChatAdapterOptions = {
|
261
290
|
api: string;
|
262
|
-
maxToolRoundtrips?: number;
|
263
291
|
};
|
264
292
|
declare class EdgeChatAdapter implements ChatModelAdapter {
|
265
293
|
private options;
|
266
294
|
constructor(options: EdgeChatAdapterOptions);
|
267
|
-
roundtrip(initialContent: ThreadAssistantContentPart[], { messages, abortSignal, config, onUpdate }: ChatModelRunOptions): Promise<readonly [ThreadMessage | undefined, ChatModelRunResult]>;
|
268
295
|
run({ messages, abortSignal, config, onUpdate }: ChatModelRunOptions): Promise<ChatModelRunResult>;
|
269
296
|
}
|
270
297
|
|
@@ -655,7 +682,7 @@ declare function useMessageContext(options: {
|
|
655
682
|
}): MessageContextValue | null;
|
656
683
|
|
657
684
|
type ContentPartState = Readonly<{
|
658
|
-
status:
|
685
|
+
status: ToolContentPartStatus;
|
659
686
|
part: TextContentPart | ImageContentPart | UIContentPart | ToolCallContentPart;
|
660
687
|
}>;
|
661
688
|
|
@@ -735,17 +762,17 @@ declare const useComposerIf: (props: UseComposerIfProps) => boolean;
|
|
735
762
|
declare const useComposerSend: () => (() => void) | null;
|
736
763
|
|
737
764
|
declare const useContentPartDisplay: () => Readonly<{
|
738
|
-
status:
|
765
|
+
status: ContentPartStatus;
|
739
766
|
part: UIContentPart;
|
740
767
|
}>;
|
741
768
|
|
742
769
|
declare const useContentPartImage: () => Readonly<{
|
743
|
-
status:
|
770
|
+
status: ContentPartStatus;
|
744
771
|
part: ImageContentPart;
|
745
772
|
}>;
|
746
773
|
|
747
774
|
declare const useContentPartText: () => Readonly<{
|
748
|
-
status:
|
775
|
+
status: ContentPartStatus;
|
749
776
|
part: TextContentPart;
|
750
777
|
}>;
|
751
778
|
|
@@ -1349,7 +1376,7 @@ declare class MessageRepository {
|
|
1349
1376
|
parentId: string | null;
|
1350
1377
|
message: ThreadMessage;
|
1351
1378
|
};
|
1352
|
-
appendOptimisticMessage(parentId: string | null, message:
|
1379
|
+
appendOptimisticMessage(parentId: string | null, message: CoreMessage): string;
|
1353
1380
|
deleteMessage(messageId: string, replacementId?: string | null | undefined): void;
|
1354
1381
|
getBranches(messageId: string): string[];
|
1355
1382
|
switchToBranch(messageId: string): void;
|
@@ -1373,4 +1400,4 @@ declare namespace internal {
|
|
1373
1400
|
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 };
|
1374
1401
|
}
|
1375
1402
|
|
1376
|
-
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, type EdgeRuntimeRequestOptions, _default$4 as EditComposer, type EditComposerState, internal as INTERNAL, type ImageContentPart, type ImageContentPartComponent, type ImageContentPartProps, type LocalRuntimeOptions, 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, fromLanguageModelTools, makeAssistantTool, makeAssistantToolUI, toCoreMessages, toLanguageModelMessages, toLanguageModelTools, 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 };
|
1403
|
+
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, type EdgeRuntimeRequestOptions, _default$4 as EditComposer, type EditComposerState, internal as INTERNAL, type ImageContentPart, type ImageContentPartComponent, type ImageContentPartProps, type LocalRuntimeOptions, 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, fromCoreMessage, fromCoreMessages, fromLanguageModelMessages, fromLanguageModelTools, makeAssistantTool, makeAssistantToolUI, toCoreMessage, toCoreMessages, toLanguageModelMessages, toLanguageModelTools, 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 };
|