Agents 0.0.2
Edge AI Agents SDK
Loading...
Searching...
No Matches
memory.h
1
10#pragma once
11
12#include <agents-cpp/types.h>
13#include <memory>
14#include <optional>
15#include <vector>
16
17namespace agents {
18
26class Memory {
27public:
28 virtual ~Memory() = default;
29
36 virtual void add(const String& key, const JsonObject& value, MemoryType type = MemoryType::SHORT_TERM) = 0;
37
44 virtual std::optional<JsonObject> get(const String& key, MemoryType type = MemoryType::SHORT_TERM) const = 0;
45
52 virtual bool has(const String& key, MemoryType type = MemoryType::SHORT_TERM) const = 0;
53
59 virtual void remove(const String& key, MemoryType type = MemoryType::SHORT_TERM) = 0;
60
65 virtual void clear(MemoryType type = MemoryType::SHORT_TERM) = 0;
66
71 virtual void addMessage(const Message& message) = 0;
72
77 virtual std::vector<Message> getMessages() const = 0;
78
84 virtual String getConversationSummary(int max_length = 0) const = 0;
85
93 virtual std::vector<std::pair<JsonObject, float>> search(
94 const String& query,
96 int max_results = 5
97 ) const = 0;
98};
99
104std::shared_ptr<Memory> createMemory();
105
106} // namespace agents
Interface for agent memory storage.
Definition memory.h:26
virtual void add(const String &key, const JsonObject &value, MemoryType type=MemoryType::SHORT_TERM)=0
Add a memory entry.
virtual void clear(MemoryType type=MemoryType::SHORT_TERM)=0
Clear all memory of a specific type.
virtual std::vector< Message > getMessages() const =0
Get all conversation messages.
virtual void remove(const String &key, MemoryType type=MemoryType::SHORT_TERM)=0
Remove a memory entry.
virtual void addMessage(const Message &message)=0
Add a conversation message to memory.
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.
virtual bool has(const String &key, MemoryType type=MemoryType::SHORT_TERM) const =0
Check if a memory entry exists.
virtual std::optional< JsonObject > get(const String &key, MemoryType type=MemoryType::SHORT_TERM) const =0
Get a memory entry by key.
virtual String getConversationSummary(int max_length=0) const =0
Get conversation summary as a string.
Framework Namespace.
Definition agent.h:18
nlohmann::json JsonObject
JSON object type.
Definition types.h:39
std::string String
String type.
Definition types.h:27
std::shared_ptr< Memory > createMemory()
Create a Memory instance.
MemoryType
Memory types.
Definition types.h:155
@ LONG_TERM
Long term memory.
Definition types.h:163
@ SHORT_TERM
Short term memory.
Definition types.h:159
Message in a conversation.
Definition types.h:105