import { JSONValue } from '../../global/dist/index.js'; import { MessageContentDetail, MessageContent, ChatMessage, ToolMetadata } from '../../llms/dist/index.js'; import { QueryType } from '../../query-engine/dist/index.js'; import { ImageType } from '../../schema/dist/index.js'; /** * Extracts just the text whether from * a multi-modal message * a single text message * or a query * * @param message The message to extract text from. * @returns The extracted text */ declare function extractText(message: MessageContent | QueryType): string; /** * Extracts a single text from a multi-modal message content * * @param message The message to extract images from. * @returns The extracted images */ declare function extractSingleText(message: MessageContentDetail): string | null; /** * Extracts an image from a multi-modal message content * * @param message The message to extract images from. * @returns The extracted images */ declare function extractImage(message: MessageContentDetail): ImageType | null; declare const extractDataUrlComponents: (dataUrl: string) => { mimeType: string; base64: string; }; declare function messagesToHistory(messages: ChatMessage[]): string; declare function toToolDescriptions(tools: ToolMetadata[]): string; declare function imageToDataUrl(input: ImageType | Uint8Array): Promise; /** * Converts a base64 string (without data: prefix) to a Uint8Array * @param base64 - The base64 string without data: prefix * @returns The Uint8Array */ declare function base64ToUint8Array(base64: string): Uint8Array; /** * Converts a Uint8Array to a base64 string. * @param uint8Array The Uint8Array to convert. * @returns The base64-encoded string. */ declare function uint8ArrayToBase64(uint8Array: Uint8Array): string; /** * Extracts the MIME type from a data URL. * @param dataUrl The data URL string. * @returns The MIME type from the data URL. * @throws An error if the data URL is malformed. */ declare function getMimeTypeFromDataUrl(dataUrl: string): string; /** * Convert base64 data to Blob * @param base64 - The base64 string * @param mimeType - The MIME type of the file * @returns The Blob */ declare function base64ToBlob(base64: string, mimeType?: string): Blob; declare function blobToDataUrl(input: Blob): Promise; type ObjectEntries> = { [K in keyof T]: [K, T[K]]; }[keyof T][]; /** * Type safe version of `Object.entries` */ declare function objectEntries>(obj: T): ObjectEntries<{ [K in keyof T]-?: NonNullable; }>; declare function streamConverter(stream: AsyncIterable, converter: (s: S) => D | null): AsyncIterable; declare const isPromise: (obj: unknown) => obj is Promise; declare const isAsyncIterable: (obj: unknown) => obj is AsyncIterable; declare const isIterable: (obj: unknown) => obj is Iterable; declare function streamCallbacks(stream: AsyncIterable, callbacks: { finished?: (value?: S) => void; }): AsyncIterable; declare function streamReducer(params: { stream: AsyncIterable; reducer: (previousValue: D, currentValue: S) => D; initialValue: D; finished?: (value: D) => void; }): AsyncIterable; /** * Prettify an error for AI to read */ declare function prettifyError(error: unknown): string; /** * Returns a stringfied JSON with double quotes removed. * * @param value - The JSON value to stringify * @returns The stringified JSON with no double quotes */ declare function stringifyJSONToMessageContent(value: JSONValue): string; declare function assertIsJSONValue(value: unknown): asserts value is JSONValue; export { assertIsJSONValue, base64ToBlob, base64ToUint8Array, blobToDataUrl, extractDataUrlComponents, extractImage, extractSingleText, extractText, getMimeTypeFromDataUrl, imageToDataUrl, isAsyncIterable, isIterable, isPromise, messagesToHistory, objectEntries, prettifyError, streamCallbacks, streamConverter, streamReducer, stringifyJSONToMessageContent, toToolDescriptions, uint8ArrayToBase64 };