Package-level declarations

Types

Link copied to clipboard
class PdfAI(val document: PdfDocument, val options: PdfAIOptions = PdfAIOptions())

The entry point. One instance per document.

Link copied to clipboard
sealed class PdfAiAvailability

Whether a feature can run right now.

Link copied to clipboard
data class PdfAIOptions(val provider: PdfAiProvider? = null, val providerContextTokens: Int = 4096, val context: Context? = null, val experimentalOnDevicePrompt: Boolean = false)
Link copied to clipboard
sealed class PdfAiOutcome<out T>

The outcome of resolving the routes: an answer, or why there wasn't one.

Link copied to clipboard
fun interface PdfAiProvider

Implemented by the integrator: their own server, or their own model.

Link copied to clipboard
data class PdfAiRequest(val prompt: String, val images: List<ByteArray> = emptyList(), val schema: String? = null)
Link copied to clipboard
data class PdfAiResponse(val text: String, val structured: String? = null)
Link copied to clipboard
data class PdfAiResult<T>(val value: T, val source: PdfAiSource)
Link copied to clipboard

Where an answer came from. Shown to users and logged for audits (PRV-3).

Link copied to clipboard

Thrown by a route that failed for a reason the host can act on, such as the platform refusing inference from the background. Reported if no later route answers.

Link copied to clipboard

Why a feature cannot run.

Link copied to clipboard
sealed class PdfAnswer
Link copied to clipboard
data class PdfCitation(val pageIndex: Int, val start: Int, val end: Int, val rects: List<PdfRect>, val quote: String)

A sentence in the document that supports an answer (ANS-5).

Link copied to clipboard
data class PdfGroundedReply(val answer: String, val citations: List<PdfGroundedReply.Citation>)

What the model is asked to return (ANS-2).

Link copied to clipboard
data class PdfPageText(val pageIndex: Int, val text: String)

One page's text layer. Offsets into text are UTF-16, which the core's character indices count.

Link copied to clipboard
data class PdfPassage(val id: String, val pageIndex: Int, val start: Int, val end: Int, val text: String)

A retrievable piece of a page: whole sentences, with their UTF-16 range.

Link copied to clipboard
data class PdfProposal<T>(val id: String, val kind: PdfProposalKind, val detail: T, val source: PdfAiSource)

A change the user has not agreed to yet.

Link copied to clipboard
Link copied to clipboard
class PdfProposalSet<T>(val proposals: List<PdfProposal<T>>, write: suspend (PdfProposal<T>) -> Unit)
Link copied to clipboard
data class PdfSummary(val text: String, val pagesWithoutText: List<Int>)
Link copied to clipboard
Link copied to clipboard
data class PdfTextIndex(val pages: List<PdfPageText>, val passages: List<PdfPassage>, val pagesWithoutText: List<Int>)

Functions

Link copied to clipboard
fun locateQuote(source: String, quote: String): IntRange?

Finds a model's quote in the source text and returns its character range there (ANS-3).

Link copied to clipboard
suspend fun <T> resolveRoutes(onDevice: suspend () -> T?? = null, customProvider: suspend () -> T?? = null, rules: suspend () -> T?? = null): PdfAiOutcome<T>

Tries each route in the fixed order of PRV-2 and reports which one answered.