ai 5.1.0-beta.21 → 5.1.0-beta.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/index.d.mts +169 -49
- package/dist/index.d.ts +169 -49
- package/dist/index.js +749 -379
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +644 -278
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +33 -5
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +33 -5
- package/dist/internal/index.mjs.map +1 -1
- package/dist/test/index.d.mts +20 -20
- package/dist/test/index.d.ts +20 -20
- package/dist/test/index.js +10 -10
- package/dist/test/index.js.map +1 -1
- package/dist/test/index.mjs +8 -8
- package/dist/test/index.mjs.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 5.1.0-beta.23
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [1d8ea2c]
|
|
8
|
+
- @ai-sdk/gateway@1.1.0-beta.17
|
|
9
|
+
|
|
10
|
+
## 5.1.0-beta.22
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 046aa3b: feat(provider): speech model v3 spec
|
|
15
|
+
- e8109d3: feat: tool execution approval
|
|
16
|
+
- a5e152d: fix(ai): back version support for V2 providers
|
|
17
|
+
- 21e20c0: feat(provider): transcription model v3 spec
|
|
18
|
+
- Updated dependencies [046aa3b]
|
|
19
|
+
- Updated dependencies [e8109d3]
|
|
20
|
+
- @ai-sdk/provider@2.1.0-beta.5
|
|
21
|
+
- @ai-sdk/provider-utils@3.1.0-beta.7
|
|
22
|
+
- @ai-sdk/gateway@1.1.0-beta.16
|
|
23
|
+
|
|
3
24
|
## 5.1.0-beta.21
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { createGateway, gateway } from '@ai-sdk/gateway';
|
|
2
2
|
import { ModelMessage, Tool, InferToolInput, InferToolOutput, AssistantModelMessage, ToolModelMessage, ReasoningPart, Schema, SystemModelMessage, UserModelMessage, ProviderOptions, IdGenerator, ToolCall, InferSchema, FlexibleSchema, DataContent, Validator, StandardSchemaV1, Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
|
-
export { AssistantContent, AssistantModelMessage, DataContent, FilePart, IdGenerator, ImagePart, InferToolInput, InferToolOutput, ModelMessage, Schema, SystemModelMessage, TextPart, Tool, ToolCallOptions, ToolCallPart, ToolContent, ToolExecuteFunction, ToolModelMessage, ToolResultPart, UserContent, UserModelMessage, asSchema, createIdGenerator, dynamicTool, generateId, jsonSchema, parseJsonEventStream, tool, zodSchema } from '@ai-sdk/provider-utils';
|
|
3
|
+
export { AssistantContent, AssistantModelMessage, DataContent, FilePart, IdGenerator, ImagePart, InferToolInput, InferToolOutput, ModelMessage, Schema, SystemModelMessage, TextPart, Tool, ToolApprovalRequest, ToolApprovalResponse, ToolCallOptions, ToolCallPart, ToolContent, ToolExecuteFunction, ToolModelMessage, ToolResultPart, UserContent, UserModelMessage, asSchema, createIdGenerator, dynamicTool, generateId, jsonSchema, parseJsonEventStream, tool, zodSchema } from '@ai-sdk/provider-utils';
|
|
4
4
|
import { AttributeValue, Tracer } from '@opentelemetry/api';
|
|
5
5
|
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
6
|
-
import { EmbeddingModelV3, EmbeddingModelV2, EmbeddingModelV3Embedding, ImageModelV3, ImageModelV3CallWarning, ImageModelV3ProviderMetadata, JSONValue as JSONValue$1, LanguageModelV3, LanguageModelV2, LanguageModelV3FinishReason, LanguageModelV3CallWarning, LanguageModelV3Source, LanguageModelV3Middleware, SharedV3ProviderMetadata,
|
|
6
|
+
import { EmbeddingModelV3, EmbeddingModelV2, EmbeddingModelV3Embedding, ImageModelV3, ImageModelV3CallWarning, ImageModelV3ProviderMetadata, JSONValue as JSONValue$1, LanguageModelV3, LanguageModelV2, LanguageModelV3FinishReason, LanguageModelV3CallWarning, LanguageModelV3Source, LanguageModelV3Middleware, SharedV3ProviderMetadata, SpeechModelV3, SpeechModelV3CallWarning, TranscriptionModelV3, TranscriptionModelV3CallWarning, LanguageModelV3Usage, LanguageModelV3CallOptions, AISDKError, LanguageModelV3ToolCall, JSONSchema7, JSONParseError, TypeValidationError, ProviderV3, ProviderV2, NoSuchModelError, JSONObject } from '@ai-sdk/provider';
|
|
7
7
|
export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, NoContentGeneratedError, NoSuchModelError, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
|
|
8
8
|
import * as z3 from 'zod/v3';
|
|
9
9
|
import * as z4 from 'zod/v4';
|
|
@@ -309,12 +309,12 @@ type ProviderMetadata = SharedV3ProviderMetadata;
|
|
|
309
309
|
/**
|
|
310
310
|
Speech model that is used by the AI SDK Core functions.
|
|
311
311
|
*/
|
|
312
|
-
type SpeechModel =
|
|
312
|
+
type SpeechModel = SpeechModelV3;
|
|
313
313
|
/**
|
|
314
314
|
Warning from the model provider for this call. The call will proceed, but e.g.
|
|
315
315
|
some settings might not be supported, which can lead to suboptimal results.
|
|
316
316
|
*/
|
|
317
|
-
type SpeechWarning =
|
|
317
|
+
type SpeechWarning = SpeechModelV3CallWarning;
|
|
318
318
|
|
|
319
319
|
type SpeechModelResponseMetadata = {
|
|
320
320
|
/**
|
|
@@ -338,12 +338,12 @@ type SpeechModelResponseMetadata = {
|
|
|
338
338
|
/**
|
|
339
339
|
Transcription model that is used by the AI SDK Core functions.
|
|
340
340
|
*/
|
|
341
|
-
type TranscriptionModel =
|
|
341
|
+
type TranscriptionModel = TranscriptionModelV3;
|
|
342
342
|
/**
|
|
343
343
|
Warning from the model provider for this call. The call will proceed, but e.g.
|
|
344
344
|
some settings might not be supported, which can lead to suboptimal results.
|
|
345
345
|
*/
|
|
346
|
-
type TranscriptionWarning =
|
|
346
|
+
type TranscriptionWarning = TranscriptionModelV3CallWarning;
|
|
347
347
|
|
|
348
348
|
type TranscriptionModelResponseMetadata = {
|
|
349
349
|
/**
|
|
@@ -419,23 +419,6 @@ interface GeneratedFile {
|
|
|
419
419
|
readonly mediaType: string;
|
|
420
420
|
}
|
|
421
421
|
|
|
422
|
-
/**
|
|
423
|
-
* Reasoning output of a text generation. It contains a reasoning.
|
|
424
|
-
*/
|
|
425
|
-
interface ReasoningOutput {
|
|
426
|
-
type: 'reasoning';
|
|
427
|
-
/**
|
|
428
|
-
* The reasoning text.
|
|
429
|
-
*/
|
|
430
|
-
text: string;
|
|
431
|
-
/**
|
|
432
|
-
* Additional provider-specific metadata. They are passed through
|
|
433
|
-
* to the provider from the AI SDK and enable provider-specific
|
|
434
|
-
* functionality that can be fully encapsulated in the provider.
|
|
435
|
-
*/
|
|
436
|
-
providerMetadata?: ProviderMetadata;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
422
|
/**
|
|
440
423
|
Create a union of the given object's values, and optionally specify which keys to get the values from.
|
|
441
424
|
|
|
@@ -480,27 +463,25 @@ type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType>
|
|
|
480
463
|
|
|
481
464
|
type ToolSet = Record<string, (Tool<never, never> | Tool<any, any> | Tool<any, never> | Tool<never, any>) & Pick<Tool<any, any>, 'execute' | 'onInputAvailable' | 'onInputStart' | 'onInputDelta'>>;
|
|
482
465
|
|
|
466
|
+
type BaseToolCall = {
|
|
467
|
+
type: 'tool-call';
|
|
468
|
+
toolCallId: string;
|
|
469
|
+
providerExecuted?: boolean;
|
|
470
|
+
providerMetadata?: ProviderMetadata;
|
|
471
|
+
};
|
|
483
472
|
type StaticToolCall<TOOLS extends ToolSet> = ValueOf<{
|
|
484
|
-
[NAME in keyof TOOLS]: {
|
|
485
|
-
type: 'tool-call';
|
|
486
|
-
toolCallId: string;
|
|
473
|
+
[NAME in keyof TOOLS]: BaseToolCall & {
|
|
487
474
|
toolName: NAME & string;
|
|
488
475
|
input: TOOLS[NAME] extends Tool<infer PARAMETERS> ? PARAMETERS : never;
|
|
489
|
-
providerExecuted?: boolean;
|
|
490
476
|
dynamic?: false | undefined;
|
|
491
477
|
invalid?: false | undefined;
|
|
492
478
|
error?: never;
|
|
493
|
-
providerMetadata?: ProviderMetadata;
|
|
494
479
|
};
|
|
495
480
|
}>;
|
|
496
|
-
type DynamicToolCall = {
|
|
497
|
-
type: 'tool-call';
|
|
498
|
-
toolCallId: string;
|
|
481
|
+
type DynamicToolCall = BaseToolCall & {
|
|
499
482
|
toolName: string;
|
|
500
483
|
input: unknown;
|
|
501
|
-
providerExecuted?: boolean;
|
|
502
484
|
dynamic: true;
|
|
503
|
-
providerMetadata?: ProviderMetadata;
|
|
504
485
|
/**
|
|
505
486
|
* True if this is caused by an unparsable tool call or
|
|
506
487
|
* a tool that does not exist.
|
|
@@ -513,6 +494,40 @@ type DynamicToolCall = {
|
|
|
513
494
|
};
|
|
514
495
|
type TypedToolCall<TOOLS extends ToolSet> = StaticToolCall<TOOLS> | DynamicToolCall;
|
|
515
496
|
|
|
497
|
+
/**
|
|
498
|
+
* Output part that indicates that a tool approval request has been made.
|
|
499
|
+
*
|
|
500
|
+
* The tool approval request can be approved or denied in the next tool message.
|
|
501
|
+
*/
|
|
502
|
+
type ToolApprovalRequestOutput<TOOLS extends ToolSet> = {
|
|
503
|
+
type: 'tool-approval-request';
|
|
504
|
+
/**
|
|
505
|
+
* ID of the tool approval request.
|
|
506
|
+
*/
|
|
507
|
+
approvalId: string;
|
|
508
|
+
/**
|
|
509
|
+
* Tool call that the approval request is for.
|
|
510
|
+
*/
|
|
511
|
+
toolCall: TypedToolCall<TOOLS>;
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Reasoning output of a text generation. It contains a reasoning.
|
|
516
|
+
*/
|
|
517
|
+
interface ReasoningOutput {
|
|
518
|
+
type: 'reasoning';
|
|
519
|
+
/**
|
|
520
|
+
* The reasoning text.
|
|
521
|
+
*/
|
|
522
|
+
text: string;
|
|
523
|
+
/**
|
|
524
|
+
* Additional provider-specific metadata. They are passed through
|
|
525
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
526
|
+
* functionality that can be fully encapsulated in the provider.
|
|
527
|
+
*/
|
|
528
|
+
providerMetadata?: ProviderMetadata;
|
|
529
|
+
}
|
|
530
|
+
|
|
516
531
|
type StaticToolError<TOOLS extends ToolSet> = ValueOf<{
|
|
517
532
|
[NAME in keyof TOOLS]: {
|
|
518
533
|
type: 'tool-error';
|
|
@@ -581,7 +596,7 @@ type ContentPart<TOOLS extends ToolSet> = {
|
|
|
581
596
|
type: 'tool-error';
|
|
582
597
|
} & TypedToolError<TOOLS> & {
|
|
583
598
|
providerMetadata?: ProviderMetadata;
|
|
584
|
-
})
|
|
599
|
+
}) | ToolApprovalRequestOutput<TOOLS>;
|
|
585
600
|
|
|
586
601
|
/**
|
|
587
602
|
A message that was generated during the generation process.
|
|
@@ -1359,6 +1374,23 @@ Internal. For test use only. May change without notice.
|
|
|
1359
1374
|
};
|
|
1360
1375
|
}): StreamTextResult<TOOLS, PARTIAL_OUTPUT>;
|
|
1361
1376
|
|
|
1377
|
+
/**
|
|
1378
|
+
* Tool output when the tool execution has been denied (for static tools).
|
|
1379
|
+
*/
|
|
1380
|
+
type StaticToolOutputDenied<TOOLS extends ToolSet> = ValueOf<{
|
|
1381
|
+
[NAME in keyof TOOLS]: {
|
|
1382
|
+
type: 'tool-output-denied';
|
|
1383
|
+
toolCallId: string;
|
|
1384
|
+
toolName: NAME & string;
|
|
1385
|
+
providerExecuted?: boolean;
|
|
1386
|
+
dynamic?: false | undefined;
|
|
1387
|
+
};
|
|
1388
|
+
}>;
|
|
1389
|
+
/**
|
|
1390
|
+
* Tool output when the tool execution has been denied.
|
|
1391
|
+
*/
|
|
1392
|
+
type TypedToolOutputDenied<TOOLS extends ToolSet> = StaticToolOutputDenied<TOOLS>;
|
|
1393
|
+
|
|
1362
1394
|
/**
|
|
1363
1395
|
The data types that can be used in the UI message for the UI message data parts.
|
|
1364
1396
|
*/
|
|
@@ -1519,6 +1551,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
|
1519
1551
|
providerExecuted?: boolean;
|
|
1520
1552
|
output?: never;
|
|
1521
1553
|
errorText?: never;
|
|
1554
|
+
approval?: never;
|
|
1522
1555
|
} | {
|
|
1523
1556
|
state: 'input-available';
|
|
1524
1557
|
input: asUITool<TOOL>['input'];
|
|
@@ -1526,6 +1559,31 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
|
1526
1559
|
output?: never;
|
|
1527
1560
|
errorText?: never;
|
|
1528
1561
|
callProviderMetadata?: ProviderMetadata;
|
|
1562
|
+
approval?: never;
|
|
1563
|
+
} | {
|
|
1564
|
+
state: 'approval-requested';
|
|
1565
|
+
input: asUITool<TOOL>['input'];
|
|
1566
|
+
providerExecuted?: boolean;
|
|
1567
|
+
output?: never;
|
|
1568
|
+
errorText?: never;
|
|
1569
|
+
callProviderMetadata?: ProviderMetadata;
|
|
1570
|
+
approval: {
|
|
1571
|
+
id: string;
|
|
1572
|
+
approved?: never;
|
|
1573
|
+
reason?: never;
|
|
1574
|
+
};
|
|
1575
|
+
} | {
|
|
1576
|
+
state: 'approval-responded';
|
|
1577
|
+
input: asUITool<TOOL>['input'];
|
|
1578
|
+
providerExecuted?: boolean;
|
|
1579
|
+
output?: never;
|
|
1580
|
+
errorText?: never;
|
|
1581
|
+
callProviderMetadata?: ProviderMetadata;
|
|
1582
|
+
approval: {
|
|
1583
|
+
id: string;
|
|
1584
|
+
approved: boolean;
|
|
1585
|
+
reason?: string;
|
|
1586
|
+
};
|
|
1529
1587
|
} | {
|
|
1530
1588
|
state: 'output-available';
|
|
1531
1589
|
input: asUITool<TOOL>['input'];
|
|
@@ -1534,6 +1592,11 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
|
1534
1592
|
providerExecuted?: boolean;
|
|
1535
1593
|
callProviderMetadata?: ProviderMetadata;
|
|
1536
1594
|
preliminary?: boolean;
|
|
1595
|
+
approval?: {
|
|
1596
|
+
id: string;
|
|
1597
|
+
approved: true;
|
|
1598
|
+
reason?: string;
|
|
1599
|
+
};
|
|
1537
1600
|
} | {
|
|
1538
1601
|
state: 'output-error';
|
|
1539
1602
|
input: asUITool<TOOL>['input'] | undefined;
|
|
@@ -1542,6 +1605,23 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
|
1542
1605
|
errorText: string;
|
|
1543
1606
|
providerExecuted?: boolean;
|
|
1544
1607
|
callProviderMetadata?: ProviderMetadata;
|
|
1608
|
+
approval?: {
|
|
1609
|
+
id: string;
|
|
1610
|
+
approved: true;
|
|
1611
|
+
reason?: string;
|
|
1612
|
+
};
|
|
1613
|
+
} | {
|
|
1614
|
+
state: 'output-denied';
|
|
1615
|
+
input: asUITool<TOOL>['input'];
|
|
1616
|
+
providerExecuted?: boolean;
|
|
1617
|
+
output?: never;
|
|
1618
|
+
errorText?: never;
|
|
1619
|
+
callProviderMetadata?: ProviderMetadata;
|
|
1620
|
+
approval: {
|
|
1621
|
+
id: string;
|
|
1622
|
+
approved: false;
|
|
1623
|
+
reason?: string;
|
|
1624
|
+
};
|
|
1545
1625
|
});
|
|
1546
1626
|
type ToolUIPart<TOOLS extends UITools = UITools> = ValueOf<{
|
|
1547
1627
|
[NAME in keyof TOOLS & string]: {
|
|
@@ -1637,6 +1717,10 @@ declare const uiMessageChunkSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
1637
1717
|
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV3ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV3ProviderMetadata, unknown>>>;
|
|
1638
1718
|
dynamic: z.ZodOptional<z.ZodBoolean>;
|
|
1639
1719
|
errorText: z.ZodString;
|
|
1720
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1721
|
+
type: z.ZodLiteral<"tool-approval-request">;
|
|
1722
|
+
approvalId: z.ZodString;
|
|
1723
|
+
toolCallId: z.ZodString;
|
|
1640
1724
|
}, z.core.$strict>, z.ZodObject<{
|
|
1641
1725
|
type: z.ZodLiteral<"tool-output-available">;
|
|
1642
1726
|
toolCallId: z.ZodString;
|
|
@@ -1650,6 +1734,9 @@ declare const uiMessageChunkSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
1650
1734
|
errorText: z.ZodString;
|
|
1651
1735
|
providerExecuted: z.ZodOptional<z.ZodBoolean>;
|
|
1652
1736
|
dynamic: z.ZodOptional<z.ZodBoolean>;
|
|
1737
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1738
|
+
type: z.ZodLiteral<"tool-output-denied">;
|
|
1739
|
+
toolCallId: z.ZodString;
|
|
1653
1740
|
}, z.core.$strict>, z.ZodObject<{
|
|
1654
1741
|
type: z.ZodLiteral<"reasoning-start">;
|
|
1655
1742
|
id: z.ZodString;
|
|
@@ -1757,6 +1844,10 @@ type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataT
|
|
|
1757
1844
|
providerMetadata?: ProviderMetadata;
|
|
1758
1845
|
dynamic?: boolean;
|
|
1759
1846
|
errorText: string;
|
|
1847
|
+
} | {
|
|
1848
|
+
type: 'tool-approval-request';
|
|
1849
|
+
approvalId: string;
|
|
1850
|
+
toolCallId: string;
|
|
1760
1851
|
} | {
|
|
1761
1852
|
type: 'tool-output-available';
|
|
1762
1853
|
toolCallId: string;
|
|
@@ -1770,6 +1861,9 @@ type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataT
|
|
|
1770
1861
|
errorText: string;
|
|
1771
1862
|
providerExecuted?: boolean;
|
|
1772
1863
|
dynamic?: boolean;
|
|
1864
|
+
} | {
|
|
1865
|
+
type: 'tool-output-denied';
|
|
1866
|
+
toolCallId: string;
|
|
1773
1867
|
} | {
|
|
1774
1868
|
type: 'tool-input-start';
|
|
1775
1869
|
toolCallId: string;
|
|
@@ -2157,7 +2251,9 @@ type TextStreamPart<TOOLS extends ToolSet> = {
|
|
|
2157
2251
|
type: 'tool-result';
|
|
2158
2252
|
} & TypedToolResult<TOOLS>) | ({
|
|
2159
2253
|
type: 'tool-error';
|
|
2160
|
-
} & TypedToolError<TOOLS>) | {
|
|
2254
|
+
} & TypedToolError<TOOLS>) | ({
|
|
2255
|
+
type: 'tool-output-denied';
|
|
2256
|
+
} & StaticToolOutputDenied<TOOLS>) | ToolApprovalRequestOutput<TOOLS> | {
|
|
2161
2257
|
type: 'start-step';
|
|
2162
2258
|
request: LanguageModelRequestMetadata;
|
|
2163
2259
|
warnings: CallWarning[];
|
|
@@ -2528,7 +2624,7 @@ type SingleRequestTextStreamPart<TOOLS extends ToolSet> = {
|
|
|
2528
2624
|
type: 'tool-input-end';
|
|
2529
2625
|
id: string;
|
|
2530
2626
|
providerMetadata?: ProviderMetadata;
|
|
2531
|
-
} | ({
|
|
2627
|
+
} | ToolApprovalRequestOutput<TOOLS> | ({
|
|
2532
2628
|
type: 'source';
|
|
2533
2629
|
} & Source) | {
|
|
2534
2630
|
type: 'file';
|
|
@@ -3491,7 +3587,7 @@ declare function generateSpeech({ model, text, voice, outputFormat, instructions
|
|
|
3491
3587
|
/**
|
|
3492
3588
|
The speech model to use.
|
|
3493
3589
|
*/
|
|
3494
|
-
model:
|
|
3590
|
+
model: SpeechModelV3;
|
|
3495
3591
|
/**
|
|
3496
3592
|
The text to convert to speech.
|
|
3497
3593
|
*/
|
|
@@ -3547,7 +3643,7 @@ declare function generateSpeech({ model, text, voice, outputFormat, instructions
|
|
|
3547
3643
|
headers?: Record<string, string>;
|
|
3548
3644
|
}): Promise<SpeechResult>;
|
|
3549
3645
|
|
|
3550
|
-
type Warning = LanguageModelV3CallWarning | ImageModelV3CallWarning |
|
|
3646
|
+
type Warning = LanguageModelV3CallWarning | ImageModelV3CallWarning | SpeechModelV3CallWarning | TranscriptionModelV3CallWarning;
|
|
3551
3647
|
type LogWarningsFunction = (warnings: Warning[]) => void;
|
|
3552
3648
|
|
|
3553
3649
|
/**
|
|
@@ -3621,7 +3717,7 @@ declare const wrapLanguageModel: ({ model, middleware: middlewareArg, modelId, p
|
|
|
3621
3717
|
* @returns A new ProviderV3 instance with middleware applied to all language models.
|
|
3622
3718
|
*/
|
|
3623
3719
|
declare function wrapProvider({ provider, languageModelMiddleware, }: {
|
|
3624
|
-
provider: ProviderV3;
|
|
3720
|
+
provider: ProviderV3 | ProviderV2;
|
|
3625
3721
|
languageModelMiddleware: LanguageModelMiddleware | LanguageModelMiddleware[];
|
|
3626
3722
|
}): ProviderV3;
|
|
3627
3723
|
|
|
@@ -3639,19 +3735,19 @@ declare function wrapProvider({ provider, languageModelMiddleware, }: {
|
|
|
3639
3735
|
*
|
|
3640
3736
|
* @throws {NoSuchModelError} Throws when a requested model is not found and no fallback provider is available.
|
|
3641
3737
|
*/
|
|
3642
|
-
declare function customProvider<LANGUAGE_MODELS extends Record<string, LanguageModelV3>, EMBEDDING_MODELS extends Record<string, EmbeddingModelV3<string>>, IMAGE_MODELS extends Record<string, ImageModelV3>, TRANSCRIPTION_MODELS extends Record<string,
|
|
3738
|
+
declare function customProvider<LANGUAGE_MODELS extends Record<string, LanguageModelV3>, EMBEDDING_MODELS extends Record<string, EmbeddingModelV3<string>>, IMAGE_MODELS extends Record<string, ImageModelV3>, TRANSCRIPTION_MODELS extends Record<string, TranscriptionModelV3>, SPEECH_MODELS extends Record<string, SpeechModelV3>>({ languageModels, textEmbeddingModels, imageModels, transcriptionModels, speechModels, fallbackProvider, }: {
|
|
3643
3739
|
languageModels?: LANGUAGE_MODELS;
|
|
3644
3740
|
textEmbeddingModels?: EMBEDDING_MODELS;
|
|
3645
3741
|
imageModels?: IMAGE_MODELS;
|
|
3646
3742
|
transcriptionModels?: TRANSCRIPTION_MODELS;
|
|
3647
3743
|
speechModels?: SPEECH_MODELS;
|
|
3648
|
-
fallbackProvider?: ProviderV3;
|
|
3744
|
+
fallbackProvider?: ProviderV3 | ProviderV2;
|
|
3649
3745
|
}): ProviderV3 & {
|
|
3650
3746
|
languageModel(modelId: ExtractModelId<LANGUAGE_MODELS>): LanguageModelV3;
|
|
3651
3747
|
textEmbeddingModel(modelId: ExtractModelId<EMBEDDING_MODELS>): EmbeddingModelV3<string>;
|
|
3652
3748
|
imageModel(modelId: ExtractModelId<IMAGE_MODELS>): ImageModelV3;
|
|
3653
|
-
transcriptionModel(modelId: ExtractModelId<TRANSCRIPTION_MODELS>):
|
|
3654
|
-
speechModel(modelId: ExtractModelId<SPEECH_MODELS>):
|
|
3749
|
+
transcriptionModel(modelId: ExtractModelId<TRANSCRIPTION_MODELS>): TranscriptionModelV3;
|
|
3750
|
+
speechModel(modelId: ExtractModelId<SPEECH_MODELS>): SpeechModelV3;
|
|
3655
3751
|
};
|
|
3656
3752
|
/**
|
|
3657
3753
|
* @deprecated Use `customProvider` instead.
|
|
@@ -3682,10 +3778,10 @@ interface ProviderRegistryProvider<PROVIDERS extends Record<string, ProviderV3>
|
|
|
3682
3778
|
textEmbeddingModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${string}` : never): EmbeddingModelV3<string>;
|
|
3683
3779
|
imageModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${ExtractLiteralUnion<Parameters<NonNullable<PROVIDERS[KEY]['imageModel']>>[0]>}` : never): ImageModelV3;
|
|
3684
3780
|
imageModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${string}` : never): ImageModelV3;
|
|
3685
|
-
transcriptionModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${ExtractLiteralUnion<Parameters<NonNullable<PROVIDERS[KEY]['transcriptionModel']>>[0]>}` : never):
|
|
3686
|
-
transcriptionModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${string}` : never):
|
|
3687
|
-
speechModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${ExtractLiteralUnion<Parameters<NonNullable<PROVIDERS[KEY]['speechModel']>>[0]>}` : never):
|
|
3688
|
-
speechModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${string}` : never):
|
|
3781
|
+
transcriptionModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${ExtractLiteralUnion<Parameters<NonNullable<PROVIDERS[KEY]['transcriptionModel']>>[0]>}` : never): TranscriptionModelV3;
|
|
3782
|
+
transcriptionModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${string}` : never): TranscriptionModelV3;
|
|
3783
|
+
speechModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${ExtractLiteralUnion<Parameters<NonNullable<PROVIDERS[KEY]['speechModel']>>[0]>}` : never): SpeechModelV3;
|
|
3784
|
+
speechModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${string}` : never): SpeechModelV3;
|
|
3689
3785
|
}
|
|
3690
3786
|
/**
|
|
3691
3787
|
* Creates a registry for the given providers with optional middleware functionality.
|
|
@@ -3949,7 +4045,7 @@ declare function transcribe({ model, audio, providerOptions, maxRetries: maxRetr
|
|
|
3949
4045
|
/**
|
|
3950
4046
|
The transcription model to use.
|
|
3951
4047
|
*/
|
|
3952
|
-
model:
|
|
4048
|
+
model: TranscriptionModelV3;
|
|
3953
4049
|
/**
|
|
3954
4050
|
The audio data to transcribe.
|
|
3955
4051
|
*/
|
|
@@ -4170,6 +4266,20 @@ type ChatRequestOptions = {
|
|
|
4170
4266
|
body?: object;
|
|
4171
4267
|
metadata?: unknown;
|
|
4172
4268
|
};
|
|
4269
|
+
/**
|
|
4270
|
+
* Function that can be called to add a tool approval response to the chat.
|
|
4271
|
+
*/
|
|
4272
|
+
type ChatAddToolApproveResponseFunction = ({ id, approved, reason, }: {
|
|
4273
|
+
id: string;
|
|
4274
|
+
/**
|
|
4275
|
+
* Flag indicating whether the approval was granted or denied.
|
|
4276
|
+
*/
|
|
4277
|
+
approved: boolean;
|
|
4278
|
+
/**
|
|
4279
|
+
* Optional reason for the approval or denial.
|
|
4280
|
+
*/
|
|
4281
|
+
reason?: string;
|
|
4282
|
+
}) => void | PromiseLike<void>;
|
|
4173
4283
|
type ChatStatus = 'submitted' | 'streaming' | 'ready' | 'error';
|
|
4174
4284
|
interface ChatState<UI_MESSAGE extends UIMessage> {
|
|
4175
4285
|
status: ChatStatus;
|
|
@@ -4318,6 +4428,7 @@ declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
4318
4428
|
* Clear the error state and set the status to ready if the chat is in an error state.
|
|
4319
4429
|
*/
|
|
4320
4430
|
clearError: () => void;
|
|
4431
|
+
addToolApprovalResponse: ChatAddToolApproveResponseFunction;
|
|
4321
4432
|
addToolResult: <TOOL extends keyof InferUIMessageTools<UI_MESSAGE>>({ state, tool, toolCallId, output, errorText, }: {
|
|
4322
4433
|
state?: "output-available";
|
|
4323
4434
|
tool: TOOL;
|
|
@@ -4474,6 +4585,15 @@ declare class DefaultChatTransport<UI_MESSAGE extends UIMessage> extends HttpCha
|
|
|
4474
4585
|
protected processResponseStream(stream: ReadableStream<Uint8Array<ArrayBufferLike>>): ReadableStream<UIMessageChunk>;
|
|
4475
4586
|
}
|
|
4476
4587
|
|
|
4588
|
+
/**
|
|
4589
|
+
Check if the last message is an assistant message with completed tool call approvals.
|
|
4590
|
+
The last step of the message must have at least one tool approval response and
|
|
4591
|
+
all tool approvals must have a response.
|
|
4592
|
+
*/
|
|
4593
|
+
declare function lastAssistantMessageIsCompleteWithApprovalResponses({ messages, }: {
|
|
4594
|
+
messages: UIMessage[];
|
|
4595
|
+
}): boolean;
|
|
4596
|
+
|
|
4477
4597
|
/**
|
|
4478
4598
|
Check if the message is an assistant message with completed tool calls.
|
|
4479
4599
|
The last step of the message must have at least one tool invocation and
|
|
@@ -4620,4 +4740,4 @@ declare global {
|
|
|
4620
4740
|
var AI_SDK_LOG_WARNINGS: LogWarningsFunction | undefined | false;
|
|
4621
4741
|
}
|
|
4622
4742
|
|
|
4623
|
-
export { AbstractChat, Agent, AgentSettings, AsyncIterableStream, CallSettings, CallWarning, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, ErrorHandler, Agent as Experimental_Agent, AgentSettings as Experimental_AgentSettings, DownloadFunction as Experimental_DownloadFunction, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, Warning as Experimental_Warning, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferAgentUIMessage, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoOutputSpecifiedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RetryError, SafeValidateUIMessagesResult, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StaticToolCall, StaticToolError, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, TypedToolCall, TypedToolError, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultSettingsMiddleware, embed, embedMany, MCPClient as experimental_MCPClient, MCPClientConfig as experimental_MCPClientConfig, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDeepEqualData, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, readUIMessageStream, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapLanguageModel, wrapProvider };
|
|
4743
|
+
export { AbstractChat, Agent, AgentSettings, AsyncIterableStream, CallSettings, CallWarning, ChatAddToolApproveResponseFunction, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, ErrorHandler, Agent as Experimental_Agent, AgentSettings as Experimental_AgentSettings, DownloadFunction as Experimental_DownloadFunction, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, Warning as Experimental_Warning, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferAgentUIMessage, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoOutputSpecifiedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RetryError, SafeValidateUIMessagesResult, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StaticToolCall, StaticToolError, StaticToolOutputDenied, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolApprovalRequestOutput, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultSettingsMiddleware, embed, embedMany, MCPClient as experimental_MCPClient, MCPClientConfig as experimental_MCPClientConfig, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDeepEqualData, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithApprovalResponses, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, readUIMessageStream, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapLanguageModel, wrapProvider };
|