class ChatHistoryBlock(MemoryBlock):
MemoryBlock
abstract base class for
maintaining a record of chat histories.
This memory block helps manage conversation histories with a key-value
storage backend, either provided by the user or using a default
in-memory storage. It offers a windowed approach to retrieving chat
histories, allowing users to specify how many recent messages they’d
like to fetch.
Parameters:
None
, an :obj:InMemoryKeyValueStorage
will be used. (default: :obj:None
)keep_rate
. Higher keep_rate
leads to high possibility to keep history messages during context creation.def __init__(
self,
storage: Optional[BaseKeyValueStorage] = None,
keep_rate: float = 0.9
):
def retrieve(self, window_size: Optional[int] = None):
None
)def write_records(self, records: List[MemoryRecord]):
def clear(self):