EmptyMemoryWarning
ChatHistoryBlock
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:
- storage (BaseKeyValueStorage, optional): A storage mechanism for storing chat history. If
None
, an :obj:InMemoryKeyValueStorage
will be used. (default: :obj:None
) - keep_rate (float, optional): In historical messages, the score of the last message is 1.0, and with each step taken backward, the score of the message is multiplied by the
keep_rate
. Higherkeep_rate
leads to high possibility to keep history messages during context creation. (default: :obj:0.9
)
init
retrieve
- window_size (int, optional): Specifies the number of recent chat messages to retrieve. If not provided, the entire chat history will be retrieved. (default: :obj:
None
)
write_records
- records (List[MemoryRecord]): Memory records to be added to the memory.