Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot pickle '_thread.RLock' object #4

Open
sambantham-p opened this issue Nov 14, 2023 · 3 comments
Open

cannot pickle '_thread.RLock' object #4

sambantham-p opened this issue Nov 14, 2023 · 3 comments

Comments

@sambantham-p
Copy link

Traceback (most recent call last):
File "D:\news agent\venv\Lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 534, in _run_script
exec(code, module.dict)
File "D:\news agent\main.py", line 31, in
final = qa.qaretriever(question,urls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\news agent\qaretriever.py", line 35, in qaretriever
pickle.dump(vector_index, f)
TypeError: cannot pickle '_thread.RLock' object

@cabdelahad
Copy link

did you solve this ?

@HariPrasanth
Copy link

Hi, Were you able to solve this issue?

@HariPrasanth
Copy link

The answer is : We will have to use vectorstore methods only to dump into a file and retrieve it instead of using pickle

Just replaced the code

with open(file_path, "wb") as f:
    pickle.dump(vectorstore_openai, f)

With this line
vectorstore_openai.save_local("vectorstore")

And

replace this code
vectorstore = pickle.load(f)
with
vectorstore = FAISS.load_local("vectorstore", OpenAIEmbeddings(), allow_dangerous_deserialization=True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants