Skip to content

LlamaIndex

LlamaIndexBridgeMixin

Bases: BaseBridgeMixin

LlamaIndex Bridge.

This mixin adds LlamaIndex conversion capabilities to _RAGSystem. When mixed with an unbridged _RAGSystem, it allows direct conversion to LlamaIndex's BaseManagedIndex through the to_llamaindex() method.

Source code in src/fed_rag/_bridges/llamaindex/bridge.py
class LlamaIndexBridgeMixin(BaseBridgeMixin):
    """LlamaIndex Bridge.

    This mixin adds LlamaIndex conversion capabilities to _RAGSystem.
    When mixed with an unbridged _RAGSystem, it allows direct conversion to
    LlamaIndex's BaseManagedIndex through the to_llamaindex() method.
    """

    _bridge_version = __version__
    _bridge_extra = "llama-index"
    _framework = "llama-index"
    _compatible_versions = ["0.12.35"]
    _method_name = "to_llamaindex"

    def to_llamaindex(self: "_RAGSystem") -> "BaseManagedIndex":
        """Converts the _RAGSystem to a ~llamaindex.core.BaseManagedIndex."""
        self._validate_framework_installed()

        from fed_rag._bridges.llamaindex._managed_index import (
            FedRAGManagedIndex,
        )

        return FedRAGManagedIndex(rag_system=self)

to_llamaindex

to_llamaindex()

Converts the _RAGSystem to a ~llamaindex.core.BaseManagedIndex.

Source code in src/fed_rag/_bridges/llamaindex/bridge.py
def to_llamaindex(self: "_RAGSystem") -> "BaseManagedIndex":
    """Converts the _RAGSystem to a ~llamaindex.core.BaseManagedIndex."""
    self._validate_framework_installed()

    from fed_rag._bridges.llamaindex._managed_index import (
        FedRAGManagedIndex,
    )

    return FedRAGManagedIndex(rag_system=self)