Skip to content

ontocast.onto.retrieval_capabilities

Vector retrieval prerequisites for selected_vector_search_ontology context mode.

OntologyContextConfigError

Bases: ValueError

Raised when vector-search ontology context mode is requested but Qdrant is missing.

Source code in ontocast/onto/retrieval_capabilities.py
class OntologyContextConfigError(ValueError):
    """Raised when vector-search ontology context mode is requested but Qdrant is missing."""

VectorStoreUnavailableError

Bases: OntologyContextConfigError

Raised when vector retrieval is requested but vector infra is unavailable.

Source code in ontocast/onto/retrieval_capabilities.py
class VectorStoreUnavailableError(OntologyContextConfigError):
    """Raised when vector retrieval is requested but vector infra is unavailable."""

    error_code: str = "VECTOR_STORE_UNAVAILABLE"

require_vector_retrieval(tools)

Raise a single canonical error if vector ensemble cannot run.

Source code in ontocast/onto/retrieval_capabilities.py
def require_vector_retrieval(tools: ToolBox) -> None:
    """Raise a single canonical error if vector ensemble cannot run."""
    if vector_retrieval_available(tools):
        return
    last_error = tools.vector_store_last_error
    details = ""
    if last_error is not None:
        details = f" Last vector-store init error: {last_error}"
    raise VectorStoreUnavailableError(
        "ontology_context_mode='selected_vector_search_ontology' requires a configured Qdrant "
        "vector store (set tool qdrant.uri, matching embedding dimension) so "
        "vector_store and patch_retriever are available and initialized."
        f"{details}"
    )

validate_ontology_context_mode(ontology_context_mode, tools)

Raise if the requested ontology context mode cannot be satisfied.

Source code in ontocast/onto/retrieval_capabilities.py
def validate_ontology_context_mode(
    ontology_context_mode: OntologyContextMode,
    tools: ToolBox,
) -> None:
    """Raise if the requested ontology context mode cannot be satisfied."""
    if ontology_context_mode == OntologyContextMode.SELECTED_VECTOR_SEARCH_ONTOLOGY:
        require_vector_retrieval(tools)

vector_retrieval_available(tools)

True when Qdrant vector store and patch retriever are both configured.

Source code in ontocast/onto/retrieval_capabilities.py
def vector_retrieval_available(tools: ToolBox) -> bool:
    """True when Qdrant vector store and patch retriever are both configured."""
    return (
        tools.vector_store is not None
        and tools.patch_retriever is not None
        and tools.is_vector_store_ready()
    )