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

LLMChain build error:RedisCache only accepts values that can be pickled. #1324

Closed
lsg328 opened this issue Jan 11, 2024 · 11 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@lsg328
Copy link

lsg328 commented Jan 11, 2024

Describe the bug
Using ChatOpenAi/OpenAi to create LLMChain, an error occurs when compiling:
RedisCache only accepts values that can be pickled.
TypeError("cannot pickle '_thread.RLock' object")

Version
0.6.4

Screenshots
image

Log
log.txt

Copy link

dosubot bot commented Jan 11, 2024

🤖

Hello @lsg328! I'm Dosu, a friendly bot here to assist you while a human maintainer becomes available. I'm designed to help you work out bugs, answer your queries, and guide you through contributing to the project. Don't hesitate to ask any questions you have while we work on this together. Looking forward to helping you get this sorted!

The error "RedisCache only accepts values that can be pickled" typically occurs when you're trying to store a value in Redis that can't be serialized (or "pickled") into a format that Redis can store.

In the context of the provided code, this could potentially happen if the documents or embedding passed to the Redis.from_documents method can't be pickled.

The documents parameter is expected to be of type Optional[Document] and the embedding parameter is expected to be of type Embeddings. If the actual objects passed do not conform to these types or contain non-picklable attributes, you might encounter this error.

To resolve this issue, you should ensure that the documents and embedding objects passed to the Redis.from_documents method are picklable. This might involve modifying the Document or Embeddings classes or the way you're creating instances of these classes.

If you're not sure whether an object is picklable, you can test it using Python's built-in pickle module:

import pickle

try:
    pickle.dumps(your_object)
except (pickle.PicklingError, TypeError):
    print("This object is not picklable")

Replace your_object with the object you want to test. If the object is not picklable, this code will print "This object is not picklable".

Unfortunately, I wasn't able to find the structure of the Document and Embeddings classes used in the Redis.from_documents method in the langflow codebase. If you could provide more information about these classes or the way you're creating instances of these classes, I might be able to provide more specific advice.

You can find more information about the Redis.from_documents method in the src/backend/langflow/components/vectorstores/Redis.py file in the langflow repository.

I hope this helps! If you have any other questions, feel free to ask.

-Dosu

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@dosubot dosubot bot added the bug Something isn't working label Jan 11, 2024
@lsg328
Copy link
Author

lsg328 commented Jan 12, 2024

I located the langchain_community.chat_models.openai.ChatOpenAI class and reported an error when pickled. This error does not occur in 0.5.12.
image

@ogabrielluiz
Copy link
Contributor

Hey @lsg328

Yeah.. this is a problem we encountered after on openai's package after 1.0 because there's a thread lock object that blocks the dump. This is definitely fixable but requires quite a bit of testing.

We need to implement how the Vertex object serializes.

@lsg328
Copy link
Author

lsg328 commented Feb 27, 2024

@ogabrielluiz Thank you for your reply, looking forward to your good news

@YamonBot
Copy link
Contributor

We are also facing the same issue. We kindly ask for your assistance.

@nhha1602
Copy link

Hi,

Do we have any workaround solution to fix this issue ?

Thanks.

@iam-dev0
Copy link

I'm facing the same issue. Any workaround or should I downgrade to 0.5.12?

@iam-dev0
Copy link

A workaround that worked is setting LANGFLOW_CACHE_TYPE=memory so the backend won't use redis.

@anovazzi1
Copy link
Contributor

Hello,
Sorry for the delay. Did you try using the new version? Does the error still persist?

@carlosrcoelho
Copy link
Contributor

Hi @lsg328 ,


We hope you're doing well. Just a friendly reminder that if we do not hear back from you within the next 3 days, we will close this issue. If you need more time or further assistance, please let us know.


Thank you for your understanding!

@carlosrcoelho carlosrcoelho self-assigned this Jul 22, 2024
@carlosrcoelho
Copy link
Contributor

Thank you for your contribution! This issue will be closed. If you have any questions or encounter another problem, please open a new issue and we will be ready to assist you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants