Replies: 5 comments 4 replies
-
🤖 Hello, To add memory to the SQL agent in LangChain, you can use the Here is how you can use this method: # Create an instance of ConversationBufferMemory
memory = ConversationBufferMemory(memory_key="foo")
# Save context
memory.save_context({"input": "bar"}, {"output": "foo"}) The In the context shared, MongoDB is used as a message store for the # setup MongoDB as a message store
message_history = MongoDBChatMessageHistory(
connection_string=connection_string, session_id="test-session"
)
memory = ConversationBufferMemory(
memory_key="baz", chat_memory=message_history, return_messages=True
)
# add some messages
memory.chat_memory.add_ai_message("This is me, the AI")
memory.chat_memory.add_user_message("This is me, the human") Please note that the SQLDatabaseToolkit is not mentioned in the provided context, so it's unclear how it interacts with the For more information, you can refer to the following sources:
I hope this helps! If you have any other questions or need further clarification, feel free to ask. Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
-
Does anyone have right code snippet that is working with sqldatabasechain ? please provide the right input. |
Beta Was this translation helpful? Give feedback.
-
Any update on this? |
Beta Was this translation helpful? Give feedback.
-
Probably a bit too late but here is the right code:
I see that the chat history is maintained when I run agent_executor.invoke(input). |
Beta Was this translation helpful? Give feedback.
-
Try using a different model, sometimes the open source models don't work well. Your best bet are closed source frontier models. Try Openai or Claude. They are in my opinion some of the best option out there. |
Beta Was this translation helpful? Give feedback.
-
I have been trying to add memory to the SQL agent and have ran to various problems, for what I could see in different discussion #6918 , #7546 and others have to a conclusion there is no exact way, at the moment, to have an agent that responds, querys from a database, and keeps the history and remembers the context to answer the next question and keep querying. At least in my case, and with the use of the SQLDatabaseToolkit just seemed to complicate things.
Beta Was this translation helpful? Give feedback.
All reactions