Download conversation_memory.py from ShubhangiAg/Conversational_plot_generator: direct link, hf CLI and curl.
- Browser
- Download file 382 Bytes
-
https://huggingface.co/spaces/ShubhangiAg/Conversational_plot_generator/resolve/main/conversation_memory.py
- Command line
-
hf download hf://spaces/ShubhangiAg/Conversational_plot_generator/conversation_memory.py
-
curl -L -o conversation_memory.py https://huggingface.co/spaces/ShubhangiAg/Conversational_plot_generator/resolve/main/conversation_memory.py
382 Bytes
| from langchain.memory import ConversationBufferMemory | |
| def initialize_memory(): | |
| """Creates and returns an instance of conversational memory.""" | |
| return ConversationBufferMemory() | |
| def update_memory(memory, user_input): | |
| """Updates memory with user input.""" | |
| memory.save_context({"user": user_input}, {"AI": "Processing..."}) | |
| return memory.load_memory_variables({}) |