UNPKG

@promptbook/fake-llm

Version:

Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action

82 lines (81 loc) 2.33 kB
/** * Input payload accepted by `decodeAttachmentAsText`. * * @private internal utility for shared text decoding */ export type DecodeAttachmentAsTextInput = { /** * Raw file bytes to inspect and decode. */ readonly bytes: ArrayBuffer | ArrayBufferView; /** * Original filename used for diagnostics. */ readonly filename: string; /** * Optional MIME type from transport or storage metadata. */ readonly mimeType?: string | null; }; /** * Optional settings for `decodeAttachmentAsText`. * * @private internal utility for shared text decoding */ export type DecodeAttachmentAsTextOptions = { /** * Max bytes to decode before truncating the payload. * * @default 524288 */ readonly maxBytes?: number; /** * Forces text decoding even when the bytes look binary. * * @default false */ readonly forceText?: boolean; }; /** * Best-effort text-decoding result for one attachment or file. * * @private internal utility for shared text decoding */ export type DecodeAttachmentAsTextResult = { /** * Decoded text. Empty string when decoding is skipped for binary content. */ readonly text: string; /** * Encoding label used for decoding, or `binary` when decoding was skipped. */ readonly encodingUsed: string; /** * Confidence score from `0` to `1`. */ readonly confidence?: number; /** * Human-readable warnings describing truncation or guessed encodings. */ readonly warnings: Array<string>; /** * Whether the payload was classified as binary and therefore not decoded. */ readonly wasBinary: boolean; /** * Whether the byte payload had to be truncated before decoding. */ readonly isTruncated: boolean; }; /** * Default byte limit for one best-effort text decode. * * @private constant of decodeAttachmentAsText */ export declare const DEFAULT_ATTACHMENT_TEXT_DECODE_BYTES: number; /** * Best-effort decoder for uploaded or remote file bytes whose extension or encoding may be unknown. * * @private internal utility for shared text decoding */ export declare function decodeAttachmentAsText(input: DecodeAttachmentAsTextInput, options?: DecodeAttachmentAsTextOptions): DecodeAttachmentAsTextResult;