Spaces:
Runtime error
Runtime error
Download src/agents/memory/memory_manager.py from NandiniKodali/smartmatch: direct link, hf CLI and curl.
- Browser
- Download file 797 Bytes
-
https://huggingface.co/spaces/NandiniKodali/smartmatch/resolve/main/src/agents/memory/memory_manager.py
- Command line
-
hf download hf://spaces/NandiniKodali/smartmatch/src/agents/memory/memory_manager.py
-
curl -L -o memory_manager.py https://huggingface.co/spaces/NandiniKodali/smartmatch/resolve/main/src/agents/memory/memory_manager.py
797 Bytes
| class MemoryManager: | |
| """ | |
| Simple in-memory storage for conversation history. | |
| """ | |
| def __init__(self): | |
| self.history = [] | |
| def add(self, user_input: str, grounding_output: dict): | |
| """ | |
| Store a new interaction. | |
| """ | |
| self.history.append({ | |
| "user_input": user_input, | |
| "grounding_output": grounding_output | |
| }) | |
| def get_last(self): | |
| """ | |
| Get the most recent grounding output. | |
| """ | |
| if not self.history: | |
| return None | |
| return self.history[-1]["grounding_output"] | |
| def get_all(self): | |
| """ | |
| Get full conversation history. | |
| """ | |
| return self.history | |
| def clear(self): | |
| """ | |
| Reset memory. | |
| """ | |
| self.history = [] |