ix icon indicating copy to clipboard operation
ix copied to clipboard

Memory issue

Open gwc4github opened this issue 1 year ago • 2 comments

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: image

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': image

So then I tried the following prompt: image 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

gwc4github avatar Jul 27 '23 22:07 gwc4github

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.

gwc4github avatar Jul 27 '23 23:07 gwc4github

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.

kreneskyp avatar Jul 29 '23 20:07 kreneskyp