langchain/templates/csv-agent/ingest.py

13 lines
405 B
Python
Raw Normal View History

from langchain.indexes import VectorstoreIndexCreator
from langchain_community.document_loaders import CSVLoader
from langchain_community.vectorstores import FAISS
2023-10-29 22:50:09 +00:00
loader = CSVLoader("/Users/harrisonchase/Downloads/titanic.csv")
docs = loader.load()
index_creator = VectorstoreIndexCreator(vectorstore_cls=FAISS)
index = index_creator.from_documents(docs)
index.vectorstore.save_local("titanic_data")