Agents 0.0.2
Edge AI Agents SDK
Loading...
Searching...
No Matches
agents::Memory Class Referenceabstract

Interface for agent memory storage. More...

#include <memory.h>

Public Member Functions

virtual void add (const String &key, const JsonObject &value, MemoryType type=MemoryType::SHORT_TERM)=0
 Add a memory entry.
 
virtual std::optional< JsonObjectget (const String &key, MemoryType type=MemoryType::SHORT_TERM) const =0
 Get a memory entry by key.
 
virtual bool has (const String &key, MemoryType type=MemoryType::SHORT_TERM) const =0
 Check if a memory entry exists.
 
virtual void remove (const String &key, MemoryType type=MemoryType::SHORT_TERM)=0
 Remove a memory entry.
 
virtual void clear (MemoryType type=MemoryType::SHORT_TERM)=0
 Clear all memory of a specific type.
 
virtual void addMessage (const Message &message)=0
 Add a conversation message to memory.
 
virtual std::vector< MessagegetMessages () const =0
 Get all conversation messages.
 
virtual String getConversationSummary (int max_length=0) const =0
 Get conversation summary as a string.
 
virtual std::vector< std::pair< JsonObject, float > > search (const String &query, MemoryType type=MemoryType::LONG_TERM, int max_results=5) const =0
 Semantic search in memory.
 

Detailed Description

Interface for agent memory storage.

Memory stores information that can be retrieved by the agent, such as conversation history, retrieved documents, or intermediate results.

Member Function Documentation

◆ add()

virtual void agents::Memory::add ( const String & key,
const JsonObject & value,
MemoryType type = MemoryType::SHORT_TERM )
pure virtual

Add a memory entry.

Parameters
keyThe key to add
valueThe value to add
typeThe type of memory to add

◆ addMessage()

virtual void agents::Memory::addMessage ( const Message & message)
pure virtual

Add a conversation message to memory.

Parameters
messageThe message to add

◆ clear()

virtual void agents::Memory::clear ( MemoryType type = MemoryType::SHORT_TERM)
pure virtual

Clear all memory of a specific type.

Parameters
typeThe type of memory to clear

◆ get()

virtual std::optional< JsonObject > agents::Memory::get ( const String & key,
MemoryType type = MemoryType::SHORT_TERM ) const
pure virtual

Get a memory entry by key.

Parameters
keyThe key to get
typeThe type of memory to get
Returns
The memory entry

◆ getConversationSummary()

virtual String agents::Memory::getConversationSummary ( int max_length = 0) const
pure virtual

Get conversation summary as a string.

Parameters
max_lengthThe maximum length of the summary
Returns
The conversation summary

◆ getMessages()

virtual std::vector< Message > agents::Memory::getMessages ( ) const
pure virtual

Get all conversation messages.

Returns
The conversation messages

◆ has()

virtual bool agents::Memory::has ( const String & key,
MemoryType type = MemoryType::SHORT_TERM ) const
pure virtual

Check if a memory entry exists.

Parameters
keyThe key to check
typeThe type of memory to check
Returns
true if exists, otherwise false

◆ remove()

virtual void agents::Memory::remove ( const String & key,
MemoryType type = MemoryType::SHORT_TERM )
pure virtual

Remove a memory entry.

Parameters
keyThe key to remove
typeThe type of memory to remove

◆ search()

virtual std::vector< std::pair< JsonObject, float > > agents::Memory::search ( const String & query,
MemoryType type = MemoryType::LONG_TERM,
int max_results = 5 ) const
pure virtual

Semantic search in memory.

Parameters
queryThe query to search for
typeThe type of memory to search
max_resultsThe maximum number of results to return
Returns
The search results