UNPKG

nano-ai-pdf

Version:

This package helps you summarize pdfs using Gemini nano on edge or on browser, making it compliant safe, faster and free

96 lines (95 loc) 2.99 kB
/** * Available summary types for the Chrome Summarizer API */ export type SummaryType = "key-points" | "tldr" | "teaser" | "headline"; /** * Available output formats for summaries */ export type SummaryFormat = "markdown" | "plain-text"; /** * Available summary lengths */ export type SummaryLength = "short" | "medium" | "long"; /** * Model availability status from Chrome's Summarizer API */ export type ModelAvailability = "available" | "downloadable" | "downloading" | "unavailable"; /** * Configuration options for PDF summarization */ export interface PdfSummarizerOptions { /** Type of summary to generate */ type?: SummaryType; /** Output format for the summary */ format?: SummaryFormat; /** Length of the summary */ length?: SummaryLength; /** Additional context to help with summarization */ context?: string; /** Shared context for the summarizer session */ sharedContext?: string; /** Enable streaming mode for real-time summary generation */ enableStreaming?: boolean; /** Maximum file size allowed in bytes (default: 10MB) */ maxFileSize?: number; /** Minimum text length required for summarization (default: 100 characters) */ minTextLength?: number; } /** * Result object returned by the PDF summarizer */ export interface PdfSummarizerResult { /** The generated summary text */ summary: string; /** Original text extracted from the PDF */ originalText: string; /** Length of the original text in characters */ originalLength: number; /** Length of the summary in characters */ summaryLength: number; /** Compression ratio (percentage) */ compressionRatio: number; /** Time taken to generate the summary in milliseconds */ processingTime: number; /** Configuration used for this summarization */ config: Required<PdfSummarizerOptions>; } /** * Streaming result for real-time summary generation */ export interface PdfSummarizerStreamResult extends Omit<PdfSummarizerResult, "summary"> { /** Async iterable for streaming summary chunks */ summaryStream: AsyncIterable<string>; } /** * Chrome Summarizer API interface */ export interface ChromeSummarizer { summarize(text: string, options?: { context?: string; }): Promise<string>; summarizeStreaming(text: string, options?: { context?: string; }): AsyncIterable<string>; destroy(): void; } /** * Chrome Summarizer factory interface */ export interface ChromeSummarizerFactory { availability(): Promise<ModelAvailability>; create(options?: { type?: SummaryType; format?: SummaryFormat; length?: SummaryLength; sharedContext?: string; monitor?: (monitor: EventTarget) => void; }): Promise<ChromeSummarizer>; } /** * Custom error class for PDF summarizer errors */ export declare class PdfSummarizerError extends Error { code: string; constructor(message: string, code: string); }