Skip to main content
Dell PowerScale 是一款企业级横向扩展存储系统,搭载业界领先的 OneFS 文件系统,可部署于本地或云端。 本文档加载器利用 PowerScale 的独特能力,能够判断自应用上次运行以来哪些文件已被修改,并仅返回修改过的文件进行处理。这将避免对未变更文件进行重复处理(分块和嵌入),从而提升整体数据摄取工作流的效率。 此加载器需要启用 PowerScale 的 MetadataIQ 功能。更多信息请参阅我们的 GitHub 仓库:https://github.com/dell/powerscale-rag-connector

概述

集成详情

加载器特性

来源文档惰性加载原生异步支持
PowerScaleDocumentLoader
PowerScaleUnstructuredLoader

设置

此文档加载器需要启用 MetadataIQ 功能的 Dell PowerScale 系统。更多信息请参阅我们的 GitHub 页面:https://github.com/dell/powerscale-rag-connector

安装

文档加载器位于外部 pip 包中,可使用标准工具进行安装:
pip install -qU  powerscale-rag-connector

初始化

现在我们可以实例化文档加载器:

通用文档加载器

我们的通用文档加载器可用于以增量方式从 PowerScale 加载所有文件:
from powerscale_rag_connector import PowerScaleDocumentLoader

loader = PowerScaleDocumentLoader(
    es_host_url="http://elasticsearch:9200",
    es_index_name="metadataiq",
    es_api_key="your-api-key",
    folder_path="/ifs/data",
)

UnstructuredLoader 加载器

可选地,PowerScaleUnstructuredLoader 可用于定位已更改的文件, 自动处理文件以生成源文件的元素。这是通过 LangChain 的 UnstructuredLoader 类实现的。
from powerscale_rag_connector import PowerScaleUnstructuredLoader

# Or load files with the Unstructured Loader
loader = PowerScaleUnstructuredLoader(
    es_host_url="http://elasticsearch:9200",
    es_index_name="metadataiq",
    es_api_key="your-api-key",
    folder_path="/ifs/data",
    # 'elements' mode splits the document into more granular chunks
    # Use 'single' mode if you want the entire document as a single chunk
    mode="elements",
)
字段说明:
  • es_host_url 是 MetadataIQ Elasticsearch 数据库的端点
  • es_index_index 是 PowerScale 写入文件系统元数据的索引名称
  • es_api_key 是您的 Elasticsearch API 密钥的编码版本
  • folder_path 是 PowerScale 上需要查询变更的路径

加载

内部代码与 PowerScale 和 MetadataIQ 的交互全部是异步的,load 和 lazy_load 方法将返回一个 Python 生成器。建议使用惰性加载函数。
for doc in loader.load():
    print(doc)
[Document(page_content='' metadata={'source': '/ifs/pdfs/1994-Graph.Theoretic.Obstacles.to.Perfect.Hashing.TR0257.pdf', 'snapshot': 20834, 'change_types': ['ENTRY_ADDED']}),
Document(page_content='' metadata={'source': '/ifs/pdfs/New.sendfile-FreeBSD.20.Feb.2015.pdf', 'snapshot': 20920, 'change_types': ['ENTRY_MODIFIED']}),
Document(page_content='' metadata={'source': '/ifs/pdfs/FAST-Fast.Architecture.Sensitive.Tree.Search.on.Modern.CPUs.and.GPUs-Slides.pdf', 'snapshot': 20924, 'change_types': ['ENTRY_ADDED']})]

返回对象

两个文档加载器都会追踪之前返回给应用程序的文件。再次调用时,文档加载器只会返回自上次运行以来新增或修改的文件。
  • 返回的 Document 中的 metadata 字段将返回包含已修改文件的 PowerScale 路径。您将使用此路径通过 NFS(或 S3)读取数据,并在应用程序中处理数据(例如:创建分块和嵌入)。
  • source 字段是 PowerScale 上的路径,不一定是本地系统上的路径(取决于您的挂载策略);OneFS 将整个存储系统表示为以 /ifs 为根节点的单一树结构。
  • change_types 属性将告知您自上次以来发生了何种变更——例如:新增、修改或删除。
您的 RAG 应用可使用 change_types 中的信息来对分块和向量存储中的条目进行增加、更新或删除操作。 使用 PowerScaleUnstructuredLoader 时,page_content 字段将填充来自 Unstructured Loader 的数据。

惰性加载

内部代码与 PowerScale 和 MetadataIQ 的交互全部是异步的,load 和 lazy_load 方法将返回一个 Python 生成器。建议使用惰性加载函数。
for doc in loader.lazy_load():
    print(doc)  # do something specific with the document
返回的 Document 与 load 函数相同,具有上述所有相同属性。

更多示例

更多示例和代码请参阅我们的公共 GitHub 页面:https://github.com/dell/powerscale-rag-connector/tree/main/examples,其中提供了完整的工作示例。

API 参考

有关 PowerScale 文档加载器所有特性和配置的详细文档,请访问 GitHub 页面:https://github.com/dell/powerscale-rag-connector/