Home / Function/ split_text() — langchain Function Reference

split_text() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/text-splitters/langchain_text_splitters/json.py lines 141–161

    def split_text(
        self,
        json_data: dict[str, Any],
        convert_lists: bool = False,  # noqa: FBT001,FBT002
        ensure_ascii: bool = True,  # noqa: FBT001,FBT002
    ) -> list[str]:
        """Splits JSON into a list of JSON formatted strings.

        Args:
            json_data: The JSON data to be split.
            convert_lists: Whether to convert lists in the JSON to dictionaries
                before splitting.
            ensure_ascii: Whether to ensure ASCII encoding in the JSON strings.

        Returns:
            A list of JSON formatted strings.
        """
        chunks = self.split_json(json_data=json_data, convert_lists=convert_lists)

        # Convert to string
        return [json.dumps(chunk, ensure_ascii=ensure_ascii) for chunk in chunks]

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free