mem0 icon indicating copy to clipboard operation
mem0 copied to clipboard

bug: `query` knows and uses `history` from `chat`

Open cachho opened this issue 2 years ago • 1 comments

🐛 Describe the bug

If you use the chat method, the history is stored persistently in the Llm app-subclass. If query is used in the same script after chat, it also uses that history, because it assumes that you set this as custom history, which is supported behavior.

I'm really not sure how to fix this, other than splitting history in to history and custom_history.

If we just said that we only want to support history that's added directly as an argument to the query method, we'd probably have to:

  1. serialize it
  2. save the serial
  3. delete the history
  4. replace it with the history from arguments
  5. restore the saved serial after the method run

This adds complexity and makes it slower. We also couldn't use the app.llm.set_history method anymore, this method is really good for managing custom history. So splitting into history and custom_history seems like the better option.

Open for suggestions.

cachho avatar Sep 13 '23 07:09 cachho

I think the offered option makes a lot of sense. However, history (without any adjectives) is a bit ambiguous since contrast has to be made with custom_history to understand what's going on. I'd go for chat_history and query_history instead, which clearly shows the intent of which method it is supposed to be used with.

mtsoltan avatar Sep 19 '23 00:09 mtsoltan