QdrantMemoryStore¶
Qdrant-backed episodic memory store.
QdrantMemoryStore
¶
Bases: BaseMemoryStore
Episodic memory store backed by a Qdrant collection.
Episodes are embedded at write time using FastEmbed and stored as vector points. Similarity search uses cosine distance over the embedded episode text.
By default, Qdrant runs in-process with no server required. Pass a
pre-configured AsyncQdrantClient to persist to a remote or on-disk
instance instead.
Note: This is a minimal integration. Advanced Qdrant features such
as payload filters, score thresholds, and named vectors are not
exposed. Use the _client attribute directly for full API access.
Attributes:
| Name | Type | Description |
|---|---|---|
_client |
AsyncQdrantClient
|
The Qdrant client instance. |
_collection_name |
str
|
Name of the Qdrant collection. |
_key_fn |
Callable[[Episode], str]
|
Callable that extracts the text used for embedding from an episode. |
Source code in src/llm_agents_from_scratch/memory_stores/qdrant/store.py
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 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 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | |
__init__
¶
__init__(
collection_name="episodes",
embedding_model="BAAI/bge-small-en-v1.5",
client=None,
max_results=5,
recall_mode=RecallMode.SEARCH,
key_fn=None,
)
Initialize a QdrantMemoryStore.
The Qdrant collection is created lazily on the first operation
via _ensure_collection(). No async calls are made in
__init__.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection_name
|
str
|
Name of the Qdrant collection.
Defaults to |
'episodes'
|
embedding_model
|
str
|
FastEmbed model name used to embed
episode text at write time and queries at search time.
Defaults to |
'BAAI/bge-small-en-v1.5'
|
client
|
AsyncQdrantClient | None
|
Pre-configured async
Qdrant client. Defaults to an in-memory client when
|
None
|
max_results
|
int
|
Default maximum number of episodes
returned by |
5
|
recall_mode
|
RecallMode
|
Retrieval strategy used by
|
SEARCH
|
key_fn
|
Callable[[Episode], str] | None
|
Callable that
extracts the text to embed from an episode. Defaults to
a concat-format serialization using
|
None
|
Source code in src/llm_agents_from_scratch/memory_stores/qdrant/store.py
write
async
¶
Embed and persist an episode to the Qdrant collection.
The full serialized episode and its completion timestamp are
stored in the point payload for later retrieval. The embedding
text is produced by _key_fn.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
episode
|
Episode
|
The completed episode to store. |
required |
Source code in src/llm_agents_from_scratch/memory_stores/qdrant/store.py
count
async
¶
Return the total number of episodes in the store.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Episode count. |
Source code in src/llm_agents_from_scratch/memory_stores/qdrant/store.py
delete
async
¶
Delete an episode by its unique identifier.
Raises EpisodeNotFoundError if no point with id_ exists
in the collection. Otherwise removes it via
AsyncQdrantClient.delete.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_
|
str
|
The |
required |
Raises:
| Type | Description |
|---|---|
EpisodeNotFoundError
|
If no point with |
Source code in src/llm_agents_from_scratch/memory_stores/qdrant/store.py
update
async
¶
Replace an existing episode with an updated version.
Matches by episode.id_ (the Qdrant point ID). Raises
EpisodeNotFoundError if no matching point exists. Otherwise
re-embeds and upserts the updated episode using _key_fn.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
episode
|
Episode
|
The updated episode. Matched by |
required |
Raises:
| Type | Description |
|---|---|
EpisodeNotFoundError
|
If no point with |
Source code in src/llm_agents_from_scratch/memory_stores/qdrant/store.py
summary
async
¶
Return a human-readable summary of the store contents.
Includes the collection name, total episode count, and the instruction and timestamp of the newest and oldest episodes.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Multi-line summary of the store. |