|
Iragent
This project is about using agents as simple as possible with small and large language models
|
Public Member Functions | |
| None | __init__ (self, AgentFactory agent_factory, int memory_limit=10) |
| None | add_history (self, dict|list[dict] msg) |
Public Member Functions inherited from iragent.memory.BaseMemory | |
| None | __init__ (self) |
| list[dict] | get_history (self) |
| None | clear_history (self) |
| None | add_message (self, Message msg) |
| list[dict] | get_messages (self) |
| None | clear_messages (self) |
Public Attributes | |
| memory_limit = memory_limit | |
| summarizer | |
Public Attributes inherited from iragent.memory.BaseMemory | |
| list | history = [] |
| list | messages = [] |
Protected Member Functions | |
| _summarize_history (self) | |
A memory manager that summarizes conversation history when it exceeds a specified limit.
This class extends `BaseMemory` and adds summarization capabilities using a summarizer agent.
When the number of stored messages exceeds `memory_limit`, the full conversation history is
summarized into a compact representation and stored as a single system message.
Attributes:
memory_limit (int): The maximum number of messages to retain before triggering summarization.
summarizer (Agent): A stateless agent used to generate a summary of the current conversation history.
Args:
agent_factory (AgentFactory): Factory used to create the summarizer agent.
memory_limit (int, optional): Maximum number of messages before summarizing. Defaults to 10.
Methods:
add_history(msg):
Adds new message(s) to memory and summarizes history if the limit is exceeded.
_summarize_history():
Internal method that compresses the full message history into a single summary message.
| None iragent.memory.SummarizerMemory.__init__ | ( | self, | |
| AgentFactory | agent_factory, | ||
| int | memory_limit = 10 ) |
|
protected |
| None iragent.memory.SummarizerMemory.add_history | ( | self, | |
| dict | list[dict] | msg ) |
Reimplemented from iragent.memory.BaseMemory.
| iragent.memory.SummarizerMemory.memory_limit = memory_limit |
| iragent.memory.SummarizerMemory.summarizer |