@ai-sdk/provider-utils 5.0.0-beta.3 → 5.0.0-beta.5
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 +86 -0
- package/dist/index.d.mts +29 -15
- package/dist/index.d.ts +29 -15
- package/dist/index.js +8 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/convert-image-model-file-to-data-uri.ts +3 -3
- package/src/create-tool-name-mapping.ts +5 -21
- package/src/inject-json-instruction.ts +5 -5
- package/src/types/assistant-model-message.ts +2 -0
- package/src/types/content-part.ts +20 -0
- package/src/types/index.ts +1 -0
- package/src/types/provider-options.ts +2 -2
- package/src/types/tool.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,91 @@
|
|
|
1
1
|
# @ai-sdk/provider-utils
|
|
2
2
|
|
|
3
|
+
## 5.0.0-beta.5
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 776b617: feat(provider): adding new 'custom' content type
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [776b617]
|
|
12
|
+
- @ai-sdk/provider@4.0.0-beta.3
|
|
13
|
+
|
|
14
|
+
## 5.0.0-beta.4
|
|
15
|
+
|
|
16
|
+
### Major Changes
|
|
17
|
+
|
|
18
|
+
- 61753c3: ### `@ai-sdk/openai`: remove redundant `name` argument from `openai.tools.customTool()`
|
|
19
|
+
|
|
20
|
+
`openai.tools.customTool()` no longer accepts a `name` field. the tool name is now derived from the sdk tool key (the object key in the `tools` object).
|
|
21
|
+
|
|
22
|
+
migration: remove the `name` property from `customTool()` calls. the object key is now used as the tool name sent to the openai api.
|
|
23
|
+
|
|
24
|
+
before:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
tools: {
|
|
28
|
+
write_sql: openai.tools.customTool({
|
|
29
|
+
name: 'write_sql',
|
|
30
|
+
description: '...',
|
|
31
|
+
}),
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
after:
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
tools: {
|
|
39
|
+
write_sql: openai.tools.customTool({
|
|
40
|
+
description: '...',
|
|
41
|
+
}),
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### `@ai-sdk/provider-utils`: `createToolNameMapping()` no longer accepts the `resolveProviderToolName` parameter
|
|
46
|
+
|
|
47
|
+
before: tool name can be set dynamically
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
const toolNameMapping = createToolNameMapping({
|
|
51
|
+
tools,
|
|
52
|
+
providerToolNames: {
|
|
53
|
+
'openai.code_interpreter': 'code_interpreter',
|
|
54
|
+
'openai.file_search': 'file_search',
|
|
55
|
+
'openai.image_generation': 'image_generation',
|
|
56
|
+
'openai.local_shell': 'local_shell',
|
|
57
|
+
'openai.shell': 'shell',
|
|
58
|
+
'openai.web_search': 'web_search',
|
|
59
|
+
'openai.web_search_preview': 'web_search_preview',
|
|
60
|
+
'openai.mcp': 'mcp',
|
|
61
|
+
'openai.apply_patch': 'apply_patch',
|
|
62
|
+
},
|
|
63
|
+
resolveProviderToolName: tool =>
|
|
64
|
+
tool.id === 'openai.custom'
|
|
65
|
+
? (tool.args as { name?: string }).name
|
|
66
|
+
: undefined,
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
after: tool name is static based on `tools` keys
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
const toolNameMapping = createToolNameMapping({
|
|
74
|
+
tools,
|
|
75
|
+
providerToolNames: {
|
|
76
|
+
'openai.code_interpreter': 'code_interpreter',
|
|
77
|
+
'openai.file_search': 'file_search',
|
|
78
|
+
'openai.image_generation': 'image_generation',
|
|
79
|
+
'openai.local_shell': 'local_shell',
|
|
80
|
+
'openai.shell': 'shell',
|
|
81
|
+
'openai.web_search': 'web_search',
|
|
82
|
+
'openai.web_search_preview': 'web_search_preview',
|
|
83
|
+
'openai.mcp': 'mcp',
|
|
84
|
+
'openai.apply_patch': 'apply_patch',
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
3
89
|
## 5.0.0-beta.3
|
|
4
90
|
|
|
5
91
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LanguageModelV4FunctionTool, LanguageModelV4ProviderTool, ImageModelV4File, AISDKError, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV4Prompt, SharedV4ProviderOptions, TypeValidationContext } from '@ai-sdk/provider';
|
|
2
2
|
import { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';
|
|
3
3
|
export * from '@standard-schema/spec';
|
|
4
4
|
import * as z3 from 'zod/v3';
|
|
@@ -41,20 +41,15 @@ interface ToolNameMapping {
|
|
|
41
41
|
* @param tools - Tools that were passed to the language model.
|
|
42
42
|
* @param providerToolNames - Maps the provider tool ids to the provider tool names.
|
|
43
43
|
*/
|
|
44
|
-
declare function createToolNameMapping({ tools, providerToolNames,
|
|
44
|
+
declare function createToolNameMapping({ tools, providerToolNames, }: {
|
|
45
45
|
/**
|
|
46
46
|
* Tools that were passed to the language model.
|
|
47
47
|
*/
|
|
48
|
-
tools: Array<
|
|
48
|
+
tools: Array<LanguageModelV4FunctionTool | LanguageModelV4ProviderTool> | undefined;
|
|
49
49
|
/**
|
|
50
50
|
* Maps the provider tool ids to the provider tool names.
|
|
51
51
|
*/
|
|
52
52
|
providerToolNames: Record<`${string}.${string}`, string>;
|
|
53
|
-
/**
|
|
54
|
-
* Optional resolver for provider tool names that cannot be represented as
|
|
55
|
-
* static id -> name mappings (e.g. dynamic provider names).
|
|
56
|
-
*/
|
|
57
|
-
resolveProviderToolName?: (tool: LanguageModelV3ProviderTool) => string | undefined;
|
|
58
53
|
}): ToolNameMapping;
|
|
59
54
|
|
|
60
55
|
/**
|
|
@@ -97,13 +92,13 @@ declare function extractResponseHeaders(response: Response): {
|
|
|
97
92
|
};
|
|
98
93
|
|
|
99
94
|
/**
|
|
100
|
-
* Convert an
|
|
95
|
+
* Convert an ImageModelV4File to a URL or data URI string.
|
|
101
96
|
*
|
|
102
97
|
* If the file is a URL, it returns the URL as-is.
|
|
103
98
|
* If the file is base64 data, it returns a data URI with the base64 data.
|
|
104
99
|
* If the file is a Uint8Array, it converts it to base64 and returns a data URI.
|
|
105
100
|
*/
|
|
106
|
-
declare function convertImageModelFileToDataUri(file:
|
|
101
|
+
declare function convertImageModelFileToDataUri(file: ImageModelV4File): string;
|
|
107
102
|
|
|
108
103
|
/**
|
|
109
104
|
* Converts an input object to FormData for multipart/form-data requests.
|
|
@@ -390,11 +385,11 @@ declare const getFromApi: <T>({ url, headers, successfulResponseHandler, failedR
|
|
|
390
385
|
declare function getRuntimeEnvironmentUserAgent(globalThisAny?: any): string;
|
|
391
386
|
|
|
392
387
|
declare function injectJsonInstructionIntoMessages({ messages, schema, schemaPrefix, schemaSuffix, }: {
|
|
393
|
-
messages:
|
|
388
|
+
messages: LanguageModelV4Prompt;
|
|
394
389
|
schema?: JSONSchema7;
|
|
395
390
|
schemaPrefix?: string;
|
|
396
391
|
schemaSuffix?: string;
|
|
397
|
-
}):
|
|
392
|
+
}): LanguageModelV4Prompt;
|
|
398
393
|
|
|
399
394
|
declare function isAbortError(error: unknown): error is Error;
|
|
400
395
|
|
|
@@ -549,7 +544,7 @@ type DataContent = string | Uint8Array | ArrayBuffer | Buffer;
|
|
|
549
544
|
* They are passed through to the provider from the AI SDK and enable
|
|
550
545
|
* provider-specific functionality that can be fully encapsulated in the provider.
|
|
551
546
|
*/
|
|
552
|
-
type ProviderOptions =
|
|
547
|
+
type ProviderOptions = SharedV4ProviderOptions;
|
|
553
548
|
|
|
554
549
|
/**
|
|
555
550
|
* Text content part of a prompt. It contains a string of text.
|
|
@@ -637,6 +632,23 @@ interface ReasoningPart {
|
|
|
637
632
|
*/
|
|
638
633
|
providerOptions?: ProviderOptions;
|
|
639
634
|
}
|
|
635
|
+
/**
|
|
636
|
+
* Custom content part of a prompt. It contains no standardized payload beyond
|
|
637
|
+
* provider-specific options.
|
|
638
|
+
*/
|
|
639
|
+
interface CustomPart {
|
|
640
|
+
type: 'custom';
|
|
641
|
+
/**
|
|
642
|
+
* The kind of custom content, in the format `{provider}-{provider-type}`.
|
|
643
|
+
*/
|
|
644
|
+
kind: string;
|
|
645
|
+
/**
|
|
646
|
+
* Additional provider-specific metadata. They are passed through
|
|
647
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
648
|
+
* functionality that can be fully encapsulated in the provider.
|
|
649
|
+
*/
|
|
650
|
+
providerOptions?: ProviderOptions;
|
|
651
|
+
}
|
|
640
652
|
/**
|
|
641
653
|
* Reasoning file content part of a prompt. It contains a file generated as part of reasoning.
|
|
642
654
|
*/
|
|
@@ -918,7 +930,7 @@ type AssistantModelMessage = {
|
|
|
918
930
|
* Content of an assistant message.
|
|
919
931
|
* It can be a string or an array of text, image, reasoning, redacted reasoning, and tool call parts.
|
|
920
932
|
*/
|
|
921
|
-
type AssistantContent = string | Array<TextPart | FilePart | ReasoningPart | ReasoningFilePart | ToolCallPart | ToolResultPart | ToolApprovalRequest>;
|
|
933
|
+
type AssistantContent = string | Array<TextPart | CustomPart | FilePart | ReasoningPart | ReasoningFilePart | ToolCallPart | ToolResultPart | ToolApprovalRequest>;
|
|
922
934
|
|
|
923
935
|
/**
|
|
924
936
|
* A system message. It can contain system information.
|
|
@@ -1145,6 +1157,8 @@ type Tool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONVa
|
|
|
1145
1157
|
* Optional conversion function that maps the tool result to an output that can be used by the language model.
|
|
1146
1158
|
*
|
|
1147
1159
|
* If not provided, the tool result will be sent as a JSON object.
|
|
1160
|
+
*
|
|
1161
|
+
* This function is invoked on the server by `convertToModelMessages`, so ensure that you pass the same "tools" (ToolSet) to both "convertToModelMessages" and "streamText" (or other generation APIs).
|
|
1148
1162
|
*/
|
|
1149
1163
|
toModelOutput?: (options: {
|
|
1150
1164
|
/**
|
|
@@ -1455,4 +1469,4 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
|
|
|
1455
1469
|
*/
|
|
1456
1470
|
type ToolCallOptions = ToolExecutionOptions;
|
|
1457
1471
|
|
|
1458
|
-
export { type AssistantContent, type AssistantModelMessage, DEFAULT_MAX_DOWNLOAD_SIZE, type DataContent, DelayedPromise, DownloadError, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderOptions, type ProviderToolFactory, type ProviderToolFactoryWithOutputSchema, type ReasoningFilePart, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolExecutionOptions, type ToolModelMessage, type ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertImageModelFileToDataUri, convertToBase64, convertToFormData, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderToolFactory, createProviderToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, downloadBlob, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isNonNullable, isParsableJson, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, readResponseWithSizeLimit, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, stripFileExtension, tool, validateDownloadUrl, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
|
1472
|
+
export { type AssistantContent, type AssistantModelMessage, type CustomPart, DEFAULT_MAX_DOWNLOAD_SIZE, type DataContent, DelayedPromise, DownloadError, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderOptions, type ProviderToolFactory, type ProviderToolFactoryWithOutputSchema, type ReasoningFilePart, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolExecutionOptions, type ToolModelMessage, type ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertImageModelFileToDataUri, convertToBase64, convertToFormData, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderToolFactory, createProviderToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, downloadBlob, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isNonNullable, isParsableJson, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, readResponseWithSizeLimit, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, stripFileExtension, tool, validateDownloadUrl, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LanguageModelV4FunctionTool, LanguageModelV4ProviderTool, ImageModelV4File, AISDKError, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV4Prompt, SharedV4ProviderOptions, TypeValidationContext } from '@ai-sdk/provider';
|
|
2
2
|
import { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';
|
|
3
3
|
export * from '@standard-schema/spec';
|
|
4
4
|
import * as z3 from 'zod/v3';
|
|
@@ -41,20 +41,15 @@ interface ToolNameMapping {
|
|
|
41
41
|
* @param tools - Tools that were passed to the language model.
|
|
42
42
|
* @param providerToolNames - Maps the provider tool ids to the provider tool names.
|
|
43
43
|
*/
|
|
44
|
-
declare function createToolNameMapping({ tools, providerToolNames,
|
|
44
|
+
declare function createToolNameMapping({ tools, providerToolNames, }: {
|
|
45
45
|
/**
|
|
46
46
|
* Tools that were passed to the language model.
|
|
47
47
|
*/
|
|
48
|
-
tools: Array<
|
|
48
|
+
tools: Array<LanguageModelV4FunctionTool | LanguageModelV4ProviderTool> | undefined;
|
|
49
49
|
/**
|
|
50
50
|
* Maps the provider tool ids to the provider tool names.
|
|
51
51
|
*/
|
|
52
52
|
providerToolNames: Record<`${string}.${string}`, string>;
|
|
53
|
-
/**
|
|
54
|
-
* Optional resolver for provider tool names that cannot be represented as
|
|
55
|
-
* static id -> name mappings (e.g. dynamic provider names).
|
|
56
|
-
*/
|
|
57
|
-
resolveProviderToolName?: (tool: LanguageModelV3ProviderTool) => string | undefined;
|
|
58
53
|
}): ToolNameMapping;
|
|
59
54
|
|
|
60
55
|
/**
|
|
@@ -97,13 +92,13 @@ declare function extractResponseHeaders(response: Response): {
|
|
|
97
92
|
};
|
|
98
93
|
|
|
99
94
|
/**
|
|
100
|
-
* Convert an
|
|
95
|
+
* Convert an ImageModelV4File to a URL or data URI string.
|
|
101
96
|
*
|
|
102
97
|
* If the file is a URL, it returns the URL as-is.
|
|
103
98
|
* If the file is base64 data, it returns a data URI with the base64 data.
|
|
104
99
|
* If the file is a Uint8Array, it converts it to base64 and returns a data URI.
|
|
105
100
|
*/
|
|
106
|
-
declare function convertImageModelFileToDataUri(file:
|
|
101
|
+
declare function convertImageModelFileToDataUri(file: ImageModelV4File): string;
|
|
107
102
|
|
|
108
103
|
/**
|
|
109
104
|
* Converts an input object to FormData for multipart/form-data requests.
|
|
@@ -390,11 +385,11 @@ declare const getFromApi: <T>({ url, headers, successfulResponseHandler, failedR
|
|
|
390
385
|
declare function getRuntimeEnvironmentUserAgent(globalThisAny?: any): string;
|
|
391
386
|
|
|
392
387
|
declare function injectJsonInstructionIntoMessages({ messages, schema, schemaPrefix, schemaSuffix, }: {
|
|
393
|
-
messages:
|
|
388
|
+
messages: LanguageModelV4Prompt;
|
|
394
389
|
schema?: JSONSchema7;
|
|
395
390
|
schemaPrefix?: string;
|
|
396
391
|
schemaSuffix?: string;
|
|
397
|
-
}):
|
|
392
|
+
}): LanguageModelV4Prompt;
|
|
398
393
|
|
|
399
394
|
declare function isAbortError(error: unknown): error is Error;
|
|
400
395
|
|
|
@@ -549,7 +544,7 @@ type DataContent = string | Uint8Array | ArrayBuffer | Buffer;
|
|
|
549
544
|
* They are passed through to the provider from the AI SDK and enable
|
|
550
545
|
* provider-specific functionality that can be fully encapsulated in the provider.
|
|
551
546
|
*/
|
|
552
|
-
type ProviderOptions =
|
|
547
|
+
type ProviderOptions = SharedV4ProviderOptions;
|
|
553
548
|
|
|
554
549
|
/**
|
|
555
550
|
* Text content part of a prompt. It contains a string of text.
|
|
@@ -637,6 +632,23 @@ interface ReasoningPart {
|
|
|
637
632
|
*/
|
|
638
633
|
providerOptions?: ProviderOptions;
|
|
639
634
|
}
|
|
635
|
+
/**
|
|
636
|
+
* Custom content part of a prompt. It contains no standardized payload beyond
|
|
637
|
+
* provider-specific options.
|
|
638
|
+
*/
|
|
639
|
+
interface CustomPart {
|
|
640
|
+
type: 'custom';
|
|
641
|
+
/**
|
|
642
|
+
* The kind of custom content, in the format `{provider}-{provider-type}`.
|
|
643
|
+
*/
|
|
644
|
+
kind: string;
|
|
645
|
+
/**
|
|
646
|
+
* Additional provider-specific metadata. They are passed through
|
|
647
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
648
|
+
* functionality that can be fully encapsulated in the provider.
|
|
649
|
+
*/
|
|
650
|
+
providerOptions?: ProviderOptions;
|
|
651
|
+
}
|
|
640
652
|
/**
|
|
641
653
|
* Reasoning file content part of a prompt. It contains a file generated as part of reasoning.
|
|
642
654
|
*/
|
|
@@ -918,7 +930,7 @@ type AssistantModelMessage = {
|
|
|
918
930
|
* Content of an assistant message.
|
|
919
931
|
* It can be a string or an array of text, image, reasoning, redacted reasoning, and tool call parts.
|
|
920
932
|
*/
|
|
921
|
-
type AssistantContent = string | Array<TextPart | FilePart | ReasoningPart | ReasoningFilePart | ToolCallPart | ToolResultPart | ToolApprovalRequest>;
|
|
933
|
+
type AssistantContent = string | Array<TextPart | CustomPart | FilePart | ReasoningPart | ReasoningFilePart | ToolCallPart | ToolResultPart | ToolApprovalRequest>;
|
|
922
934
|
|
|
923
935
|
/**
|
|
924
936
|
* A system message. It can contain system information.
|
|
@@ -1145,6 +1157,8 @@ type Tool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONVa
|
|
|
1145
1157
|
* Optional conversion function that maps the tool result to an output that can be used by the language model.
|
|
1146
1158
|
*
|
|
1147
1159
|
* If not provided, the tool result will be sent as a JSON object.
|
|
1160
|
+
*
|
|
1161
|
+
* This function is invoked on the server by `convertToModelMessages`, so ensure that you pass the same "tools" (ToolSet) to both "convertToModelMessages" and "streamText" (or other generation APIs).
|
|
1148
1162
|
*/
|
|
1149
1163
|
toModelOutput?: (options: {
|
|
1150
1164
|
/**
|
|
@@ -1455,4 +1469,4 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
|
|
|
1455
1469
|
*/
|
|
1456
1470
|
type ToolCallOptions = ToolExecutionOptions;
|
|
1457
1471
|
|
|
1458
|
-
export { type AssistantContent, type AssistantModelMessage, DEFAULT_MAX_DOWNLOAD_SIZE, type DataContent, DelayedPromise, DownloadError, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderOptions, type ProviderToolFactory, type ProviderToolFactoryWithOutputSchema, type ReasoningFilePart, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolExecutionOptions, type ToolModelMessage, type ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertImageModelFileToDataUri, convertToBase64, convertToFormData, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderToolFactory, createProviderToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, downloadBlob, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isNonNullable, isParsableJson, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, readResponseWithSizeLimit, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, stripFileExtension, tool, validateDownloadUrl, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
|
1472
|
+
export { type AssistantContent, type AssistantModelMessage, type CustomPart, DEFAULT_MAX_DOWNLOAD_SIZE, type DataContent, DelayedPromise, DownloadError, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderOptions, type ProviderToolFactory, type ProviderToolFactoryWithOutputSchema, type ReasoningFilePart, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolExecutionOptions, type ToolModelMessage, type ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertImageModelFileToDataUri, convertToBase64, convertToFormData, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderToolFactory, createProviderToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, downloadBlob, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isNonNullable, isParsableJson, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, readResponseWithSizeLimit, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, stripFileExtension, tool, validateDownloadUrl, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
package/dist/index.js
CHANGED
|
@@ -146,30 +146,25 @@ function convertAsyncIteratorToReadableStream(iterator) {
|
|
|
146
146
|
// src/create-tool-name-mapping.ts
|
|
147
147
|
function createToolNameMapping({
|
|
148
148
|
tools = [],
|
|
149
|
-
providerToolNames
|
|
150
|
-
resolveProviderToolName
|
|
149
|
+
providerToolNames
|
|
151
150
|
}) {
|
|
152
|
-
var _a2;
|
|
153
151
|
const customToolNameToProviderToolName = {};
|
|
154
152
|
const providerToolNameToCustomToolName = {};
|
|
155
153
|
for (const tool2 of tools) {
|
|
156
|
-
if (tool2.type === "provider") {
|
|
157
|
-
const providerToolName =
|
|
158
|
-
if (providerToolName == null) {
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
154
|
+
if (tool2.type === "provider" && tool2.id in providerToolNames) {
|
|
155
|
+
const providerToolName = providerToolNames[tool2.id];
|
|
161
156
|
customToolNameToProviderToolName[tool2.name] = providerToolName;
|
|
162
157
|
providerToolNameToCustomToolName[providerToolName] = tool2.name;
|
|
163
158
|
}
|
|
164
159
|
}
|
|
165
160
|
return {
|
|
166
161
|
toProviderToolName: (customToolName) => {
|
|
167
|
-
var
|
|
168
|
-
return (
|
|
162
|
+
var _a2;
|
|
163
|
+
return (_a2 = customToolNameToProviderToolName[customToolName]) != null ? _a2 : customToolName;
|
|
169
164
|
},
|
|
170
165
|
toCustomToolName: (providerToolName) => {
|
|
171
|
-
var
|
|
172
|
-
return (
|
|
166
|
+
var _a2;
|
|
167
|
+
return (_a2 = providerToolNameToCustomToolName[providerToolName]) != null ? _a2 : providerToolName;
|
|
173
168
|
}
|
|
174
169
|
};
|
|
175
170
|
}
|
|
@@ -675,7 +670,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
675
670
|
}
|
|
676
671
|
|
|
677
672
|
// src/version.ts
|
|
678
|
-
var VERSION = true ? "5.0.0-beta.
|
|
673
|
+
var VERSION = true ? "5.0.0-beta.5" : "0.0.0-test";
|
|
679
674
|
|
|
680
675
|
// src/get-from-api.ts
|
|
681
676
|
var getOriginalFetch = () => globalThis.fetch;
|