Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use RecursiveJsonSplitter when learning JSON files #1036

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/jupyter-ai/jupyter_ai/chat_handlers/learn.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
MarkdownTextSplitter,
PythonCodeTextSplitter,
RecursiveCharacterTextSplitter,
RecursiveJsonSplitter,
)
from langchain_community.vectorstores import FAISS

Expand Down Expand Up @@ -83,15 +84,15 @@ def __init__(self, *args, **kwargs):
action="store",
default=DEFAULT_CHUNK_SIZE,
type=int,
help="Max number of characters in chunk",
help="Maximum number of characters per chunk. This argument is not supported on JSON files.",
)
self.parser.add_argument(
"-o",
"--chunk-overlap",
action="store",
default=DEFAULT_CHUNK_OVERLAP,
type=int,
help="Number of characters overlapping between chunks, helpful to ensure text is not split mid-word or mid-sentence",
help="Number of characters that may overlap between chunks, which can help ensure a document is not split mid-word or mid-sentence. This argument is not supported on JSON files.",
)
self.parser.add_argument("path", nargs=argparse.REMAINDER)
self.index_name = "default"
Expand Down Expand Up @@ -240,6 +241,7 @@ async def learn_dir(
".md": MarkdownTextSplitter(**splitter_kwargs),
".tex": LatexTextSplitter(**splitter_kwargs),
".ipynb": NotebookSplitter(**splitter_kwargs),
".json": RecursiveJsonSplitter(),
}
splitter = ExtensionSplitter(
splitters=splitters,
Expand Down
Loading