Skip to content

API Reference parrot.knowledge.pageindex.citations

github-actions[bot] edited this page Dec 2, 2026 · 2 revisions

parrot.knowledge.pageindex.citations

View source

Citations for PageIndex agentic retrieval (FEAT-843): models, exact-range validator, renderer.

Class Citation

A validated citation; start/end are computed by the validator (half-open, stored text).

Fields:

Field Type Default Description
doc_id str
revision str
seq int
page Optional[int] None
ordinal int
section Optional[list[str]] None
start int
end int
excerpt str
label str
document str

Class ProposedCitation

What the model proposes: an address key and a verbatim excerpt.

Fields:

Field Type Default Description
address str
excerpt str

Attribute RejectReason

Class RejectedCitation

A proposed citation rejected by the validation ladder.

Fields:

Field Type Default Description
proposed ProposedCitation
reason RejectReason

Function find_any_match

Return whether the normalized excerpt occurs anywhere in stored text.

find_any_match(segment_text: str, excerpt: str) -> bool

Parameter Type Default Description
segment_text str
excerpt str

Returns: bool

Function find_covered_match

Return the first excerpt match contained entirely in one covered range.

find_covered_match(segment_text: str, excerpt: str, covered: list[Range]) -> Optional[Range]

Parameter Type Default Description
segment_text str
excerpt str
covered list[Range]

Returns: Optional[Range]

Function normalize_ws

Normalize all runs of whitespace to one space.

normalize_ws(text: str) -> str

Parameter Type Default Description
text str

Returns: str

Function parse_address_key

Parse doc@rev#seq into (doc_id, revision, seq).

parse_address_key(key: str) -> tuple[str, str, int]

Parameter Type Default Description
key str

Returns: tuple[str, str, int]

Raises:

  • ValueError — If the key does not use the supported address shape.

Function render_citation

Render a citation as [<document>, <label>].

render_citation(citation: Citation) -> str

Parameter Type Default Description
citation Citation

Returns: str

Function render_citations

Render citations in input order, separated by semicolons.

render_citations(citations: Sequence[Citation]) -> str

Parameter Type Default Description
citations Sequence[Citation]

Returns: str

Function validate_citations

Validate proposed citations against read coverage and loaded document revisions.

Order is preserved and proposals with an already-seen normalized address and excerpt are ignored.

validate_citations(ledger: ReadLedger, load_revision: Callable[[str, str], Optional[DocumentRevision]], proposed: Sequence[ProposedCitation]) -> tuple[list[Citation], list[RejectedCitation]]

Parameter Type Default Description
ledger ReadLedger
load_revision Callable[[str, str], Optional[DocumentRevision]]
proposed Sequence[ProposedCitation]

Returns: tuple[list[Citation], list[RejectedCitation]]

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally