Simple composable memory
SimpleComposableMemory #
Bases: BaseMemory
A simple composition of potentially several memory sources.
This composable memory considers one of the memory sources as the main one and the others as secondary. The secondary memory sources get added to the chat history only in either the system prompt or to the first user message within the chat history.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
primary_memory |
(BaseMemory) The main memory buffer for agent. |
required | |
secondary_memory_sources |
(List(BaseMemory)) Secondary memory sources. Retrieved messages from these sources get added to the system prompt message. |
required |
Source code in llama-index-core/llama_index/core/memory/simple_composable_memory.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
class_name
classmethod
#
class_name() -> str
Class name.
Source code in llama-index-core/llama_index/core/memory/simple_composable_memory.py
35 36 37 38 |
|
from_defaults
classmethod
#
from_defaults(primary_memory: Optional[BaseMemory] = None, secondary_memory_sources: Optional[List[BaseMemory]] = None, **kwargs: Any) -> SimpleComposableMemory
Create a simple composable memory from an LLM.
Source code in llama-index-core/llama_index/core/memory/simple_composable_memory.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
|
get #
get(input: Optional[str] = None, **kwargs: Any) -> List[ChatMessage]
Get chat history.
Source code in llama-index-core/llama_index/core/memory/simple_composable_memory.py
78 79 80 |
|
get_all #
get_all() -> List[ChatMessage]
Get all chat history.
Uses primary memory get_all only.
Source code in llama-index-core/llama_index/core/memory/simple_composable_memory.py
126 127 128 129 130 131 |
|
put #
put(message: ChatMessage) -> None
Put chat history.
Source code in llama-index-core/llama_index/core/memory/simple_composable_memory.py
133 134 135 136 137 |
|
aput
async
#
aput(message: ChatMessage) -> None
Put chat history.
Source code in llama-index-core/llama_index/core/memory/simple_composable_memory.py
139 140 141 142 143 |
|
set #
set(messages: List[ChatMessage]) -> None
Set chat history.
Source code in llama-index-core/llama_index/core/memory/simple_composable_memory.py
145 146 147 148 149 150 151 152 |
|
reset #
reset() -> None
Reset chat history.
Source code in llama-index-core/llama_index/core/memory/simple_composable_memory.py
154 155 156 157 158 |
|