Spaces:
Build error
Build error
Download lagent/memory/manager.py from luckDW1126/Lagent: direct link, hf CLI and curl.
- Browser
- Download file 888 Bytes
-
https://huggingface.co/spaces/luckDW1126/Lagent/resolve/main/lagent/memory/manager.py
- Command line
-
hf download hf://spaces/luckDW1126/Lagent/lagent/memory/manager.py
-
curl -L -o manager.py https://huggingface.co/spaces/luckDW1126/Lagent/resolve/main/lagent/memory/manager.py
888 Bytes
| from typing import Dict | |
| from ..utils import create_object | |
| from .base_memory import Memory | |
| class MemoryManager: | |
| def __init__(self, cfg) -> None: | |
| self.cfg = cfg | |
| self.memory_map: Dict[str, Memory] = {} | |
| def create_instance(self, session_id): | |
| self.memory_map[session_id] = create_object(self.cfg) | |
| def get_memory(self, session_id=0, **kwargs) -> list: | |
| return self.memory_map[session_id].get_memory(**kwargs) | |
| def add(self, memory, session_id=0, **kwargs) -> None: | |
| if session_id not in self.memory_map: | |
| self.create_instance(session_id) | |
| self.memory_map[session_id].add(memory, **kwargs) | |
| def get(self, session_id=0) -> Memory: | |
| return self.memory_map.get(session_id, None) | |
| def reset(self, session_id=0) -> None: | |
| if session_id in self.memory_map: | |
| del self.memory_map[session_id] | |