Short-term Memory
Short-term memory temporarily buffers recent perceptions, it will receive some of the sensory memory, and it can be enhanced by other observations or retrieved memories to enter the long-term memory.
In most cases, short-term memory is analogous to the input information within the context window constrained by the LLM. So you can think of short-term memory will be written into the prompt of the LLM in most cases.
Using Short-term Memory
from dbgpt.agent import AgentMemory, ShortTermMemory
# Create an agent memory, which contains a short-term memory
memory = ShortTermMemory(buffer_size=2)
agent_memory: AgentMemory = AgentMemory(memory=memory)
Like sensory memory, short-term memory is also has a buffer size, when the buffer is full, it will keep the latest buffer_size memories, and some of the discarded memories will be transferred to long-term memory.
The default short-term memory is a FIFO buffered memory, we won't introduce too much here.
Enhanced Short-term Memory
Like human short-term memory, the short-term memory in DB-GPT agents can be enhanced by outside observations.
Here we introduce a kind of enhanced short-term memory, which is called EnhancedShortTermMemory,
it enhances memories by comparing the similarity between the new observation and the existing memories.
To use EnhancedShortTermMemory, you need to provide a embeddings model.