mirror of
https://github.com/VectifyAI/PageIndex.git
synced 2026-07-15 21:11:05 +02:00
The dedup refactor dropped the explicit load_dotenv() that the old top-level utils.py ran on import. Since then, .env was only loaded as a side effect of importing litellm — which would silently break both local mode (needs OPENAI_API_KEY in the environment) and cloud usage (callers read PAGEINDEX_API_KEY via os.environ) if litellm changed that behavior or its import were made lazy. Restore an explicit load_dotenv() at the top of pageindex/__init__.py so PageIndex owns .env loading. Claude-Session: https://claude.ai/code/session_01Kx5DgKbhK1N8autqXH8SmS
57 lines
1.8 KiB
Python
57 lines
1.8 KiB
Python
# pageindex/__init__.py
|
|
# Load .env explicitly, before anything else, so environment-based credentials
|
|
# (OPENAI_API_KEY for local mode, PAGEINDEX_API_KEY that callers read via
|
|
# os.environ for cloud mode) are populated by PageIndex itself — not left to
|
|
# litellm's incidental dotenv loading, which would vanish if litellm changes or
|
|
# its import is ever made lazy.
|
|
from dotenv import load_dotenv as _load_dotenv
|
|
_load_dotenv()
|
|
|
|
# Upstream exports (backward compatibility). Import from the canonical
|
|
# pageindex.index.* modules directly so `import pageindex` does NOT trip the
|
|
# top-level deprecation shims (pageindex.page_index / .page_index_md / .utils).
|
|
from .index.page_index import * # noqa: E402
|
|
from .index.page_index_md import md_to_tree
|
|
from .retrieve import get_document, get_document_structure, get_page_content
|
|
|
|
# SDK exports
|
|
from .client import PageIndexClient, LocalClient, CloudClient
|
|
from .config import IndexConfig, set_llm_params
|
|
from .collection import Collection
|
|
from .types import DocumentInfo, DocumentDetail, PageContent
|
|
from .parser.protocol import ContentNode, ParsedDocument, DocumentParser
|
|
from .storage.protocol import StorageEngine
|
|
from .events import QueryEvent
|
|
from .errors import (
|
|
PageIndexError,
|
|
PageIndexAPIError,
|
|
CollectionNotFoundError,
|
|
DocumentNotFoundError,
|
|
IndexingError,
|
|
CloudAPIError,
|
|
FileTypeError,
|
|
)
|
|
|
|
__all__ = [
|
|
"PageIndexClient",
|
|
"LocalClient",
|
|
"CloudClient",
|
|
"IndexConfig",
|
|
"set_llm_params",
|
|
"Collection",
|
|
"DocumentInfo",
|
|
"DocumentDetail",
|
|
"PageContent",
|
|
"ContentNode",
|
|
"ParsedDocument",
|
|
"DocumentParser",
|
|
"StorageEngine",
|
|
"QueryEvent",
|
|
"PageIndexError",
|
|
"PageIndexAPIError",
|
|
"CollectionNotFoundError",
|
|
"DocumentNotFoundError",
|
|
"IndexingError",
|
|
"CloudAPIError",
|
|
"FileTypeError",
|
|
]
|