mirror of
https://github.com/VectifyAI/PageIndex.git
synced 2026-07-24 21:41:04 +02:00
Parsers self-report counts via ParsedDocument.metadata (pymupdf page_count; markdown len(lines)); the backend merges them generically into the stored document row at index time. New page_count/line_count columns are added in place for pre-existing DBs. Local status is always "completed" (indexing is synchronous), matching the cloud backend's field. Align the agentic demo's get_document tool docstring (and its col -> collection naming) accordingly.
44 lines
1.6 KiB
Python
44 lines
1.6 KiB
Python
# pageindex/types.py
|
|
# TypedDicts describing the plain-dict shapes the SDK returns, so callers get
|
|
# key/field discovery in their IDE without any runtime cost (these are dicts).
|
|
from __future__ import annotations
|
|
|
|
from typing import Any, TypedDict
|
|
|
|
|
|
class DocumentInfo(TypedDict):
|
|
"""A document as returned by ``list_documents()``."""
|
|
doc_id: str
|
|
doc_name: str
|
|
doc_description: str
|
|
doc_type: str
|
|
|
|
|
|
class _DocumentDetailRequired(DocumentInfo):
|
|
"""``structure`` is always present — split into its own (default
|
|
total=True) base so the total=False below only applies to the genuinely
|
|
optional, backend-specific fields below. A single
|
|
``class DocumentDetail(DocumentInfo, total=False): structure: ...`` would
|
|
incorrectly mark ``structure`` optional too, since total=False applies to
|
|
the whole class body, not just the fields declared after it.
|
|
"""
|
|
structure: list[dict[str, Any]]
|
|
|
|
|
|
class DocumentDetail(_DocumentDetailRequired, total=False):
|
|
"""A document with its tree, as returned by ``get_document()``.
|
|
|
|
``structure`` is always present; the remaining fields are
|
|
backend-specific, hence total=False.
|
|
"""
|
|
file_path: str # local backend only
|
|
status: str # local: always "completed" (indexing is synchronous); cloud: server-reported
|
|
page_count: int # local backend, PDF documents
|
|
line_count: int # local backend, Markdown documents
|
|
|
|
|
|
class PageContent(TypedDict, total=False):
|
|
"""One page of content, as returned by ``get_page_content()``."""
|
|
page: int
|
|
content: str
|
|
images: list[dict[str, Any]]
|