rag.core.citations¶
Citation helpers for retrieved LlamaIndex nodes.
Attributes¶
Classes¶
LlamaIndex / loader metadata keys that may hold a file path or name. |
|
LlamaIndex / pypdf metadata keys that may hold a page number. |
|
A single retrieved source used to ground an answer. |
Functions¶
|
Convert LlamaIndex |
|
Render citations as a markdown bullet list. |
Module Contents¶
- class rag.core.citations.FileMetadataKey[source]¶
Bases:
enum.StrEnumLlamaIndex / loader metadata keys that may hold a file path or name.
- class rag.core.citations.PageMetadataKey[source]¶
Bases:
enum.StrEnumLlamaIndex / pypdf metadata keys that may hold a page number.
- class rag.core.citations.Citation[source]¶
A single retrieved source used to ground an answer.
- Variables:
file_name (str) – PDF file name (or path basename).
page (int or None) – 1-based page number when available.
score (float or None) – Retriever score when available.
snippet (str) – Short text excerpt from the chunk.
- rag.core.citations.citations_from_nodes(*, nodes: collections.abc.Sequence[Any], max_snippet_chars: int = DEFAULT_SNIPPET_CHARS) list[Citation][source]¶
Convert LlamaIndex
NodeWithScoreobjects into citations.- Parameters:
nodes (Sequence) – Retrieved nodes (typically
NodeWithScore).max_snippet_chars (int) – Max characters for each snippet.
- Returns:
Ordered citations matching retrieval order.
- Return type:
list of Citation