Vector memory
Vector memory.
Memory backed by a vector database.
VectorMemory #
Bases: BaseMemory
Memory backed by a vector index.
NOTE: This class requires the delete_nodes
method to be implemented
by the vector store underlying the vector index. At time of writing (May 2024),
Chroma, Qdrant and SimpleVectorStore all support delete_nodes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_index
|
Any
|
|
required |
retriever_kwargs
|
Dict[str, Any]
|
|
{}
|
batch_by_user_message
|
bool
|
|
True
|
cur_batch_textnode
|
TextNode
|
The super node for the current active user-message batch. |
TextNode(id_='f9c85d00-80b3-4506-b2c7-946d3d1d8e6e', embedding=None, metadata={'sub_dicts': []}, excluded_embed_metadata_keys=['sub_dicts'], excluded_llm_metadata_keys=['sub_dicts'], relationships={}, metadata_template='{key}: {value}', metadata_separator='\n', text='', mimetype='text/plain', start_char_idx=None, end_char_idx=None, metadata_seperator='\n', text_template='{metadata_str}\n\n{content}')
|
Source code in llama-index-core/llama_index/core/memory/vector_memory.py
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 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
|
validate_vector_index
classmethod
#
validate_vector_index(value: Any) -> Any
Validate vector index.
Source code in llama-index-core/llama_index/core/memory/vector_memory.py
71 72 73 74 75 76 77 78 79 80 81 82 83 |
|
class_name
classmethod
#
class_name() -> str
Get class name.
Source code in llama-index-core/llama_index/core/memory/vector_memory.py
85 86 87 88 |
|
from_defaults
classmethod
#
from_defaults(vector_store: Optional[BasePydanticVectorStore] = None, embed_model: Optional[EmbedType] = None, index_kwargs: Optional[Dict] = None, retriever_kwargs: Optional[Dict] = None, **kwargs: Any) -> VectorMemory
Create vector memory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_store
|
Optional[BasePydanticVectorStore]
|
vector store (note: delete_nodes must be implemented. At time of writing (May 2024), Chroma, Qdrant and SimpleVectorStore all support delete_nodes. |
None
|
embed_model
|
Optional[EmbedType]
|
embedding model |
None
|
index_kwargs
|
Optional[Dict]
|
kwargs for initializing the index |
None
|
retriever_kwargs
|
Optional[Dict]
|
kwargs for initializing the retriever |
None
|
Source code in llama-index-core/llama_index/core/memory/vector_memory.py
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 |
|
get #
get(input: Optional[str] = None, initial_token_count: int = 0, **kwargs: Any) -> List[ChatMessage]
Get chat history.
Source code in llama-index-core/llama_index/core/memory/vector_memory.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
|
get_all #
get_all() -> List[ChatMessage]
Get all chat history.
Source code in llama-index-core/llama_index/core/memory/vector_memory.py
148 149 150 151 152 153 154 |
|
put #
put(message: ChatMessage) -> None
Put chat history.
Source code in llama-index-core/llama_index/core/memory/vector_memory.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|
set #
set(messages: List[ChatMessage]) -> None
Set chat history.
Source code in llama-index-core/llama_index/core/memory/vector_memory.py
190 191 192 193 194 |
|
reset #
reset() -> None
Reset chat history.
Source code in llama-index-core/llama_index/core/memory/vector_memory.py
196 197 198 |
|