Spaces:
Runtime error
Runtime error
Download short_term_memory.py from AumCoreAI/AumCore-AI: direct link, hf CLI and curl.
- Browser
- Download file 503 Bytes
-
https://huggingface.co/spaces/AumCoreAI/AumCore-AI/resolve/refs%2Fpr%2F1/short_term_memory.py
- Command line
-
hf download hf://spaces/AumCoreAI/AumCore-AI@refs/pr/1/short_term_memory.py
-
curl -L -o short_term_memory.py https://huggingface.co/spaces/AumCoreAI/AumCore-AI/resolve/refs%2Fpr%2F1/short_term_memory.py
503 Bytes
| # short_term_memory.py - Recent Chat Buffer | |
| from collections import deque | |
| class ShortTermMemory: | |
| def __init__(self, max_size=10): | |
| self.memory = deque(maxlen=max_size) | |
| def add(self, user_input, ai_response): | |
| self.memory.append({ | |
| "user": user_input, | |
| "ai": ai_response, | |
| "timestamp": datetime.now().isoformat() | |
| }) | |
| def get_context(self): | |
| return list(self.memory) | |
| def clear(self): | |
| self.memory.clear() | |