@ai-sdk/provider
Advanced tools
Comparing version 1.0.3 to 1.0.4
# @ai-sdk/provider | ||
## 1.0.4 | ||
### Patch Changes | ||
- 19a2ce7: feat (provider): add message option to UnsupportedFunctionalityError | ||
- 6337688: feat: change image generation errors to warnings | ||
## 1.0.3 | ||
@@ -4,0 +11,0 @@ |
@@ -301,4 +301,5 @@ import { JSONSchema7 } from 'json-schema'; | ||
readonly functionality: string; | ||
constructor({ functionality }: { | ||
constructor({ functionality, message, }: { | ||
functionality: string; | ||
message?: string; | ||
}); | ||
@@ -314,3 +315,68 @@ static isInstance(error: unknown): error is UnsupportedFunctionalityError; | ||
type ImageModelV1CallOptions = { | ||
/** | ||
Prompt for the image generation. | ||
*/ | ||
prompt: string; | ||
/** | ||
Number of images to generate. | ||
*/ | ||
n: number; | ||
/** | ||
Size of the images to generate. | ||
Must have the format `{width}x{height}`. | ||
`undefined` will use the provider's default size. | ||
*/ | ||
size: `${number}x${number}` | undefined; | ||
/** | ||
Aspect ratio of the images to generate. | ||
Must have the format `{width}:{height}`. | ||
`undefined` will use the provider's default aspect ratio. | ||
*/ | ||
aspectRatio: `${number}:${number}` | undefined; | ||
/** | ||
Seed for the image generation. | ||
`undefined` will use the provider's default seed. | ||
*/ | ||
seed: number | undefined; | ||
/** | ||
Additional provider-specific options that are passed through to the provider | ||
as body parameters. | ||
The outer record is keyed by the provider name, and the inner | ||
record is keyed by the provider-specific metadata key. | ||
```ts | ||
{ | ||
"openai": { | ||
"style": "vivid" | ||
} | ||
} | ||
``` | ||
*/ | ||
providerOptions: Record<string, Record<string, JSONValue>>; | ||
/** | ||
Abort signal for cancelling the operation. | ||
*/ | ||
abortSignal?: AbortSignal; | ||
/** | ||
Additional HTTP headers to be sent with the request. | ||
Only applicable for HTTP-based providers. | ||
*/ | ||
headers?: Record<string, string | undefined>; | ||
}; | ||
/** | ||
Warning from the model provider for this call. The call will proceed, but e.g. | ||
some settings might not be supported, which can lead to suboptimal results. | ||
*/ | ||
type ImageModelV1CallWarning = { | ||
type: 'unsupported-setting'; | ||
setting: keyof ImageModelV1CallOptions; | ||
details?: string; | ||
} | { | ||
type: 'other'; | ||
message: string; | ||
}; | ||
/** | ||
Image generation model specification version 1. | ||
@@ -336,46 +402,22 @@ */ | ||
/** | ||
Limit of how many images can be generated in a single API call. | ||
If undefined, we will max generate one image per call. | ||
*/ | ||
readonly maxImagesPerCall: number | undefined; | ||
/** | ||
Generates an array of images. | ||
*/ | ||
doGenerate(options: { | ||
doGenerate(options: ImageModelV1CallOptions): PromiseLike<{ | ||
/** | ||
Prompt for the image generation. | ||
Generated images as base64 encoded strings or binary data. | ||
The images should be returned without any unnecessary conversion. | ||
If the API returns base64 encoded strings, the images should be returned | ||
as base64 encoded strings. If the API returns binary data, the images should | ||
be returned as binary data. | ||
*/ | ||
prompt: string; | ||
images: Array<string> | Array<Uint8Array>; | ||
/** | ||
Number of images to generate. | ||
Warnings for the call, e.g. unsupported settings. | ||
*/ | ||
n: number; | ||
/** | ||
Size of the images to generate. Must have the format `{width}x{height}`. | ||
*/ | ||
size: `${number}x${number}` | undefined; | ||
/** | ||
Additional provider-specific options that are passed through to the provider | ||
as body parameters. | ||
The outer record is keyed by the provider name, and the inner | ||
record is keyed by the provider-specific metadata key. | ||
```ts | ||
{ | ||
"openai": { | ||
"style": "vivid" | ||
} | ||
} | ||
``` | ||
*/ | ||
providerOptions: Record<string, Record<string, JSONValue>>; | ||
/** | ||
Abort signal for cancelling the operation. | ||
*/ | ||
abortSignal?: AbortSignal; | ||
/** | ||
Additional HTTP headers to be sent with the request. | ||
Only applicable for HTTP-based providers. | ||
*/ | ||
headers?: Record<string, string | undefined>; | ||
}): PromiseLike<{ | ||
/** | ||
Generated images as base64 encoded strings. | ||
*/ | ||
images: Array<string>; | ||
warnings: Array<ImageModelV1CallWarning>; | ||
}>; | ||
@@ -1025,3 +1067,6 @@ }; | ||
}; | ||
warnings?: LanguageModelV1CallWarning[]; | ||
/** | ||
Warnings for the call, e.g. unsupported settings. | ||
*/ | ||
warnings?: Array<LanguageModelV1CallWarning>; | ||
}>; | ||
@@ -1092,2 +1137,2 @@ }; | ||
export { AISDKError, APICallError, type EmbeddingModelV1, type EmbeddingModelV1Embedding, EmptyResponseBodyError, type ImageModelV1, InvalidArgumentError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV1, type LanguageModelV1CallOptions, type LanguageModelV1CallWarning, type LanguageModelV1FilePart, type LanguageModelV1FinishReason, type LanguageModelV1FunctionTool, type LanguageModelV1FunctionToolCall, type LanguageModelV1ImagePart, type LanguageModelV1LogProbs, type LanguageModelV1Message, type LanguageModelV1ObjectGenerationMode, type LanguageModelV1Prompt, type LanguageModelV1ProviderDefinedTool, type LanguageModelV1ProviderMetadata, type LanguageModelV1StreamPart, type LanguageModelV1TextPart, type LanguageModelV1ToolCallPart, type LanguageModelV1ToolChoice, type LanguageModelV1ToolResultPart, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV1, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue }; | ||
export { AISDKError, APICallError, type EmbeddingModelV1, type EmbeddingModelV1Embedding, EmptyResponseBodyError, type ImageModelV1, type ImageModelV1CallOptions, type ImageModelV1CallWarning, InvalidArgumentError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV1, type LanguageModelV1CallOptions, type LanguageModelV1CallWarning, type LanguageModelV1FilePart, type LanguageModelV1FinishReason, type LanguageModelV1FunctionTool, type LanguageModelV1FunctionToolCall, type LanguageModelV1ImagePart, type LanguageModelV1LogProbs, type LanguageModelV1Message, type LanguageModelV1ObjectGenerationMode, type LanguageModelV1Prompt, type LanguageModelV1ProviderDefinedTool, type LanguageModelV1ProviderMetadata, type LanguageModelV1StreamPart, type LanguageModelV1TextPart, type LanguageModelV1ToolCallPart, type LanguageModelV1ToolChoice, type LanguageModelV1ToolResultPart, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV1, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue }; |
@@ -379,7 +379,7 @@ "use strict"; | ||
var UnsupportedFunctionalityError = class extends AISDKError { | ||
constructor({ functionality }) { | ||
super({ | ||
name: name13, | ||
message: `'${functionality}' functionality not supported.` | ||
}); | ||
constructor({ | ||
functionality, | ||
message = `'${functionality}' functionality not supported.` | ||
}) { | ||
super({ name: name13, message }); | ||
this[_a14] = true; | ||
@@ -386,0 +386,0 @@ this.functionality = functionality; |
{ | ||
"name": "@ai-sdk/provider", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
145376
1869