Find answers from the community

Updated 3 weeks ago

Error When Running Code With 'Index = VectorStoreIndex.From_Documents(Documents)'

Hello everyone, I got an error when running the following code. The wrong code is"index = VectorStoreIndex.from_documents(documents)", and the error content is"'str' object has no attribute 'data'",how can i deal with it?

from dotenv import load_dotenv
load_dotenv()

from llama_index.core import SimpleDirectoryReader
documents = SimpleDirectoryReader(r"data").load_data()
print(documents)

from llama_index.core import VectorStoreIndex
index = VectorStoreIndex.from_documents(documents)

agent = index.as_query_engine()
response = agent.query("what's my favorite game?")
print("what's my favorite game?", response)
index.storage_context.persist()
W
1 comment
Did this line print something?
print(documents)

Also can you share the whole error traceback?
Add a reply
Sign up and join the conversation on Discord