Skip to content

Summary

SummaryIndexRetriever #

Bases: BaseRetriever

简单的检索器,用于返回SummaryIndex中的所有节点。

Parameters:

Name Type Description Default
index SummaryIndex

要检索的索引。

required
Source code in llama_index/core/indices/list/retrievers.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class SummaryIndexRetriever(BaseRetriever):
    """简单的检索器,用于返回SummaryIndex中的所有节点。

    Args:
        index (SummaryIndex): 要检索的索引。"""

    def __init__(
        self,
        index: SummaryIndex,
        callback_manager: Optional[CallbackManager] = None,
        object_map: Optional[dict] = None,
        verbose: bool = False,
        **kwargs: Any,
    ) -> None:
        self._index = index
        super().__init__(
            callback_manager=callback_manager, object_map=object_map, verbose=verbose
        )

    def _retrieve(
        self,
        query_bundle: QueryBundle,
    ) -> List[NodeWithScore]:
        """检索节点。"""
        del query_bundle

        node_ids = self._index.index_struct.nodes
        nodes = self._index.docstore.get_nodes(node_ids)
        return [NodeWithScore(node=node) for node in nodes]