Vector
In-memory implementation of vector similarity search capability.
This module provides an in-memory implementation of the VectorCapability protocol using dictionary-based storage optimized for development and testing scenarios.
InMemoryVectorCapability(em_invoker, store=None, encryption=None, default_batch_size=None)
Bases: BaseVectorCapability
In-memory implementation of VectorCapability protocol.
This class provides vector similarity search operations using pure Python data structures optimized for development and testing.
Attributes:
| Name | Type | Description |
|---|---|---|
store |
dict[str, Chunk]
|
Dictionary storing Chunk objects with their IDs as keys. |
Initialize the in-memory vector capability.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
em_invoker
|
BaseEMInvoker
|
Embedding model invoker for text-to-vector conversion. |
required |
store
|
dict[str, Any] | None
|
Dictionary storing Chunk objects. Defaults to None. |
None
|
encryption
|
EncryptionCapability | None
|
Encryption capability. Defaults to None. |
None
|
default_batch_size
|
int | None
|
Default batch size. Defaults to None. |
None
|
ensure_index(**kwargs)
async
Ensure in-memory vector store exists, initializing if necessary.
Idempotent; no-op if store already exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Unused; for interface compatibility. |
{}
|