Base interface for memory in chains.
| 15 | |
| 16 | |
| 17 | class BaseMemory(BaseModel, ABC): |
| 18 | """Base interface for memory in chains.""" |
| 19 | |
| 20 | @abstractmethod |
| 21 | def load_memory( |
| 22 | self, key: Union[str, None] = None, default: Optional[Any] = None, **kwargs: Any |
| 23 | ) -> Any: |
| 24 | """Return key-value pairs given the text input to the chain.""" |
| 25 | |
| 26 | @abstractmethod |
| 27 | def load_conversation(self, **kwargs) -> ChatMessageHistory: |
| 28 | """Return key-value pairs given the text input to the chain.""" |
| 29 | |
| 30 | @abstractmethod |
| 31 | def save_memory(self, key: str, value: Any) -> None: |
| 32 | """Save the context of this model run to memory.""" |
| 33 | |
| 34 | @abstractmethod |
| 35 | def save_conversation( |
| 36 | self, message: str, message_type: MessageType, **kwargs |
| 37 | ) -> None: |
| 38 | """Save the context of this model run to memory.""" |
| 39 | |
| 40 | @abstractmethod |
| 41 | def clear(self) -> None: |
| 42 | """Clear memory contents.""" |
nothing calls this directly
no outgoing calls
no test coverage detected