----------------------
Your code seems to be correct according to the examples provided in the knowledge sources. However, the error you're encountering typically happens when the parser is trying to find an element in a
None
object. This could be due to the HTML file not being loaded correctly or the file might not be well-formed.
Here are a few things you could check:
- Ensure the file
./R_LOS.html
exists in the correct directory and is accessible.
- Check if the file is a well-formed HTML file. You can use online HTML validators for this.
- Make sure you have installed all the necessary packages and dependencies.
If the problem persists, it might be a good idea to debug your code step by step to see where exactly the
None
object is coming from.
Here is your code for reference:
from llama_index.readers.file import FlatReader
from llama_index.core.node_parser import UnstructuredElementNodeParser
from llama_index.llms.openai import OpenAI
from llama_index.core import Settings
from pathlib import Path
Settings.llm = OpenAI(model='gpt-3.5-turbo')
reader = FlatReader()
files = reader.load_data(Path(r'./R_LOS.html'))
parser = UnstructuredElementNodeParser()
nodes = parser.get_nodes_from_documents(files)
If you're still having trouble, you might want to refer to the
LlamaIndex documentation () or seek help from the LlamaIndex community or support.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------