I want to pickle/save my VectorStore index in LangChain. Below is my code:
import pickle from langchain.document_loaders import PyPDFLoader from langchain.indexes import VectorstoreIndexCreator # Load the PDF file pdf_path = "Los Angeles County, CA Code of Ordinances.pdf" loader = PyPDFLoader(pdf_path) # Create the index index = VectorstoreIndexCreator().from_loaders([loader]) # Serialize and save the loader and index objects with open("data.pickle", "wb") as f: pickle.dump((loader, index), f) # To load the objects from the file: with open("data.pickle", "rb") as f: loader, index = pickle.load(f) but when I run it I get this error:
~/LangChain-exploredoc-explore$ python pickle_file.py Using embedded DuckDB without persistence: data will be transient Traceback (most recent call last): File "/home/runner/LangChain-exploredoc-explore/pickle_file.py", line 14, in <module> pickle.dump((index), f) TypeError: cannot pickle 'duckdb.DuckDBPyConnection' object Related questions 691 How can I use pickle to save a dict (or any other Python object)? 0 How can I save an Object like an Image Classifier prepared using Keras to my any file using Python? 1 TypeError: can't pickle _thread.RLock objects ( Deep Learning) Related questions 691 How can I use pickle to save a dict (or any other Python object)? 0 How can I save an Object like an Image Classifier prepared using Keras to my any file using Python? 1 TypeError: can't pickle _thread.RLock objects ( Deep Learning) 1 How to substitute module.Class() to locally defined Class() when loading with Python's Pickle? 1 How to remove an object stored in a Pickle file with Python 10 TypeError: can't pickle _thread.RLock objects 1 Use python3 pickle to serialize custom object from and unserialize it in python2 Load 4 more related questions Show fewer related questions
Reset to default