Move ChatMemory protocol to components.memory; rename files to use "_" convention for implementations. (#101)

This commit is contained in:
Eric Zhu
2024-06-21 04:06:01 -07:00
committed by GitHub
parent d365a588cb
commit 51dde2916f
22 changed files with 110 additions and 111 deletions

View File

@@ -0,0 +1,3 @@
from ._base import ChatMemory
__all__ = ["ChatMemory"]

View File

@@ -0,0 +1,19 @@
from typing import List, Mapping, Protocol, TypeVar
T = TypeVar("T")
class ChatMemory(Protocol[T]):
"""A protocol for defining the interface of a chat memory. A chat memory
lets agents store and retrieve messages. It can be implemented with
different memory recall strategies."""
async def add_message(self, message: T) -> None: ...
async def get_messages(self) -> List[T]: ...
async def clear(self) -> None: ...
def save_state(self) -> Mapping[str, T]: ...
def load_state(self, state: Mapping[str, T]) -> None: ...