techleadhd / chatgpt-retrieval

1.65k stars 786 forks source link

explicitlyspecify a vectorstore when using VectorstoreIndexCreator #62

Open Zhi0467 opened 1 month ago

Zhi0467 commented 1 month ago

I ran into this error when running chatgpt.py. all dependencies seem to be installed properly, see the following error message:

/Users/wangzhi/anaconda3/envs/chat/lib/python3.12/site-packages/langchain/indexes/vectorstore.py:129: UserWarning: Using InMemoryVectorStore as the default vectorstore.This memory store won't persist data. You should explicitlyspecify a vectorstore when using VectorstoreIndexCreator warnings.warn( Traceback (most recent call last): File "/Users/wangzhi/Desktop/chatgpt-retrieval/chatgpt.py", line 32, in <module> index = VectorstoreIndexCreator(vectorstore_kwargs={"persist_directory":"persist"}).from_loaders([loader]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/wangzhi/anaconda3/envs/chat/lib/python3.12/site-packages/pydantic/v1/main.py", line 341, in __init__ raise validation_error pydantic.v1.error_wrappers.ValidationError: 1 validation error for VectorstoreIndexCreator embedding field required (type=value_error.missing)

how should I fix this part of the code? `else:

loader = TextLoader("data/data.txt") # Use this line if you only need data.txt

loader = DirectoryLoader("data/") if PERSIST: index = VectorstoreIndexCreator(vectorstore_kwargs={"persist_directory":"persist"}).from_loaders([loader]) else: index = VectorstoreIndexCreator().from_loaders([loader])`