ix
ix copied to clipboard
Memory issue
I am trying to add memory to a chain. I want to use conversation summary buffer because the generated information is bound to get large.
Here is my configuration:
If I don't add the prompt I get this error: `UnboundLocalError cannot access local variable 'response' where it is not associated with a value'
When I add the prompt as shown I get:
ValidationError 1 validation error for ConversationSummaryBufferMemory root Got unexpected prompt input variables. The prompt expects ['history', 'input'], but it should have {'new_lines', 'summary'}. (type=value_error)
You can see that the config has different field names than 'new_lines' and 'summary':
So then I tried the following prompt:
And was back to the error:
UnboundLocalError cannot access local variable 'response' where it is not associated with a value
The documentation seems to expect dict input somewhere so I am not sure how to use that info: https://github.com/kreneskyp/ix/blob/master/docs/chains/memory.rst
I noticed that the Pirate Chain uses the same memory buffer so I changed my settings to the same. I also took out the prompt since pirate didn't use one. This removed the error but the memory doesn't work. It is more forgetful than my cat.
Here are related docs for adding memory to the OpenAIFunctionsAgent. https://python.langchain.com/docs/modules/agents/how_to/add_memory_openai_functions
The example in the docs use a MessagesPlaceholder
to add the memory variable to the agent's template. Need to implement something similar here.
One possible option is updating the agent loader to add a MessagesPlaceholder
to agent_kwargs
when a memory class is connected and there isn't a custom prompt.