+12
-12
| { | ||
| "name": "ai", | ||
| "version": "7.0.88", | ||
| "version": "7.0.89", | ||
| "type": "module", | ||
@@ -45,16 +45,16 @@ "description": "AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.", | ||
| "dependencies": { | ||
| "@ai-sdk/gateway": "4.0.70", | ||
| "@ai-sdk/provider": "4.0.9", | ||
| "@ai-sdk/provider-utils": "5.0.34" | ||
| "@ai-sdk/gateway": "4.0.71", | ||
| "@ai-sdk/provider": "4.0.10", | ||
| "@ai-sdk/provider-utils": "5.0.35" | ||
| }, | ||
| "devDependencies": { | ||
| "@ai-sdk/amazon-bedrock": "5.0.70", | ||
| "@ai-sdk/deepseek": "3.0.37", | ||
| "@ai-sdk/google": "4.0.60", | ||
| "@ai-sdk/groq": "4.0.35", | ||
| "@ai-sdk/huggingface": "2.0.41", | ||
| "@ai-sdk/moonshotai": "3.0.43", | ||
| "@ai-sdk/openai": "4.0.54", | ||
| "@ai-sdk/amazon-bedrock": "5.0.71", | ||
| "@ai-sdk/deepseek": "3.0.38", | ||
| "@ai-sdk/google": "4.0.61", | ||
| "@ai-sdk/groq": "4.0.36", | ||
| "@ai-sdk/huggingface": "2.0.42", | ||
| "@ai-sdk/moonshotai": "3.0.44", | ||
| "@ai-sdk/openai": "4.0.55", | ||
| "@ai-sdk/test-server": "2.0.1", | ||
| "@ai-sdk/xai": "4.0.51", | ||
| "@ai-sdk/xai": "4.0.52", | ||
| "@edge-runtime/vm": "^5.0.0", | ||
@@ -61,0 +61,0 @@ "@smithy/eventstream-codec": "^4.3.3", |
@@ -9,4 +9,16 @@ import type { ProviderMetadata } from '../types/provider-metadata'; | ||
| readonly filename?: string; | ||
| /** | ||
| * The size of the uploaded file in bytes, if reported by the provider. | ||
| */ | ||
| readonly byteSize?: number; | ||
| /** | ||
| * When the file was created, if reported by the provider. | ||
| */ | ||
| readonly createdAt?: Date; | ||
| /** | ||
| * When the provider will delete the file (retention expiry), if reported. | ||
| */ | ||
| readonly expiresAt?: Date; | ||
| readonly providerMetadata?: ProviderMetadata; | ||
| readonly warnings: Array<Warning>; | ||
| } |
@@ -19,9 +19,19 @@ import type { | ||
| * @param api - The Files API interface to use for uploading. | ||
| * @param data - The file data to upload (tagged `{ type: 'data' | 'text' }`). | ||
| * @param data - The file data to upload (tagged `{ type: 'data' | 'text' | 'stream' }`). | ||
| * Stream data is sent without buffering by providers that support streaming | ||
| * uploads (others reject with `UnsupportedFunctionalityError`); the provider | ||
| * consumes the stream — any failed upload, including validation failures | ||
| * before a request is made, cancels it. Do not reuse it. | ||
| * @param mediaType - Optional IANA media type. Auto-detected from file bytes | ||
| * when omitted (falls back to `text/plain` for the `text` variant). | ||
| * @param filename - Optional filename for the uploaded file. | ||
| * when omitted (falls back to `text/plain` for the `text` variant and | ||
| * `application/octet-stream` for the `stream` variant, which cannot be sniffed). | ||
| * @param filename - Optional filename for the uploaded file. Multipart-based | ||
| * providers default it to `"blob"` when omitted. | ||
| * @param abortSignal - Optional signal to cancel the upload. | ||
| * @param headers - Optional additional HTTP headers for the request. | ||
| * @param providerOptions - Additional provider-specific options. | ||
| * | ||
| * @returns A result object containing the provider reference and optional metadata. | ||
| * @returns A result object containing the provider reference, optional | ||
| * metadata, and — when reported by the provider — `byteSize`, `createdAt`, | ||
| * and `expiresAt` (the provider-applied retention expiry). | ||
| */ | ||
@@ -33,2 +43,4 @@ export async function uploadFile({ | ||
| filename, | ||
| abortSignal, | ||
| headers, | ||
| providerOptions, | ||
@@ -59,2 +71,3 @@ }: { | ||
| // stream data cannot be sniffed without consuming it | ||
| const mediaType = | ||
@@ -64,22 +77,38 @@ mediaTypeArg ?? | ||
| ? 'text/plain' | ||
| : (detectMediaType({ data: data.data }) ?? | ||
| (isLikelyText(data.data) ? 'text/plain' : 'application/octet-stream'))); | ||
| : data.type === 'stream' | ||
| ? 'application/octet-stream' | ||
| : (detectMediaType({ data: data.data }) ?? | ||
| (isLikelyText(data.data) | ||
| ? 'text/plain' | ||
| : 'application/octet-stream'))); | ||
| const filesApi: FilesV4 = | ||
| 'uploadFile' in api | ||
| ? api | ||
| : typeof api.files === 'function' | ||
| ? api.files() | ||
| : (() => { | ||
| throw new Error( | ||
| 'The provider does not support file uploads. Make sure it exposes a files() method.', | ||
| ); | ||
| })(); | ||
| let result; | ||
| try { | ||
| const filesApi: FilesV4 = | ||
| 'uploadFile' in api | ||
| ? api | ||
| : typeof api.files === 'function' | ||
| ? api.files() | ||
| : (() => { | ||
| throw new Error( | ||
| 'The provider does not support file uploads. Make sure it exposes a files() method.', | ||
| ); | ||
| })(); | ||
| const result = await filesApi.uploadFile({ | ||
| data, | ||
| mediaType, | ||
| filename, | ||
| providerOptions, | ||
| }); | ||
| result = await filesApi.uploadFile({ | ||
| data, | ||
| mediaType, | ||
| filename, | ||
| abortSignal, | ||
| headers, | ||
| providerOptions, | ||
| }); | ||
| } catch (error) { | ||
| // ownership guarantee: a failed upload releases the stream, even when | ||
| // the provider rejected before (or without) consuming it | ||
| if (data.type === 'stream') { | ||
| await data.stream.cancel(error).catch(() => {}); | ||
| } | ||
| throw error; | ||
| } | ||
@@ -90,2 +119,5 @@ return new DefaultUploadFileResult({ | ||
| filename: result.filename, | ||
| byteSize: result.byteSize, | ||
| createdAt: result.createdAt, | ||
| expiresAt: result.expiresAt, | ||
| providerMetadata: result.providerMetadata, | ||
@@ -100,2 +132,5 @@ warnings: result.warnings, | ||
| readonly filename?: string; | ||
| readonly byteSize?: number; | ||
| readonly createdAt?: Date; | ||
| readonly expiresAt?: Date; | ||
| readonly providerMetadata?: ProviderMetadata; | ||
@@ -108,2 +143,5 @@ readonly warnings: Array<Warning>; | ||
| filename?: string; | ||
| byteSize?: number; | ||
| createdAt?: Date; | ||
| expiresAt?: Date; | ||
| providerMetadata?: ProviderMetadata; | ||
@@ -115,2 +153,5 @@ warnings: Array<Warning>; | ||
| this.filename = options.filename; | ||
| this.byteSize = options.byteSize; | ||
| this.createdAt = options.createdAt; | ||
| this.expiresAt = options.expiresAt; | ||
| this.providerMetadata = options.providerMetadata; | ||
@@ -117,0 +158,0 @@ this.warnings = options.warnings; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
6917527
0.13%72313
0.13%+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
Updated
Updated