session_id
.run_id
.role
(system
, user
or assistant
) and content
.agent.memory
AgentStorage
.
Storage is a necessary component when building user facing AI products as any production application will require users to be able to “continue” their conversation with the Agent.
Let’s test this out, create a file persistent_memory.py
with the following code:
session_id
.
Read more in the storage section.
AgentMemory
can be extended to automatically classify and store user preferences and conversation summaries.
To do this, add a db
to AgentMemory
and set create_user_memories=True
and create_session_summary=True
User memories are stored in the AgentMemory
whereas session summaries are stored in the AgentStorage
table with the rest of the session information.
OpenAI
and OpenAILike
models. While Persistent Memory is compatible with
all model providers.Parameter | Type | Default | Description |
---|---|---|---|
memory | AgentMemory | AgentMemory() | Agent’s memory object used for storing and retrieving information. |
add_history_to_messages | bool | False | If true, adds the chat history to the messages sent to the Model. Also known as add_chat_history_to_messages . |
num_history_responses | int | 3 | Number of historical responses to add to the messages. |
create_user_memories | bool | False | If true, create and store personalized memories for the user. |
update_user_memories_after_run | bool | True | If true, update memories for the user after each run. |
create_session_summary | bool | False | If true, create and store session summaries. |
update_session_summary_after_run | bool | True | If true, update session summaries after each run. |