@ai-sdk/ui-utils
Advanced tools
Comparing version 0.0.13 to 0.0.14
@@ -38,2 +38,3 @@ "use strict"; | ||
generateId: () => import_provider_utils2.generateId, | ||
getTextFromDataUrl: () => getTextFromDataUrl, | ||
isDeepEqualData: () => isDeepEqualData, | ||
@@ -1182,2 +1183,16 @@ parseComplexResponse: () => parseComplexResponse, | ||
} | ||
// src/data-url.ts | ||
function getTextFromDataUrl(dataUrl) { | ||
const [header, base64Content] = dataUrl.split(","); | ||
const mimeType = header.split(";")[0].split(":")[1]; | ||
if (mimeType == null || base64Content == null) { | ||
throw new Error("Invalid data URL format"); | ||
} | ||
try { | ||
return window.atob(base64Content); | ||
} catch (error) { | ||
throw new Error(`Error decoding data URL`); | ||
} | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -1190,2 +1205,3 @@ 0 && (module.exports = { | ||
generateId, | ||
getTextFromDataUrl, | ||
isDeepEqualData, | ||
@@ -1192,0 +1208,0 @@ parseComplexResponse, |
@@ -185,2 +185,20 @@ export { generateId } from '@ai-sdk/provider-utils'; | ||
/** | ||
* An attachment that can be sent along with a message. | ||
*/ | ||
interface Attachment { | ||
/** | ||
* The name of the attachment, usually the file name. | ||
*/ | ||
name?: string; | ||
/** | ||
* A string indicating the [media type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type). | ||
* By default, it's extracted from the pathname's extension. | ||
*/ | ||
contentType?: string; | ||
/** | ||
* The URL of the attachment. It can either be a URL to a hosted file or a [Data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs). | ||
*/ | ||
url: string; | ||
} | ||
/** | ||
* AI SDK UI Messages. They are used in the client and to communicate between the frontend and the API routes. | ||
@@ -193,2 +211,6 @@ */ | ||
/** | ||
* Additional attachments to be sent along with the message. | ||
*/ | ||
experimental_attachments?: Attachment[]; | ||
/** | ||
* @deprecated Use AI SDK 3.1 `toolInvocations` instead. | ||
@@ -312,2 +334,6 @@ */ | ||
/** | ||
* Additional files to be sent to the server. | ||
*/ | ||
experimental_attachments?: FileList | Array<Attachment>; | ||
/** | ||
The options to be passed to the fetch call. | ||
@@ -750,2 +776,7 @@ | ||
export { type AssistantMessage, type AssistantStatus, type ChatRequest, type ChatRequestOptions, type CreateMessage, type DataMessage, type DeepPartial, type FetchFunction, type Function, type FunctionCall, type FunctionCallHandler, type IdGenerator, type JSONValue, type Message, type RequestOptions, type StreamPart, type StreamString, type Tool, type ToolCall, type ToolCallHandler, type ToolChoice, type ToolInvocation, type UseAssistantOptions, type UseChatOptions, type UseCompletionOptions, callChatApi, callCompletionApi, createChunkDecoder, formatStreamPart, isDeepEqualData, parseComplexResponse, parsePartialJson, parseStreamPart, processChatStream, readDataStream }; | ||
/** | ||
* Converts a data URL of type text/* to a text string. | ||
*/ | ||
declare function getTextFromDataUrl(dataUrl: string): string; | ||
export { type AssistantMessage, type AssistantStatus, type Attachment, type ChatRequest, type ChatRequestOptions, type CreateMessage, type DataMessage, type DeepPartial, type FetchFunction, type Function, type FunctionCall, type FunctionCallHandler, type IdGenerator, type JSONValue, type Message, type RequestOptions, type StreamPart, type StreamString, type Tool, type ToolCall, type ToolCallHandler, type ToolChoice, type ToolInvocation, type UseAssistantOptions, type UseChatOptions, type UseCompletionOptions, callChatApi, callCompletionApi, createChunkDecoder, formatStreamPart, getTextFromDataUrl, isDeepEqualData, parseComplexResponse, parsePartialJson, parseStreamPart, processChatStream, readDataStream }; |
@@ -38,2 +38,3 @@ "use strict"; | ||
generateId: () => import_provider_utils2.generateId, | ||
getTextFromDataUrl: () => getTextFromDataUrl, | ||
isDeepEqualData: () => isDeepEqualData, | ||
@@ -1182,2 +1183,16 @@ parseComplexResponse: () => parseComplexResponse, | ||
} | ||
// src/data-url.ts | ||
function getTextFromDataUrl(dataUrl) { | ||
const [header, base64Content] = dataUrl.split(","); | ||
const mimeType = header.split(";")[0].split(":")[1]; | ||
if (mimeType == null || base64Content == null) { | ||
throw new Error("Invalid data URL format"); | ||
} | ||
try { | ||
return window.atob(base64Content); | ||
} catch (error) { | ||
throw new Error(`Error decoding data URL`); | ||
} | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -1190,2 +1205,3 @@ 0 && (module.exports = { | ||
generateId, | ||
getTextFromDataUrl, | ||
isDeepEqualData, | ||
@@ -1192,0 +1208,0 @@ parseComplexResponse, |
{ | ||
"name": "@ai-sdk/ui-utils", | ||
"version": "0.0.13", | ||
"version": "0.0.14", | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3988487
36865