The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
chore(text-splitters): remove arg types from docstrings (#33406)
Christophe Bornet83901b30e3eb
diff --git a/libs/text-splitters/langchain_text_splitters/base.py b/libs/text-splitters/langchain_text_splitters/base.pyindex 21d2a06c48..44221aa21c 100644--- a/libs/text-splitters/langchain_text_splitters/base.py+++ b/libs/text-splitters/langchain_text_splitters/base.py@@ -276,10 +276,10 @@ class TokenTextSplitter(TextSplitter):`split_text_on_tokens` function.Args:- text (str): The input text to be split into smaller chunks.+ text: The input text to be split into smaller chunks.Returns:- List[str]: A list of text chunks, where each chunk is derived from a portion+ A list of text chunks, where each chunk is derived from a portionof the input text based on the tokenization and chunking rules."""diff --git a/libs/text-splitters/langchain_text_splitters/character.py b/libs/text-splitters/langchain_text_splitters/character.pyindex 9a073520e4..22736f1df5 100644--- a/libs/text-splitters/langchain_text_splitters/character.py+++ b/libs/text-splitters/langchain_text_splitters/character.py@@ -143,10 +143,10 @@ class RecursiveCharacterTextSplitter(TextSplitter):"""Split the input text into smaller chunks based on predefined separators.Args:- text (str): The input text to be split.+ text: The input text to be split.Returns:- List[str]: A list of text chunks obtained after splitting.+ A list of text chunks obtained after splitting."""return self._split_text(text, self._separators)@@ -159,12 +159,11 @@ class RecursiveCharacterTextSplitter(TextSplitter):This method initializes the text splitter with language-specific separators.Args:- language (Language): The language to configure the text splitter for.- **kwargs (Any): Additional keyword arguments to customize the splitter.+ language: The language to configure the text splitter for.+ **kwargs: Additional keyword arguments to customize the splitter.Returns:- RecursiveCharacterTextSplitter: An instance of the text splitter configured- for the specified language.+ An instance of the text splitter configured for the specified language."""separators = cls.get_separators_for_language(language)return cls(separators=separators, is_separator_regex=True, **kwargs)@@ -174,10 +173,10 @@ class RecursiveCharacterTextSplitter(TextSplitter):"""Retrieve a list of separators specific to the given language.Args:- language (Language): The language for which to get the separators.+ language: The language for which to get the separators.Returns:- List[str]: A list of separators appropriate for the specified language.+ A list of separators appropriate for the specified language."""if language in {Language.C, Language.CPP}:return [diff --git a/libs/text-splitters/langchain_text_splitters/html.py b/libs/text-splitters/langchain_text_splitters/html.pyindex 179b110ab9..d47dbdd24c 100644--- a/libs/text-splitters/langchain_text_splitters/html.py+++ b/libs/text-splitters/langchain_text_splitters/html.py@@ -353,7 +353,7 @@ class HTMLSectionSplitter:headers_to_split_on: list of tuples of headers we want to track mapped to(arbitrary) keys for metadata. Allowed header values: h1, h2, h3, h4,h5, h6 e.g. [("h1", "Header 1"), ("h2", "Header 2"].- **kwargs (Any): Additional optional arguments for customizations.+ **kwargs: Additional optional arguments for customizations."""self.headers_to_split_on = dict(headers_to_split_on)@@ -408,7 +408,7 @@ class HTMLSectionSplitter:contains the header text, content under the header, and the tag name.Args:- html_doc (str): The HTML document to be split into sections.+ html_doc: The HTML document to be split into sections.Returns:A list of dictionaries representing sections. Each dictionary contains:@@ -464,10 +464,10 @@ class HTMLSectionSplitter:the HTML content is returned unchanged.Args:- html_content (str): The HTML content to be transformed.+ html_content: The HTML content to be transformed.Returns:- str: The transformed HTML content as a string.+ The transformed HTML content as a string."""if not _HAS_LXML:msg = "Unable to import lxml, please install with `pip install lxml`."@@ -677,10 +677,10 @@ class HTMLSemanticPreservingSplitter(BaseDocumentTransformer):"""Splits the provided HTML text into smaller chunks based on the configuration.Args:- text (str): The HTML content to be split.+ text: The HTML content to be split.Returns:- List[Document]: A list of Document objects containing the split content.+ A list of Document objects containing the split content."""soup = BeautifulSoup(text, "html.parser")@@ -779,10 +779,10 @@ class HTMLSemanticPreservingSplitter(BaseDocumentTransformer):"""Normalizes the text by removing extra spaces and newlines.Args:- text (str): The text to be normalized.+ text: The text to be normalized.Returns:- str: The normalized text.+ The normalized text."""if self._normalize_text:text = text.lower()@@ -939,13 +939,12 @@ class HTMLSemanticPreservingSplitter(BaseDocumentTransformer):"""Creates Document objects from the provided headers, content, and elements.Args:- headers (dict): The headers to attach as metadata to the Document.- content (str): The content of the Document.- preserved_elements (dict): Preserved elements to be reinserted- into the content.+ headers: The headers to attach as metadata to the Document.+ content: The content of the Document.+ preserved_elements: Preserved elements to be reinserted into the content.Returns:- List[Document]: A list of Document objects.+ A list of Document objects."""content = re.sub(r"\s+", " ", content).strip()@@ -964,13 +963,12 @@ class HTMLSemanticPreservingSplitter(BaseDocumentTransformer):"""Further splits the content into smaller chunks.Args:- content (str): The content to be split.- metadata (dict): Metadata to attach to each chunk.- preserved_elements (dict): Preserved elements- to be reinserted into each chunk.+ content: The content to be split.+ metadata: Metadata to attach to each chunk.+ preserved_elements: Preserved elements to be reinserted into each chunk.Returns:- List[Document]: A list of Document objects containing the split content.+ A list of Document objects containing the split content."""splits = self._recursive_splitter.split_text(content)result = []@@ -995,11 +993,11 @@ class HTMLSemanticPreservingSplitter(BaseDocumentTransformer):"""Reinserts preserved elements into the content into their original positions.Args:- content (str): The content where placeholders need to be replaced.- preserved_elements (dict): Preserved elements to be reinserted.+ content: The content where placeholders need to be replaced.+ preserved_elements: Preserved elements to be reinserted.Returns:- str: The content with placeholders replaced by preserved elements.+ The content with placeholders replaced by preserved elements."""for placeholder, preserved_content in preserved_elements.items():content = content.replace(placeholder, preserved_content.strip())diff --git a/libs/text-splitters/langchain_text_splitters/markdown.py b/libs/text-splitters/langchain_text_splitters/markdown.pyindex c793d7b821..46b1ad0c80 100644--- a/libs/text-splitters/langchain_text_splitters/markdown.py+++ b/libs/text-splitters/langchain_text_splitters/markdown.py@@ -367,10 +367,10 @@ class ExperimentalMarkdownSyntaxTextSplitter:horizontal rules.Args:- text (str): The input text to be split into chunks.+ text: The input text to be split into chunks.Returns:- List[Document]: A list of `Document` objects representing the structured+ A list of `Document` objects representing the structuredchunks of the input text. If `return_each_line` is enabled, each lineis returned as a separate `Document`."""diff --git a/libs/text-splitters/langchain_text_splitters/sentence_transformers.py b/libs/text-splitters/langchain_text_splitters/sentence_transformers.pyindex 433adef205..1e14d61f32 100644--- a/libs/text-splitters/langchain_text_splitters/sentence_transformers.py+++ b/libs/text-splitters/langchain_text_splitters/sentence_transformers.py@@ -65,11 +65,11 @@ class SentenceTransformersTokenTextSplitter(TextSplitter):processed segments as a list of strings.Args:- text (str): The input text to be split.+ text: The input text to be split.Returns:- List[str]: A list of string components derived from the input text after- encoding and processing.+ A list of string components derived from the input text after encoding and+ processing."""def encode_strip_start_and_stop_token_ids(text: str) -> list[int]:@@ -91,7 +91,7 @@ class SentenceTransformersTokenTextSplitter(TextSplitter):calculates the total number of tokens in the encoded result.Args:- text (str): The input text for which the token count is calculated.+ text: The input text for which the token count is calculated.Returns:int: The number of tokens in the encoded text.diff --git a/libs/text-splitters/tests/unit_tests/test_text_splitters.py b/libs/text-splitters/tests/unit_tests/test_text_splitters.pyindex a43a7435e3..4651f84644 100644--- a/libs/text-splitters/tests/unit_tests/test_text_splitters.py+++ b/libs/text-splitters/tests/unit_tests/test_text_splitters.py@@ -2580,12 +2580,12 @@ def test_html_header_text_splitter("""Test the HTML header text splitter.Args:- html_header_splitter_splitter_factory (Any): Factory function to create- the HTML header splitter.- headers_to_split_on (List[Tuple[str, str]]): List of headers to split on.- html_input (str): The HTML input string to be split.- expected_documents (List[Document]): List of expected Document objects.- test_case (str): Description of the test case.+ html_header_splitter_splitter_factory : Factory function to create the HTML+ header splitter.+ headers_to_split_on: List of headers to split on.+ html_input: The HTML input string to be split.+ expected_documents: List of expected Document objects.+ test_case: Description of the test case.Raises:AssertionError: If the number of documents or their content/metadata@@ -2736,12 +2736,12 @@ def test_additional_html_header_text_splitter("""Test the HTML header text splitter.Args:- html_header_splitter_splitter_factory (Any): Factory function to create- the HTML header splitter.- headers_to_split_on (List[Tuple[str, str]]): List of headers to split on.- html_content (str): HTML content to be split.- expected_output (List[Document]): Expected list of Document objects.- test_case (str): Description of the test case.+ html_header_splitter_splitter_factory: Factory function to create the HTML+ header splitter.+ headers_to_split_on: List of headers to split on.+ html_content: HTML content to be split.+ expected_output: Expected list of Document objects.+ test_case: Description of the test case.Raises:AssertionError: If the number of documents or their content/metadata@@ -2808,13 +2808,12 @@ def test_html_no_headers_with_multiple_splitters("""Test HTML content splitting without headers using multiple splitters.Args:- html_header_splitter_splitter_factory (Any): Factory to create the- HTML header splitter.- headers_to_split_on (List[Tuple[str, str]]): List of headers to split on.- html_content (str): HTML content to be split.- expected_output (List[Document]): Expected list of Document objects- after splitting.- test_case (str): Description of the test case.+ html_header_splitter_splitter_factory: Factory to create the HTML header+ splitter.+ headers_to_split_on: List of headers to split on.+ html_content: HTML content to be split.+ expected_output: Expected list of Document objects after splitting.+ test_case: Description of the test case.Raises:AssertionError: If the number of documents or their content/metadata