Skip to content

Commit

Permalink
force_chunk_size
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaMichlin committed Nov 23, 2023
1 parent 3177eff commit 6a992d3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions libs/langchain/langchain/text_splitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ def __init__(
self,
separators: Optional[List[str]] = None,
keep_separator: bool = True,
is_separator_regex: bool = True,
is_separator_regex: bool = False,
**kwargs: Any,
) -> None:
"""Create a new TextSplitter.
Expand All @@ -913,13 +913,16 @@ def __init__(
keep_separator: Whether to keep the separator in the chunks
is_separator_regex: Whether the separator is a regex
"""
if not separators:
separators = ["\s+"]
is_separator_regex = True

super().__init__(
separator="",
is_separator_regex=is_separator_regex,
keep_separator=keep_separator,
**kwargs,
)
separators = separators or ["\s+"]

# If the separator is a regex, we don't need to escape it.
if not self._is_separator_regex:
Expand Down

0 comments on commit 6a992d3

Please sign in to comment.