ContextSummarizerToolkit
- Intelligent context compression with over-compression prevention
- Markdown file storage with session management
- Simple text-based search through conversation history
- Configurable summarization prompts
- Context loading and saving capabilities
init
- agent (ChatAgent): The agent that is using the toolkit. This is required to access the agent’s memory.
- working_directory (str, optional): The directory path where notes will be stored. If not provided, a default directory will be used.
- timeout (Optional[float]): The timeout for the toolkit.
- summary_prompt_template (Optional[str]): Custom prompt template for summarization. If None, a default task-focused template is used. Users can customize this for different use cases.
_setup_storage
_summarize_messages
- memory_records (
List["MemoryRecord"]
): A list of memory records to summarize.
_save_summary
- summary (str): The summary text to save.
_save_history
- memory_records (
List["MemoryRecord"]
): The list of memory records to save.
_compress_and_save
- memory_records (
List["MemoryRecord"]
): The memory records to compress and save.
_load_summary
_load_history
_format_conversation
- memory_records (
List["MemoryRecord"]
): A list of memory records to format.
_create_summary_prompt
- conversation_text (str): The formatted conversation to summarize.
summarize_full_conversation_history
_refresh_context_with_summary
- summary (str): The summary of the conversation history.
get_conversation_memory_info
search_full_conversation_history
- keywords (List[str]): List of keywords to search for. The keywords must be explicitly related to the information the user is looking for, and not general terms that might be found about any topic. For example, if the user is searching for the price of the flight to “Paris” which was discussed previously, the keywords should be [“Paris”, “price”, “flight”, ”$”, “costs”].
- top_k (int): The number of results to return (default 4).
should_compress_context
- message_limit (int): Maximum number of messages before compression.
- token_limit (Optional[int]): Maximum number of tokens before compression.
reset
get_current_summary
set_summary
- summary (str): The summary to store.