检测到一个不符合Unstructured模式的JSON文件,partition_json目前仅处理使用langchain S3DirectoryLoader序列化的Unstructured输出,

xmjla07d  于 2个月前  发布在  其他
关注(0)|答案(3)|浏览(43)

检查其他资源

  • 为这个问题添加了一个非常描述性的标题。
  • 使用集成搜索在LangChain文档中进行了搜索。
  • 使用GitHub搜索找到了一个类似的问题,但没有找到。
  • 我确信这是LangChain中的一个bug,而不是我的代码。
  • 通过更新到LangChain的最新稳定版本(或特定集成包)无法解决此bug。

示例代码

loader = S3DirectoryLoader(bucket=s3_bucket_name, prefix=s3_prefix)
 try:
 documents = loader.load()
 logging.info(f"size of the loaded documents {len(documents)}")
except Exception as e:
    logging.info(f"error loading documents: {e}")

错误信息和堆栈跟踪(如果适用)

检测到一个不符合Unstructured模式的JSON文件。partition_json目前仅处理序列化的Unstructured输出。

doc = loader.load()
^^^^^^^^^^^^^
File "/prj/.venv/lib/python3.12/site-packages/langchain_community/document_loaders/s3_directory.py", line 139, in load
 docs.extend(loader.load())
^^^^^^^^^^^^^^^^^^^^^^
File "/prj/.venv/lib/python3.12/site-packages/langchain_core/document_loaders/base.py", line 30, in load
 return list(self.lazy_load())
^^^^^^^^^^^^^^^^^^^^^^
File "/prj/.venv/lib/python3.12/site-packages/langchain_community/document_loaders/unstructured.py", line 89, in lazy_load
 elements = self._get_elements()
^^^^^^^^^^^^^^^^^^^^
File "/prj/.venv/lib/python3.12/site-packages/langchain_community/document_loaders/s3_file.py", line 135, in _get_elements
 return partition(filename=file_path, **self.unstructured_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\
File "/prj/.venv/lib/python3.12/site-packages/unstructured/partition/auto.py", line 389, in partition
 raise ValueError(
ValueError: Detected a JSON file that does not conform to the Unstructured schema. partition_json currently only processes serialized Unstructured output.

描述

我的S3存储桶有一个文件夹,该文件夹包含json文件。
存储桶名称:"abc-bc-name"
前缀:"output"
文件内容是json格式:

{
 "abc": "This is a text json file",
 "source": " [https://asf.test/4865422_f4866011606d84f50d10e60e0b513b7](https://asf.test/4865422_f4866011606d84f50d10e60e0b513b7) ",
 "correlation_id": "4865422_f4866011606d84f50d10e60e0b513b7"
}
tjrkku2a

tjrkku2a2#

在这里也遇到了同样的问题。使用"langchain_community.document_loaders.S3DirectoryLoader"。

djmepvbi

djmepvbi3#

我上传了一个txt文件,也报了这个错误

相关问题