Skip to content

Commit

Permalink
fix SimpleFileNodeParser throw error on unsupported extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
yukikwi committed Apr 29, 2024
1 parent 4091384 commit 9d83432
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions llama-index-core/llama_index/core/node_parser/file/simple_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
from typing import Any, Dict, List, Optional, Sequence, Type

from llama_index.core.callbacks.base import CallbackManager
from llama_index.core.node_parser.node_utils import build_nodes_from_splits
from llama_index.core.node_parser.file.html import HTMLNodeParser
from llama_index.core.node_parser.file.json import JSONNodeParser
from llama_index.core.node_parser.file.markdown import MarkdownNodeParser
from llama_index.core.node_parser.interface import NodeParser
from llama_index.core.schema import BaseNode
from llama_index.core.schema import BaseNode, MetadataMode
from llama_index.core.utils import get_tqdm_iterable
from llama_index.core.schema import TextNode

FILE_NODE_PARSERS: Dict[str, Type[NodeParser]] = {
".md": MarkdownNodeParser,
Expand Down Expand Up @@ -77,6 +79,15 @@ def _parse_nodes(
all_nodes.extend(nodes)
else:
# What to do when file type isn't supported yet?
all_nodes.extend(document)
all_nodes.extend(
# build node from document
build_nodes_from_splits(
[
document.get_content(metadata_mode=MetadataMode.NONE)
],
document,
id_func=self.id_func
)
)

return all_nodes

0 comments on commit 9d83432

Please sign in to comment.