@assistant-ui/react 0.5.30 → 0.5.31

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,412 @@
1
+ import { z } from 'zod';
2
+ import { JSONSchema7 } from 'json-schema';
3
+ import { LanguageModelV1LogProbs } from '@ai-sdk/provider';
4
+ import { ReactNode } from 'react';
5
+
6
+ declare const LanguageModelV1CallSettingsSchema: z.ZodObject<{
7
+ maxTokens: z.ZodOptional<z.ZodNumber>;
8
+ temperature: z.ZodOptional<z.ZodNumber>;
9
+ topP: z.ZodOptional<z.ZodNumber>;
10
+ presencePenalty: z.ZodOptional<z.ZodNumber>;
11
+ frequencyPenalty: z.ZodOptional<z.ZodNumber>;
12
+ seed: z.ZodOptional<z.ZodNumber>;
13
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodString>>>;
14
+ }, "strip", z.ZodTypeAny, {
15
+ maxTokens?: number | undefined;
16
+ temperature?: number | undefined;
17
+ topP?: number | undefined;
18
+ presencePenalty?: number | undefined;
19
+ frequencyPenalty?: number | undefined;
20
+ seed?: number | undefined;
21
+ headers?: Record<string, string | undefined> | undefined;
22
+ }, {
23
+ maxTokens?: number | undefined;
24
+ temperature?: number | undefined;
25
+ topP?: number | undefined;
26
+ presencePenalty?: number | undefined;
27
+ frequencyPenalty?: number | undefined;
28
+ seed?: number | undefined;
29
+ headers?: Record<string, string | undefined> | undefined;
30
+ }>;
31
+ type LanguageModelV1CallSettings = z.infer<typeof LanguageModelV1CallSettingsSchema>;
32
+ declare const LanguageModelConfigSchema: z.ZodObject<{
33
+ apiKey: z.ZodOptional<z.ZodString>;
34
+ baseUrl: z.ZodOptional<z.ZodString>;
35
+ modelName: z.ZodOptional<z.ZodString>;
36
+ }, "strip", z.ZodTypeAny, {
37
+ apiKey?: string | undefined;
38
+ baseUrl?: string | undefined;
39
+ modelName?: string | undefined;
40
+ }, {
41
+ apiKey?: string | undefined;
42
+ baseUrl?: string | undefined;
43
+ modelName?: string | undefined;
44
+ }>;
45
+ type LanguageModelConfig = z.infer<typeof LanguageModelConfigSchema>;
46
+ type ToolExecuteFunction<TArgs, TResult> = (args: TArgs, context: {
47
+ abortSignal: AbortSignal;
48
+ }) => TResult | Promise<TResult>;
49
+ type Tool<TArgs extends Record<string, unknown> = Record<string | number, unknown>, TResult = unknown> = {
50
+ description?: string | undefined;
51
+ parameters: z.ZodSchema<TArgs> | JSONSchema7;
52
+ execute?: ToolExecuteFunction<TArgs, TResult>;
53
+ };
54
+ type ModelConfig = {
55
+ priority?: number | undefined;
56
+ system?: string | undefined;
57
+ tools?: Record<string, Tool<any, any>> | undefined;
58
+ callSettings?: LanguageModelV1CallSettings | undefined;
59
+ config?: LanguageModelConfig | undefined;
60
+ };
61
+ type ModelConfigProvider = {
62
+ getModelConfig: () => ModelConfig;
63
+ };
64
+
65
+ type TextContentPart = {
66
+ type: "text";
67
+ text: string;
68
+ };
69
+ type ImageContentPart = {
70
+ type: "image";
71
+ image: string;
72
+ };
73
+ type UIContentPart = {
74
+ type: "ui";
75
+ display: ReactNode;
76
+ };
77
+ type CoreToolCallContentPart<TArgs extends Record<string, unknown> = Record<string | number, unknown>, TResult = unknown> = {
78
+ type: "tool-call";
79
+ toolCallId: string;
80
+ toolName: string;
81
+ args: TArgs;
82
+ result?: TResult | undefined;
83
+ isError?: boolean | undefined;
84
+ };
85
+ type ToolCallContentPart<TArgs extends Record<string, unknown> = Record<string | number, unknown>, TResult = unknown> = CoreToolCallContentPart<TArgs, TResult> & {
86
+ argsText: string;
87
+ };
88
+ type ThreadUserContentPart = TextContentPart | ImageContentPart | UIContentPart;
89
+ type ThreadAssistantContentPart = TextContentPart | ToolCallContentPart | UIContentPart;
90
+ type MessageCommonProps = {
91
+ id: string;
92
+ createdAt: Date;
93
+ };
94
+ type ThreadRoundtrip = {
95
+ logprobs?: LanguageModelV1LogProbs | undefined;
96
+ usage?: {
97
+ promptTokens: number;
98
+ completionTokens: number;
99
+ } | undefined;
100
+ };
101
+ type ContentPartStatus = {
102
+ type: "running";
103
+ } | {
104
+ type: "complete";
105
+ } | {
106
+ type: "incomplete";
107
+ reason: "cancelled" | "length" | "content-filter" | "other" | "error";
108
+ error?: unknown;
109
+ };
110
+ type ToolCallContentPartStatus = {
111
+ type: "requires-action";
112
+ reason: "tool-calls";
113
+ } | ContentPartStatus;
114
+ type MessageStatus = {
115
+ type: "running";
116
+ } | {
117
+ type: "requires-action";
118
+ reason: "tool-calls";
119
+ } | {
120
+ type: "complete";
121
+ reason: "stop" | "unknown";
122
+ } | {
123
+ type: "incomplete";
124
+ reason: "cancelled" | "tool-calls" | "length" | "content-filter" | "other" | "error";
125
+ error?: unknown;
126
+ };
127
+ type ThreadSystemMessage = MessageCommonProps & {
128
+ role: "system";
129
+ content: [TextContentPart];
130
+ };
131
+ type ThreadUserMessage = MessageCommonProps & {
132
+ role: "user";
133
+ content: ThreadUserContentPart[];
134
+ };
135
+ type ThreadAssistantMessage = MessageCommonProps & {
136
+ role: "assistant";
137
+ content: ThreadAssistantContentPart[];
138
+ status: MessageStatus;
139
+ roundtrips?: ThreadRoundtrip[] | undefined;
140
+ };
141
+ type AppendMessage = CoreMessage & {
142
+ parentId: string | null;
143
+ };
144
+ type ThreadMessage = ThreadSystemMessage | ThreadUserMessage | ThreadAssistantMessage;
145
+ /** Core Message Types (without UI content parts) */
146
+ type CoreUserContentPart = TextContentPart | ImageContentPart;
147
+ type CoreAssistantContentPart = TextContentPart | CoreToolCallContentPart;
148
+ type CoreSystemMessage = {
149
+ role: "system";
150
+ content: [TextContentPart];
151
+ };
152
+ type CoreUserMessage = {
153
+ role: "user";
154
+ content: CoreUserContentPart[];
155
+ };
156
+ type CoreAssistantMessage = {
157
+ role: "assistant";
158
+ content: CoreAssistantContentPart[];
159
+ };
160
+ type CoreMessage = CoreSystemMessage | CoreUserMessage | CoreAssistantMessage;
161
+
162
+ declare const EdgeRuntimeRequestOptionsSchema: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<{
163
+ system: z.ZodOptional<z.ZodString>;
164
+ messages: z.ZodArray<z.ZodDiscriminatedUnion<"role", [z.ZodObject<{
165
+ role: z.ZodLiteral<"system">;
166
+ content: z.ZodTuple<[z.ZodObject<{
167
+ type: z.ZodLiteral<"text">;
168
+ text: z.ZodString;
169
+ }, "strip", z.ZodTypeAny, {
170
+ type: "text";
171
+ text: string;
172
+ }, {
173
+ type: "text";
174
+ text: string;
175
+ }>], null>;
176
+ }, "strip", z.ZodTypeAny, {
177
+ role: "system";
178
+ content: [{
179
+ type: "text";
180
+ text: string;
181
+ }];
182
+ }, {
183
+ role: "system";
184
+ content: [{
185
+ type: "text";
186
+ text: string;
187
+ }];
188
+ }>, z.ZodObject<{
189
+ role: z.ZodLiteral<"user">;
190
+ content: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
191
+ type: z.ZodLiteral<"text">;
192
+ text: z.ZodString;
193
+ }, "strip", z.ZodTypeAny, {
194
+ type: "text";
195
+ text: string;
196
+ }, {
197
+ type: "text";
198
+ text: string;
199
+ }>, z.ZodObject<{
200
+ type: z.ZodLiteral<"image">;
201
+ image: z.ZodString;
202
+ }, "strip", z.ZodTypeAny, {
203
+ type: "image";
204
+ image: string;
205
+ }, {
206
+ type: "image";
207
+ image: string;
208
+ }>]>, "many">;
209
+ }, "strip", z.ZodTypeAny, {
210
+ role: "user";
211
+ content: ({
212
+ type: "text";
213
+ text: string;
214
+ } | {
215
+ type: "image";
216
+ image: string;
217
+ })[];
218
+ }, {
219
+ role: "user";
220
+ content: ({
221
+ type: "text";
222
+ text: string;
223
+ } | {
224
+ type: "image";
225
+ image: string;
226
+ })[];
227
+ }>, z.ZodObject<{
228
+ role: z.ZodLiteral<"assistant">;
229
+ content: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
230
+ type: z.ZodLiteral<"text">;
231
+ text: z.ZodString;
232
+ }, "strip", z.ZodTypeAny, {
233
+ type: "text";
234
+ text: string;
235
+ }, {
236
+ type: "text";
237
+ text: string;
238
+ }>, z.ZodObject<{
239
+ type: z.ZodLiteral<"tool-call">;
240
+ toolCallId: z.ZodString;
241
+ toolName: z.ZodString;
242
+ args: z.ZodRecord<z.ZodString, z.ZodUnknown>;
243
+ result: z.ZodOptional<z.ZodUnknown>;
244
+ isError: z.ZodOptional<z.ZodBoolean>;
245
+ }, "strip", z.ZodTypeAny, {
246
+ type: "tool-call";
247
+ toolCallId: string;
248
+ toolName: string;
249
+ args: Record<string, unknown>;
250
+ result?: unknown;
251
+ isError?: boolean | undefined;
252
+ }, {
253
+ type: "tool-call";
254
+ toolCallId: string;
255
+ toolName: string;
256
+ args: Record<string, unknown>;
257
+ result?: unknown;
258
+ isError?: boolean | undefined;
259
+ }>]>, "many">;
260
+ }, "strip", z.ZodTypeAny, {
261
+ role: "assistant";
262
+ content: ({
263
+ type: "text";
264
+ text: string;
265
+ } | {
266
+ type: "tool-call";
267
+ toolCallId: string;
268
+ toolName: string;
269
+ args: Record<string, unknown>;
270
+ result?: unknown;
271
+ isError?: boolean | undefined;
272
+ })[];
273
+ }, {
274
+ role: "assistant";
275
+ content: ({
276
+ type: "text";
277
+ text: string;
278
+ } | {
279
+ type: "tool-call";
280
+ toolCallId: string;
281
+ toolName: string;
282
+ args: Record<string, unknown>;
283
+ result?: unknown;
284
+ isError?: boolean | undefined;
285
+ })[];
286
+ }>]>, "many">;
287
+ tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
288
+ type: z.ZodLiteral<"function">;
289
+ name: z.ZodString;
290
+ description: z.ZodOptional<z.ZodString>;
291
+ parameters: z.ZodType<JSONSchema7, z.ZodTypeDef, JSONSchema7>;
292
+ }, "strip", z.ZodTypeAny, {
293
+ type: "function";
294
+ name: string;
295
+ parameters: JSONSchema7;
296
+ description?: string | undefined;
297
+ }, {
298
+ type: "function";
299
+ name: string;
300
+ parameters: JSONSchema7;
301
+ description?: string | undefined;
302
+ }>, "many">>;
303
+ }, {
304
+ maxTokens: z.ZodOptional<z.ZodNumber>;
305
+ temperature: z.ZodOptional<z.ZodNumber>;
306
+ topP: z.ZodOptional<z.ZodNumber>;
307
+ presencePenalty: z.ZodOptional<z.ZodNumber>;
308
+ frequencyPenalty: z.ZodOptional<z.ZodNumber>;
309
+ seed: z.ZodOptional<z.ZodNumber>;
310
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodString>>>;
311
+ }>, {
312
+ apiKey: z.ZodOptional<z.ZodString>;
313
+ baseUrl: z.ZodOptional<z.ZodString>;
314
+ modelName: z.ZodOptional<z.ZodString>;
315
+ }>, "strip", z.ZodTypeAny, {
316
+ messages: ({
317
+ role: "user";
318
+ content: ({
319
+ type: "text";
320
+ text: string;
321
+ } | {
322
+ type: "image";
323
+ image: string;
324
+ })[];
325
+ } | {
326
+ role: "assistant";
327
+ content: ({
328
+ type: "text";
329
+ text: string;
330
+ } | {
331
+ type: "tool-call";
332
+ toolCallId: string;
333
+ toolName: string;
334
+ args: Record<string, unknown>;
335
+ result?: unknown;
336
+ isError?: boolean | undefined;
337
+ })[];
338
+ } | {
339
+ role: "system";
340
+ content: [{
341
+ type: "text";
342
+ text: string;
343
+ }];
344
+ })[];
345
+ maxTokens?: number | undefined;
346
+ temperature?: number | undefined;
347
+ topP?: number | undefined;
348
+ presencePenalty?: number | undefined;
349
+ frequencyPenalty?: number | undefined;
350
+ seed?: number | undefined;
351
+ headers?: Record<string, string | undefined> | undefined;
352
+ apiKey?: string | undefined;
353
+ baseUrl?: string | undefined;
354
+ modelName?: string | undefined;
355
+ system?: string | undefined;
356
+ tools?: {
357
+ type: "function";
358
+ name: string;
359
+ parameters: JSONSchema7;
360
+ description?: string | undefined;
361
+ }[] | undefined;
362
+ }, {
363
+ messages: ({
364
+ role: "user";
365
+ content: ({
366
+ type: "text";
367
+ text: string;
368
+ } | {
369
+ type: "image";
370
+ image: string;
371
+ })[];
372
+ } | {
373
+ role: "assistant";
374
+ content: ({
375
+ type: "text";
376
+ text: string;
377
+ } | {
378
+ type: "tool-call";
379
+ toolCallId: string;
380
+ toolName: string;
381
+ args: Record<string, unknown>;
382
+ result?: unknown;
383
+ isError?: boolean | undefined;
384
+ })[];
385
+ } | {
386
+ role: "system";
387
+ content: [{
388
+ type: "text";
389
+ text: string;
390
+ }];
391
+ })[];
392
+ maxTokens?: number | undefined;
393
+ temperature?: number | undefined;
394
+ topP?: number | undefined;
395
+ presencePenalty?: number | undefined;
396
+ frequencyPenalty?: number | undefined;
397
+ seed?: number | undefined;
398
+ headers?: Record<string, string | undefined> | undefined;
399
+ apiKey?: string | undefined;
400
+ baseUrl?: string | undefined;
401
+ modelName?: string | undefined;
402
+ system?: string | undefined;
403
+ tools?: {
404
+ type: "function";
405
+ name: string;
406
+ parameters: JSONSchema7;
407
+ description?: string | undefined;
408
+ }[] | undefined;
409
+ }>;
410
+ type EdgeRuntimeRequestOptions = z.infer<typeof EdgeRuntimeRequestOptionsSchema>;
411
+
412
+ export { type AppendMessage as A, type ContentPartStatus as C, type EdgeRuntimeRequestOptions as E, type ImageContentPart as I, type LanguageModelV1CallSettings as L, type MessageStatus as M, type ThreadAssistantContentPart as T, type UIContentPart as U, type ThreadRoundtrip as a, type ThreadMessage as b, type ModelConfig as c, type ModelConfigProvider as d, type TextContentPart as e, type ToolCallContentPart as f, type ToolCallContentPartStatus as g, type CoreMessage as h, type Tool as i, type CoreToolCallContentPart as j, type ThreadUserContentPart as k, type ThreadSystemMessage as l, type ThreadAssistantMessage as m, type ThreadUserMessage as n, type CoreUserContentPart as o, type CoreAssistantContentPart as p, type CoreSystemMessage as q, type CoreUserMessage as r, type CoreAssistantMessage as s, EdgeRuntimeRequestOptionsSchema as t, type LanguageModelConfig as u };