Search code examples
pythonlangchainpy-langchain

`ConversationSummaryBufferMemory` is not fully defined; you should define `BaseCache`, then call `ConversationSummaryBufferMemory.model_rebuild()`


I am attempting to use LangChain's ConversationSummaryBufferMemory and running into this error:

pydantic.errors.PydanticUserError: `ConversationSummaryBufferMemory` is not fully defined; you should define `BaseCache`, then call `ConversationSummaryBufferMemory.model_rebuild()`.

This is what my code looks like:

memory = ConversationSummaryBufferMemory(
    llm=llm,
    input_key="input",
    output_key="output",
    max_token_limit=args.get("max_tokens", DEFAULT_MAX_TOKENS),
    memory_key="chat_history",
)

I am using langchain==0.3.7.

Has anyone else encountered this?


Solution

  • pydantic library has been updated. pip install pydantic==2.9.2 should help