Spaces:
Sleeping
Sleeping
Download chat_memory.py from abstikatech/AbstikaAI: direct link, hf CLI and curl.
- Browser
- Download file 354 Bytes
-
https://huggingface.co/spaces/abstikatech/AbstikaAI/resolve/main/chat_memory.py
- Command line
-
hf download hf://spaces/abstikatech/AbstikaAI/chat_memory.py
-
curl -L -o chat_memory.py https://huggingface.co/spaces/abstikatech/AbstikaAI/resolve/main/chat_memory.py
354 Bytes
| from collections import defaultdict | |
| # In-memory chat storage | |
| chat_histories = defaultdict(list) | |
| def get_history_for_user(user_id: str): | |
| return chat_histories[user_id] | |
| def store_interaction(user_id: str, user_msg: str, assistant_msg: str): | |
| chat_histories[user_id].append({ | |
| "user": user_msg, | |
| "assistant": assistant_msg | |
| }) | |