langflow icon indicating copy to clipboard operation
langflow copied to clipboard

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

Open lsg328 opened this issue 1 year ago • 6 comments

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

lsg328 avatar Jan 11 '24 13:01 lsg328

🤖

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[bot] avatar Jan 11 '24 13:01 dosubot[bot]

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

lsg328 avatar Jan 12 '24 02:01 lsg328

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.

ogabrielluiz avatar Jan 25 '24 20:01 ogabrielluiz

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

lsg328 avatar Feb 27 '24 10:02 lsg328

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

YamonBot avatar Feb 28 '24 01:02 YamonBot

Hi,

Do we have any workaround solution to fix this issue ?

Thanks.

nhha1602 avatar Mar 28 '24 04:03 nhha1602