Skip to content

Raptor

RaptorPack #

Bases: BaseLlamaPack

Raptor pack.

Source code in llama-index-packs/llama-index-packs-raptor/llama_index/packs/raptor/base.py
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
class RaptorPack(BaseLlamaPack):
    """Raptor pack."""

    def __init__(
        self,
        documents: List[BaseNode],
        llm: Optional[LLM] = None,
        embed_model: Optional[BaseEmbedding] = None,
        vector_store: Optional[BasePydanticVectorStore] = None,
        similarity_top_k: int = 2,
        mode: QueryModes = "collapsed",
        verbose: bool = True,
        **kwargs: Any,
    ) -> None:
        """Init params."""
        self.retriever = RaptorRetriever(
            documents,
            embed_model=embed_model,
            llm=llm,
            similarity_top_k=similarity_top_k,
            vector_store=vector_store,
            mode=mode,
            verbose=verbose,
            **kwargs,
        )

    def get_modules(self) -> Dict[str, Any]:
        """Get modules."""
        return {
            "retriever": self.retriever,
        }

    def run(
        self,
        query: str,
        mode: Optional[QueryModes] = None,
    ) -> Any:
        """Run the pipeline."""
        return self.retriever.retrieve(query, mode=mode)

get_modules #

get_modules() -> Dict[str, Any]

Get modules.

Source code in llama-index-packs/llama-index-packs-raptor/llama_index/packs/raptor/base.py
369
370
371
372
373
def get_modules(self) -> Dict[str, Any]:
    """Get modules."""
    return {
        "retriever": self.retriever,
    }

run #

run(query: str, mode: Optional[QueryModes] = None) -> Any

Run the pipeline.

Source code in llama-index-packs/llama-index-packs-raptor/llama_index/packs/raptor/base.py
375
376
377
378
379
380
381
def run(
    self,
    query: str,
    mode: Optional[QueryModes] = None,
) -> Any:
    """Run the pipeline."""
    return self.retriever.retrieve(query, mode=mode)