Expand description
Vector-store abstractions: describe a collection’s fields, then read and write records through a provider-agnostic trait pair.
Ports the portable core of upstream’s agent_framework._vectors (#8014):
VectorStoreField and VectorStoreCollectionDefinition describe a
collection’s shape, VectorCollection is one collection’s data plane,
and VectorStore is the connection that hands out collections. A
provider crate implements the two traits; nothing here talks to a service.
§Divergence: records are serde_json::Value, not a registered model type
Roughly half of upstream’s module is a model layer: a
@vector_store_model decorator that registers a Python class, walks its
annotations, and generates encoders/decoders between instances of that
class and the flat mappings a store wants. Rust needs none of it — a
record type derives Serialize/Deserialize and serde already performs
that conversion, with the field names checked at compile time rather than
at registration time.
So a record here is a serde_json::Value object keyed by field name,
exactly as the workflow engine passes payloads, and a caller with a typed
struct converts at the boundary with serde_json::to_value /
from_value. That keeps both traits object-safe, so a
Box<dyn VectorCollection> can be swapped between providers — which a
generic-over-record-type trait could not be.
The one piece of upstream’s model layer that is not redundant is the
split between a field’s logical name and its storage name, since that is a
property of the store rather than of the Rust type.
VectorStoreCollectionDefinition::to_storage and
VectorStoreCollectionDefinition::from_storage perform that renaming.
Modules§
- filters
- Portable vector-store filter expressions.
Structs§
- Distance
Function - How similarity between two vectors is measured. Open value wrapper, as
IndexKind. - Filter
- One field test.
- Filter
Group - Several filters combined by a boolean operator.
- InMemory
Vector Store - An in-memory
VectorStore, for tests and for running a pipeline before a real store is provisioned. - Index
Kind - How a vector index is built. Open value wrapper — the constants cover upstream’s list, and any other string a provider understands is accepted.
- Vector
Search Options - Paging and shaping options for a search.
- Vector
Search Result - One search hit: the record, and the provider’s score for it.
- Vector
Store Collection Definition - The shape of one vector-store collection: its fields, and the accessors a provider needs to build requests from them.
- Vector
Store Field - One field in a vector-store collection.
Enums§
- Field
Type - What role a field plays in a collection.
- Filter
Expression - A filter tree: either one field test or a group of them.
- Filter
Group Operator - How a
FilterGroup’s children combine. - Filter
Operator - How one field is tested.
Constants§
- MAX_
FILTER_ DEPTH - Maximum nesting depth of a filter expression.
- MAX_
FILTER_ NODES - Maximum number of nodes (leaves plus groups) in a filter expression.
Traits§
- Vector
Collection - One collection’s data plane: create/drop, read/write, and search.
- Vector
Store - A connection to a vector store: lists collections and hands them out.