Qdrant
VectorDB Implementation
This section details the Qdrant implementation of the BaseVectorDB
interface.
memora.vector_db.qdrant.QdrantDB
QdrantDB(
async_client: AsyncQdrantClient = None,
collection_name: str = "memory_collection_v0_2",
embed_models_cache_dir: str = "./cache",
enable_logging: bool = False,
)
Bases: BaseVectorDB
PARAMETER | DESCRIPTION |
---|---|
async_client
|
A pre-initialized Async Qdrant client
TYPE:
|
collection_name
|
Name of the Qdrant collection
TYPE:
|
embed_models_cache_dir
|
Directory to cache the embedding models
TYPE:
|
enable_logging
|
Whether to enable console logging
TYPE:
|
Example
Source code in memora/vector_db/qdrant.py
Attributes
sparse_vector_embedding_model
instance-attribute
vector_embedding_model
instance-attribute
Functions
add_memories
async
add_memories(
org_id: str,
user_id: str,
agent_id: str,
memory_ids: List[uuid.UUID],
memories: List[str],
obtained_at: str,
) -> None
Add memories to collection with their org_id, user_id, agent_id, and obtained_at datetime as metadata.
PARAMETER | DESCRIPTION |
---|---|
org_id
|
Organization ID for the memories
TYPE:
|
user_id
|
User ID for the memories
TYPE:
|
agent_id
|
Agent ID for the memories
TYPE:
|
memory_ids
|
List of UUIDs for each memory
TYPE:
|
memories
|
List of memory strings to add
TYPE:
|
obtained_at
|
ISO format datetime string when the memories were obtained
TYPE:
|
Source code in memora/vector_db/qdrant.py
close
async
delete_all_organization_memories
async
Delete all memories associated with an organization.
PARAMETER | DESCRIPTION |
---|---|
org_id
|
ID of the organization whose memories should be deleted
TYPE:
|
Source code in memora/vector_db/qdrant.py
delete_all_user_memories
async
Delete all memories associated with a specific user.
PARAMETER | DESCRIPTION |
---|---|
org_id
|
Organization ID the user belongs to
TYPE:
|
user_id
|
ID of the user whose memories should be deleted
TYPE:
|
Source code in memora/vector_db/qdrant.py
delete_memories
async
Delete multiple memories by their IDs.
PARAMETER | DESCRIPTION |
---|---|
memory_ids
|
List of memory IDs to delete
TYPE:
|
Source code in memora/vector_db/qdrant.py
delete_memory
async
Delete a memory by its ID with optional org/user filtering.
PARAMETER | DESCRIPTION |
---|---|
memory_id
|
ID of the memory to delete
TYPE:
|
Source code in memora/vector_db/qdrant.py
search_memories
async
search_memories(
queries: List[str],
memory_search_scope: MemorySearchScope,
org_id: str,
user_id: Optional[str] = None,
agent_id: Optional[str] = None,
) -> List[List[Tuple[schema_models.Memory, float]]]
Batch memory search with optional user/agent filtering.
PARAMETER | DESCRIPTION |
---|---|
queries
|
List of search query strings
TYPE:
|
memory_search_scope
|
Memory search scope (organization or user)
TYPE:
|
org_id
|
Organization ID for filtering
TYPE:
|
user_id
|
Optional user ID for filtering
TYPE:
|
agent_id
|
Optional agent ID for filtering
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
List[List[Tuple[Memory, float]]]
|
List[List[Tuple[Memory, float]]] of search results for each query, with a tuple containing: Memory:
float: Score of the memory |
Source code in memora/vector_db/qdrant.py
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 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
|
search_memory
async
search_memory(
query: str,
memory_search_scope: MemorySearchScope,
org_id: str,
user_id: Optional[str] = None,
agent_id: Optional[str] = None,
) -> List[Tuple[schema_models.Memory, float]]
Memory search with optional user/agent filtering.
PARAMETER | DESCRIPTION |
---|---|
query
|
Search query string
TYPE:
|
memory_search_scope
|
Memory search scope (organization or user)
TYPE:
|
org_id
|
Organization ID for filtering
TYPE:
|
user_id
|
Optional user ID for filtering
TYPE:
|
agent_id
|
Optional agent ID for filtering
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
List[Tuple[Memory, float]]
|
List[Tuple[Memory, float]] containing tuple of search results and score: Memory:
float: Score of the memory |
Source code in memora/vector_db/qdrant.py
setup
async
Setup the QdrantDB by creating the collection and payload indices.