2026-04-06 22:51:04 +08:00
|
|
|
class PageIndexError(Exception):
|
|
|
|
|
"""Base exception for all PageIndex SDK errors."""
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CollectionNotFoundError(PageIndexError):
|
|
|
|
|
"""Collection does not exist."""
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DocumentNotFoundError(PageIndexError):
|
|
|
|
|
"""Document ID not found."""
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class IndexingError(PageIndexError):
|
|
|
|
|
"""Indexing pipeline failure."""
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
2026-05-11 21:06:23 +08:00
|
|
|
class PageIndexAPIError(PageIndexError):
|
|
|
|
|
"""PageIndex cloud API returned an error.
|
|
|
|
|
|
|
|
|
|
Kept for compatibility with the pageindex 0.2.x cloud SDK.
|
|
|
|
|
"""
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CloudAPIError(PageIndexAPIError):
|
2026-07-07 09:40:09 +08:00
|
|
|
"""Cloud API returned error.
|
|
|
|
|
|
|
|
|
|
``status_code`` carries the HTTP status when the error came from an HTTP
|
|
|
|
|
response (None for transport-level failures), so callers can branch on it
|
|
|
|
|
instead of parsing the message.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def __init__(self, message: str, status_code: int | None = None):
|
|
|
|
|
super().__init__(message)
|
|
|
|
|
self.status_code = status_code
|
2026-04-06 22:51:04 +08:00
|
|
|
|
|
|
|
|
|
fix: address PR #272 review findings (directly-fixable items)
Verified against current dev; the compat/behavior decisions (#7 api_key
semantics, #10 CLI flags, #11 doc-description default) are deferred.
Crashes:
- page_index(): snapshot args before importing IndexConfig — locals() was
capturing the imported class and IndexConfig(extra='forbid') made every call
raise ValidationError.
- process_none_page_numbers: pop('page', None) instead of del (a TOC item
without 'page' raised KeyError mid-pipeline).
- pipeline._run_async: guard only the loop detection, not the run, so a real
RuntimeError from the coroutine isn't masked as "asyncio.run() cannot be
called from a running event loop".
Silent-wrong / robustness:
- LocalBackend.get_document_structure and the agent get_document /
get_document_structure tools now surface a missing doc (raise / error-JSON)
instead of returning empty, matching get_page_content and the cloud backend.
- cloud delete_collection drops the cached folder_id.
- cloud query raises on an empty collection instead of POSTing doc_id:[].
- LocalClient skips the API-key check for keyless providers (ollama, lm_studio,
…) so keyless LiteLLM models aren't rejected at construction.
Compat / cleanup:
- md_to_tree coerces legacy 'yes'/'no' string flags (a bare 'no' was truthy).
- FileTypeError also subclasses ValueError (0.2.x raised ValueError).
- _validate_llm_provider no longer mutates global litellm.model_cost_map_url.
- __all__ re-includes legacy exports (page_index, md_to_tree, get_*).
- Rewrite examples/agentic_vectorless_rag_demo.py to the Collection API and use
the in-repo attention.pdf (the old workspace=/client.index/client.documents
API no longer exists).
Adds tests/test_review_fixes.py (10 regressions). Full suite: 189 passed.
Claude-Session: https://claude.ai/code/session_01Kx5DgKbhK1N8autqXH8SmS
2026-07-08 18:56:51 +08:00
|
|
|
class FileTypeError(PageIndexError, ValueError):
|
|
|
|
|
"""Unsupported file type.
|
|
|
|
|
|
|
|
|
|
Also subclasses ValueError so pre-SDK ``except ValueError`` around indexing
|
|
|
|
|
(0.2.x raised ValueError for an unsupported file format) still catches it.
|
|
|
|
|
"""
|
2026-04-06 22:51:04 +08:00
|
|
|
pass
|