跳转到内容

路径

路径读取器 #

基类:EventBaseReader

路径读取器。

从Pathway数据索引管道中检索文档。

参数:

名称 类型 描述 默认
host str

Pathway当前托管所在的URI。

None
port str | int

Pathway 正在监听的端口号。

None
相关链接

llamaindex.retriever.pathway.PathwayRetriever and, llamaindex.retriever.pathway.PathwayVectorServer

workflows/handler.py 中的源代码llama_index/readers/pathway/base.py
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
class PathwayReader(BaseReader):
    """
    Pathway reader.

    Retrieve documents from Pathway data indexing pipeline.

    Args:
        host (str): The URI where Pathway is currently hosted.
        port (str | int): The port number on which Pathway is listening.

    See Also:
        llamaindex.retriever.pathway.PathwayRetriever and,
        llamaindex.retriever.pathway.PathwayVectorServer

    """

    def __init__(
        self,
        host: Optional[str] = None,
        port: Optional[int] = None,
        url: Optional[str] = None,
    ):
        """Initializing the Pathway reader client."""
        self.client = _VectorStoreClient(host, port, url)

    def load_data(
        self,
        query_text: str,
        k: Optional[int] = 4,
        metadata_filter: Optional[str] = None,
    ) -> List[Document]:
        """
        Load data from Pathway.

        Args:
            query_text (str): The text to get the closest neighbors of.
            k (int): Number of results to return.
            metadata_filter (str): Filter to be applied.

        Returns:
            List[Document]: A list of documents.

        """
        results = self.client(query_text, k, metadata_filter)
        documents = []
        for return_elem in results:
            document = Document(
                text=return_elem["text"],
                extra_info=return_elem["metadata"],
            )

            documents.append(document)

        return documents

load_data #

load_data(query_text: str, k: Optional[int] = 4, metadata_filter: Optional[str] = None) -> List[文档]

从Pathway加载数据。

参数:

名称 类型 描述 默认
query_text str

要获取最邻近项的文本。

required
k int

返回结果的数量。

4
metadata_filter str

要应用的过滤器。

None

返回:

类型 描述
List[文档]

List[Document]: 文档列表。

workflows/handler.py 中的源代码llama_index/readers/pathway/base.py
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
def load_data(
    self,
    query_text: str,
    k: Optional[int] = 4,
    metadata_filter: Optional[str] = None,
) -> List[Document]:
    """
    Load data from Pathway.

    Args:
        query_text (str): The text to get the closest neighbors of.
        k (int): Number of results to return.
        metadata_filter (str): Filter to be applied.

    Returns:
        List[Document]: A list of documents.

    """
    results = self.client(query_text, k, metadata_filter)
    documents = []
    for return_elem in results:
        document = Document(
            text=return_elem["text"],
            extra_info=return_elem["metadata"],
        )

        documents.append(document)

    return documents

选项: 成员:- PathwayReader