Home / Function/ create_documents() — langchain Function Reference

create_documents() — langchain Function Reference

Architecture documentation for the create_documents() function in json.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  66dd54d0_0fcc_541a_96cd_6fc946fe44a0["create_documents()"]
  6fcdab9c_3ecd_51f0_a2ae_3b0c8bfac048["RecursiveJsonSplitter"]
  66dd54d0_0fcc_541a_96cd_6fc946fe44a0 -->|defined in| 6fcdab9c_3ecd_51f0_a2ae_3b0c8bfac048
  66dd54d0_0fcc_541a_96cd_6fc946fe44a0["create_documents()"]
  66dd54d0_0fcc_541a_96cd_6fc946fe44a0 -->|calls| 66dd54d0_0fcc_541a_96cd_6fc946fe44a0
  03a7225b_8bf6_9fff_f8d4_0a36c276bded["split_text()"]
  66dd54d0_0fcc_541a_96cd_6fc946fe44a0 -->|calls| 03a7225b_8bf6_9fff_f8d4_0a36c276bded
  66dd54d0_0fcc_541a_96cd_6fc946fe44a0["create_documents()"]
  66dd54d0_0fcc_541a_96cd_6fc946fe44a0 -->|calls| 66dd54d0_0fcc_541a_96cd_6fc946fe44a0
  style 66dd54d0_0fcc_541a_96cd_6fc946fe44a0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/text-splitters/langchain_text_splitters/json.py lines 163–190

    def create_documents(
        self,
        texts: list[dict[str, Any]],
        convert_lists: bool = False,  # noqa: FBT001,FBT002
        ensure_ascii: bool = True,  # noqa: FBT001,FBT002
        metadatas: list[dict[Any, Any]] | None = None,
    ) -> list[Document]:
        """Create a list of `Document` objects from a list of json objects (`dict`).

        Args:
            texts: A list of JSON data to be split and converted into documents.
            convert_lists: Whether to convert lists to dictionaries before splitting.
            ensure_ascii: Whether to ensure ASCII encoding in the JSON strings.
            metadatas: Optional list of metadata to associate with each document.

        Returns:
            A list of `Document` objects.
        """
        metadatas_ = metadatas or [{}] * len(texts)
        documents = []
        for i, text in enumerate(texts):
            for chunk in self.split_text(
                json_data=text, convert_lists=convert_lists, ensure_ascii=ensure_ascii
            ):
                metadata = copy.deepcopy(metadatas_[i])
                new_doc = Document(page_content=chunk, metadata=metadata)
                documents.append(new_doc)
        return documents

Subdomains

Called By

Frequently Asked Questions

What does create_documents() do?
create_documents() is a function in the langchain codebase, defined in libs/text-splitters/langchain_text_splitters/json.py.
Where is create_documents() defined?
create_documents() is defined in libs/text-splitters/langchain_text_splitters/json.py at line 163.
What does create_documents() call?
create_documents() calls 2 function(s): create_documents, split_text.
What calls create_documents()?
create_documents() is called by 1 function(s): create_documents.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free