Issue with Serializing and Deserializing LLM Chain vs Conversational Retrieval Chain in langchain_core.load.loads #26662
Replies: 3 comments 2 replies
-
The discrepancy occurs because the To resolve this issue, you need to ensure that the class ConversationalRetrievalChain(Serializable):
@classmethod
def is_lc_serializable(cls) -> bool:
"""Return whether this model can be serialized by Langchain."""
return True
# Your existing implementation of the class By overriding the For more details, you can refer to the implementation of the |
Beta Was this translation helpful? Give feedback.
-
I am using conversational buffer memory inside the conversational retrieval chain. After following the previous suggestion, I am now encountering a "not implemented" error for conversational buffer memory. |
Beta Was this translation helpful? Give feedback.
-
hello @dosu Even though I have changed the above method in the ConversationBufferMemory, I am still encountering the same error.
ERROR: NotImplementedError: Trying to load an object that doesn't implement serialization: {'lc': 1, 'type': 'not_implemented', 'id': ['main', 'CustomConversationBufferMemory'], 'repr': "CustomConversationBufferMemory(return_messages=True, memory_key='chat_history')"} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm encountering an issue while serializing and deserializing two chains: one is a standard LLM chain, and the other is a conversational retrieval chain. When I use langchain_core.load.loads to serialize the normal LLM chain, the object is of type "constructor" and works as expected. However, when I try to serialize the conversational retrieval chain using the same method, the object is of type "NotImplemented". This prevents me from deserializing the conversational chain after serialization. Could you provide insight into why this discrepancy occurs and how to resolve it?
conversational retrieval chain after serialization.
{
"lc": 1,
"type": "not_implemented",
"id": [
"langchain",
"chains",
"conversational_retrieval",
"base",
"ConversationalRetrievalChain"
]
Normal llm chain after serialization.
{
"lc": 1,
"type": "constructor",
"id": [
"langchain",
"schema",
"runnable",
"RunnableSequence"
]
error encountering when try to deserialize conversational retrieval chain :
NotImplementedError: Trying to load an object that doesn't implement serialization: {'lc': 1, 'type': 'not_implemented', 'id': ['langchain', 'chains', 'conversational_retrieval', 'base', 'ConversationalRetrievalChain']
Beta Was this translation helpful? Give feedback.
All reactions