MemoryBlock
write_records
- records (List[MemoryRecord]): Records to be added to the memory.
write_record
- record (MemoryRecord): Record to be added to the memory.
pop_records
- count (int): Number of records to remove.
remove_records_by_indices
- indices (List[int]): List of indices to remove. Indices should be valid positions in the current record list.
clear
BaseContextCreator
token_counter,:obj: token_limit,
and :obj:create_context methods to provide specific context creation
logic.
Parameters:
- token_counter (BaseTokenCounter): A token counter instance responsible for counting tokens in a message.
- token_limit (int): The maximum number of tokens allowed in the generated context.
token_counter
token_limit
create_context
- records (List[ContextRecord]): A list of context records from which to generate the context.
AgentMemory
MemoryBlock, uniquely designed for
direct integration with an agent. Two key abstract functions, “retrieve”
and “get_context_creator”, are used for generating model context based on
the memory records stored within the AgentMemory.
agent_id
agent_id
retrieve
get_context_creator
get_context
clean_tool_calls
repr
<id>)’
if agent_id exists, otherwise just ‘ClassName()’.