Vector Stores#
ragbits.core.vector_stores.base.VectorStoreEntry
#
Bases: BaseModel
An object representing a vector database entry. Contains text and/or image for embedding + metadata.
text_or_image_required
#
Validates that either text or image_bytes are provided.
RAISES | DESCRIPTION |
---|---|
ValueError
|
If neither text nor image_bytes are provided. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/base.py
ragbits.core.vector_stores.base.VectorStoreOptions
#
Bases: Options
An object representing the options for the vector store.
model_config
class-attribute
instance-attribute
#
dict
#
dict() -> dict[str, Any]
Creates a dictionary representation of the Options instance. If a value is None, it will be replaced with a provider-specific not-given sentinel.
RETURNS | DESCRIPTION |
---|---|
dict[str, Any]
|
A dictionary representation of the Options instance. |
Source code in packages/ragbits-core/src/ragbits/core/options.py
ragbits.core.vector_stores.base.VectorStore
#
Bases: ConfigurableComponent[VectorStoreOptionsT]
, ABC
A class with an implementation of Vector Store, allowing to store and retrieve vectors by similarity function.
Constructs a new ConfigurableComponent instance.
PARAMETER | DESCRIPTION |
---|---|
default_options |
The default options for the component.
TYPE:
|
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
subclass_from_config
classmethod
#
Initializes the class with the provided configuration. May return a subclass of the class, if requested by the configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A model containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The class can't be found or is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
subclass_from_factory
classmethod
#
Creates the class using the provided factory function. May return a subclass of the class, if requested by the factory.
PARAMETER | DESCRIPTION |
---|---|
factory_path |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided factory function. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The factory can't be found or the object returned is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
preferred_subclass
classmethod
#
preferred_subclass(config: CoreConfig, factory_path_override: str | None = None, yaml_path_override: Path | None = None) -> Self
Tries to create an instance by looking at project's component preferences, either from YAML or from the factory. Takes optional overrides for both, which takes a higher precedence.
PARAMETER | DESCRIPTION |
---|---|
config |
The CoreConfig instance containing preferred factory and configuration details.
TYPE:
|
factory_path_override |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
yaml_path_override |
A string representing the path to the YAML file containing the Ragstack instance configuration.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
If the default factory or configuration can't be found. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
from_config
classmethod
#
Initializes the class with the provided configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A dictionary containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
store
abstractmethod
async
#
store(entries: list[VectorStoreEntry]) -> None
Store entries in the vector store.
PARAMETER | DESCRIPTION |
---|---|
entries |
The entries to store.
TYPE:
|
retrieve
abstractmethod
async
#
retrieve(text: str, options: VectorStoreOptionsT | None = None) -> list[VectorStoreResult]
Retrieve entries from the vector store most similar to the provided text.
PARAMETER | DESCRIPTION |
---|---|
text |
The text to query the vector store with.
TYPE:
|
options |
The options for querying the vector store.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[VectorStoreResult]
|
The entries. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/base.py
remove
abstractmethod
async
#
remove(ids: list[UUID]) -> None
Remove entries from the vector store.
PARAMETER | DESCRIPTION |
---|---|
ids |
The list of entries' IDs to remove.
TYPE:
|
list
abstractmethod
async
#
list(where: WhereQuery | None = None, limit: int | None = None, offset: int = 0) -> list[VectorStoreEntry]
List entries from the vector store. The entries can be filtered, limited and offset.
PARAMETER | DESCRIPTION |
---|---|
where |
The filter dictionary - the keys are the field names and the values are the values to filter by. Not specifying the key means no filtering.
TYPE:
|
limit |
The maximum number of entries to return.
TYPE:
|
offset |
The number of entries to skip.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[VectorStoreEntry]
|
The entries. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/base.py
ragbits.core.vector_stores.hybrid.HybridSearchVectorStore
#
HybridSearchVectorStore(*vector_stores: VectorStore, retrieval_strategy: HybridRetrivalStrategy | None = None)
Bases: VectorStore
A vector store that takes multiple vector store objects and proxies requests to them, returning the union of results.
Constructs a new HybridSearchVectorStore instance.
PARAMETER | DESCRIPTION |
---|---|
vector_stores |
The vector stores to proxy requests to.
TYPE:
|
retrieval_strategy |
The retrieval strategy to use when combining results, uses OrderedHybridRetrivalStrategy by default.
TYPE:
|
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/hybrid.py
retrieval_strategy
instance-attribute
#
retrieval_strategy = retrieval_strategy or OrderedHybridRetrivalStrategy()
subclass_from_config
classmethod
#
Initializes the class with the provided configuration. May return a subclass of the class, if requested by the configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A model containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The class can't be found or is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
subclass_from_factory
classmethod
#
Creates the class using the provided factory function. May return a subclass of the class, if requested by the factory.
PARAMETER | DESCRIPTION |
---|---|
factory_path |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided factory function. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The factory can't be found or the object returned is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
preferred_subclass
classmethod
#
preferred_subclass(config: CoreConfig, factory_path_override: str | None = None, yaml_path_override: Path | None = None) -> Self
Tries to create an instance by looking at project's component preferences, either from YAML or from the factory. Takes optional overrides for both, which takes a higher precedence.
PARAMETER | DESCRIPTION |
---|---|
config |
The CoreConfig instance containing preferred factory and configuration details.
TYPE:
|
factory_path_override |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
yaml_path_override |
A string representing the path to the YAML file containing the Ragstack instance configuration.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
If the default factory or configuration can't be found. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
from_config
classmethod
#
Initializes the class with the provided configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A dictionary containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
store
async
#
store(entries: list[VectorStoreEntry]) -> None
Store entries in the vector stores.
Sends entries to all vector stores to be stored, although individual vector stores are free to implement their own logic regarding which entries to store. For example, some vector stores may only store entries with specific type of content (images, text, etc.).
PARAMETER | DESCRIPTION |
---|---|
entries |
The entries to store.
TYPE:
|
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/hybrid.py
retrieve
async
#
retrieve(text: str, options: VectorStoreOptions | None = None) -> list[VectorStoreResult]
Retrieve entries from the vector stores most similar to the provided text. The results are combined using the retrieval strategy provided in the constructor.
PARAMETER | DESCRIPTION |
---|---|
text |
The text to query the vector store with.
TYPE:
|
options |
The options for querying the vector stores.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[VectorStoreResult]
|
The entries. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/hybrid.py
remove
async
#
remove(ids: list[UUID]) -> None
Remove entries from all vector stores.
PARAMETER | DESCRIPTION |
---|---|
ids |
The list of entries' IDs to remove.
TYPE:
|
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/hybrid.py
list
async
#
list(where: WhereQuery | None = None, limit: int | None = None, offset: int = 0) -> list[VectorStoreEntry]
List entries from the vector stores. The entries can be filtered, limited and offset. Vector stores are queried in the order they were provided in the constructor.
PARAMETER | DESCRIPTION |
---|---|
where |
The filter dictionary - the keys are the field names and the values are the values to filter by. Not specifying the key means no filtering.
TYPE:
|
limit |
The maximum number of entries to return.
TYPE:
|
offset |
The number of entries to skip.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[VectorStoreEntry]
|
The entries. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/hybrid.py
ragbits.core.vector_stores.in_memory.InMemoryVectorStore
#
InMemoryVectorStore(embedder: Embedder, embedding_type: EmbeddingType = EmbeddingType.TEXT, default_options: VectorStoreOptions | None = None)
Bases: VectorStoreWithExternalEmbedder[VectorStoreOptions]
A simple in-memory implementation of Vector Store, storing vectors in memory.
Constructs a new InMemoryVectorStore instance.
PARAMETER | DESCRIPTION |
---|---|
default_options |
The default options for querying the vector store.
TYPE:
|
embedder |
The embedder to use for converting entries to vectors.
TYPE:
|
embedding_type |
Which part of the entry to embed, either text or image. The other part will be ignored.
TYPE:
|
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/in_memory.py
subclass_from_config
classmethod
#
Initializes the class with the provided configuration. May return a subclass of the class, if requested by the configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A model containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The class can't be found or is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
subclass_from_factory
classmethod
#
Creates the class using the provided factory function. May return a subclass of the class, if requested by the factory.
PARAMETER | DESCRIPTION |
---|---|
factory_path |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided factory function. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The factory can't be found or the object returned is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
preferred_subclass
classmethod
#
preferred_subclass(config: CoreConfig, factory_path_override: str | None = None, yaml_path_override: Path | None = None) -> Self
Tries to create an instance by looking at project's component preferences, either from YAML or from the factory. Takes optional overrides for both, which takes a higher precedence.
PARAMETER | DESCRIPTION |
---|---|
config |
The CoreConfig instance containing preferred factory and configuration details.
TYPE:
|
factory_path_override |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
yaml_path_override |
A string representing the path to the YAML file containing the Ragstack instance configuration.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
If the default factory or configuration can't be found. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
from_config
classmethod
#
Initializes the class with the provided configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A dictionary containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/base.py
store
async
#
store(entries: list[VectorStoreEntry]) -> None
Store entries in the vector store.
PARAMETER | DESCRIPTION |
---|---|
entries |
The entries to store.
TYPE:
|
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/in_memory.py
retrieve
async
#
retrieve(text: str, options: VectorStoreOptions | None = None) -> list[VectorStoreResult]
Retrieve entries from the vector store most similar to the provided text.
PARAMETER | DESCRIPTION |
---|---|
text |
The text to query the vector store with.
TYPE:
|
options |
The options for querying the vector store.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[VectorStoreResult]
|
The entries. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/in_memory.py
remove
async
#
remove(ids: list[UUID]) -> None
Remove entries from the vector store.
PARAMETER | DESCRIPTION |
---|---|
ids |
The list of entries' IDs to remove.
TYPE:
|
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/in_memory.py
list
async
#
list(where: WhereQuery | None = None, limit: int | None = None, offset: int = 0) -> list[VectorStoreEntry]
List entries from the vector store. The entries can be filtered, limited and offset.
PARAMETER | DESCRIPTION |
---|---|
where |
The filter dictionary - the keys are the field names and the values are the values to filter by. Not specifying the key means no filtering.
TYPE:
|
limit |
The maximum number of entries to return.
TYPE:
|
offset |
The number of entries to skip.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[VectorStoreEntry]
|
The entries. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/in_memory.py
ragbits.core.vector_stores.chroma.ChromaVectorStore
#
ChromaVectorStore(client: ClientAPI, index_name: str, embedder: Embedder, embedding_type: EmbeddingType = EmbeddingType.TEXT, distance_method: Literal['l2', 'ip', 'cosine'] = 'cosine', default_options: VectorStoreOptions | None = None)
Bases: VectorStoreWithExternalEmbedder[VectorStoreOptions]
Vector store implementation using Chroma.
Constructs a new ChromaVectorStore instance.
PARAMETER | DESCRIPTION |
---|---|
client |
The ChromaDB client.
TYPE:
|
index_name |
The name of the index.
TYPE:
|
embedder |
The embedder to use for converting entries to vectors.
TYPE:
|
embedding_type |
Which part of the entry to embed, either text or image. The other part will be ignored.
TYPE:
|
distance_method |
The distance method to use.
TYPE:
|
default_options |
The default options for querying the vector store.
TYPE:
|
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/chroma.py
subclass_from_config
classmethod
#
Initializes the class with the provided configuration. May return a subclass of the class, if requested by the configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A model containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The class can't be found or is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
subclass_from_factory
classmethod
#
Creates the class using the provided factory function. May return a subclass of the class, if requested by the factory.
PARAMETER | DESCRIPTION |
---|---|
factory_path |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided factory function. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The factory can't be found or the object returned is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
preferred_subclass
classmethod
#
preferred_subclass(config: CoreConfig, factory_path_override: str | None = None, yaml_path_override: Path | None = None) -> Self
Tries to create an instance by looking at project's component preferences, either from YAML or from the factory. Takes optional overrides for both, which takes a higher precedence.
PARAMETER | DESCRIPTION |
---|---|
config |
The CoreConfig instance containing preferred factory and configuration details.
TYPE:
|
factory_path_override |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
yaml_path_override |
A string representing the path to the YAML file containing the Ragstack instance configuration.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
If the default factory or configuration can't be found. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
from_config
classmethod
#
Initializes the class with the provided configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A dictionary containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/chroma.py
store
async
#
store(entries: list[VectorStoreEntry]) -> None
Stores entries in the ChromaDB collection.
In case entry contains both text and image embeddings,
only one of them will get embedded - text by default, unless
the option prefer_image
is set to True.
PARAMETER | DESCRIPTION |
---|---|
entries |
The entries to store.
TYPE:
|
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/chroma.py
retrieve
async
#
retrieve(text: str, options: VectorStoreOptions | None = None) -> list[VectorStoreResult]
Retrieves entries from the ChromaDB collection.
PARAMETER | DESCRIPTION |
---|---|
text |
The text to query the vector store with.
TYPE:
|
options |
The options for querying the vector store.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[VectorStoreResult]
|
The retrieved entries. |
RAISES | DESCRIPTION |
---|---|
MetadataNotFoundError
|
If the metadata is not found. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/chroma.py
remove
async
#
remove(ids: list[UUID]) -> None
Remove entries from the vector store.
PARAMETER | DESCRIPTION |
---|---|
ids |
The list of entries' IDs to remove.
TYPE:
|
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/chroma.py
list
async
#
list(where: WhereQuery | None = None, limit: int | None = None, offset: int = 0) -> list[VectorStoreEntry]
List entries from the vector store. The entries can be filtered, limited and offset.
PARAMETER | DESCRIPTION |
---|---|
where |
The filter dictionary - the keys are the field names and the values are the values to filter by. Not specifying the key means no filtering.
TYPE:
|
limit |
The maximum number of entries to return.
TYPE:
|
offset |
The number of entries to skip.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[VectorStoreEntry]
|
The entries. |
RAISES | DESCRIPTION |
---|---|
MetadataNotFoundError
|
If the metadata is not found. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/chroma.py
ragbits.core.vector_stores.qdrant.QdrantVectorStore
#
QdrantVectorStore(client: AsyncQdrantClient, index_name: str, embedder: Embedder, embedding_type: EmbeddingType = EmbeddingType.TEXT, distance_method: Distance = Distance.COSINE, default_options: VectorStoreOptions | None = None)
Bases: VectorStoreWithExternalEmbedder[VectorStoreOptions]
Vector store implementation using Qdrant.
Constructs a new QdrantVectorStore instance.
PARAMETER | DESCRIPTION |
---|---|
client |
An instance of the Qdrant client.
TYPE:
|
index_name |
The name of the index.
TYPE:
|
embedder |
The embedder to use for converting entries to vectors.
TYPE:
|
embedding_type |
Which part of the entry to embed, either text or image. The other part will be ignored.
TYPE:
|
distance_method |
The distance metric to use when creating the collection.
TYPE:
|
default_options |
The default options for querying the vector store.
TYPE:
|
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/qdrant.py
subclass_from_config
classmethod
#
Initializes the class with the provided configuration. May return a subclass of the class, if requested by the configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A model containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The class can't be found or is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
subclass_from_factory
classmethod
#
Creates the class using the provided factory function. May return a subclass of the class, if requested by the factory.
PARAMETER | DESCRIPTION |
---|---|
factory_path |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided factory function. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The factory can't be found or the object returned is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
preferred_subclass
classmethod
#
preferred_subclass(config: CoreConfig, factory_path_override: str | None = None, yaml_path_override: Path | None = None) -> Self
Tries to create an instance by looking at project's component preferences, either from YAML or from the factory. Takes optional overrides for both, which takes a higher precedence.
PARAMETER | DESCRIPTION |
---|---|
config |
The CoreConfig instance containing preferred factory and configuration details.
TYPE:
|
factory_path_override |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
yaml_path_override |
A string representing the path to the YAML file containing the Ragstack instance configuration.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
If the default factory or configuration can't be found. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
from_config
classmethod
#
Initializes the class with the provided configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A dictionary containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/qdrant.py
store
async
#
store(entries: list[VectorStoreEntry]) -> None
Stores vector entries in the Qdrant collection.
PARAMETER | DESCRIPTION |
---|---|
entries |
List of VectorStoreEntry objects to store
TYPE:
|
RAISES | DESCRIPTION |
---|---|
QdrantException
|
If upload to collection fails. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/qdrant.py
retrieve
async
#
retrieve(text: str, options: VectorStoreOptionsT | None = None) -> list[VectorStoreResult]
Retrieves entries from the Qdrant collection based on vector similarity.
PARAMETER | DESCRIPTION |
---|---|
text |
The text to query the vector store with.
TYPE:
|
options |
The options for querying the vector store.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[VectorStoreResult]
|
The retrieved entries. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/qdrant.py
remove
async
#
remove(ids: list[UUID]) -> None
Remove entries from the vector store.
PARAMETER | DESCRIPTION |
---|---|
ids |
The list of entries' IDs to remove.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If collection named |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/qdrant.py
list
async
#
list(where: WhereQuery | None = None, limit: int | None = None, offset: int = 0) -> list[VectorStoreEntry]
List entries from the vector store. The entries can be filtered, limited and offset.
PARAMETER | DESCRIPTION |
---|---|
where |
Conditions for filtering results. Reference: https://qdrant.tech/documentation/concepts/filtering
TYPE:
|
limit |
The maximum number of entries to return.
TYPE:
|
offset |
The number of entries to skip.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[VectorStoreEntry]
|
The entries. |
RAISES | DESCRIPTION |
---|---|
MetadataNotFoundError
|
If the metadata is not found. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/qdrant.py
ragbits.core.vector_stores.pgvector.PgVectorStore
#
PgVectorStore(client: Pool, table_name: str, vector_size: int, embedder: Embedder, embedding_type: EmbeddingType = EmbeddingType.TEXT, distance_method: str = 'cosine', hnsw_params: dict | None = None, default_options: VectorStoreOptions | None = None)
Bases: VectorStoreWithExternalEmbedder[VectorStoreOptions]
Vector store implementation using [pgvector]
Currently, doesn't support image embeddings when storing and retrieving entries. This will be added in the future.
Constructs a new PgVectorStore instance.
PARAMETER | DESCRIPTION |
---|---|
client |
The pgVector database connection pool.
TYPE:
|
table_name |
The name of the table.
TYPE:
|
vector_size |
The size of the vectors.
TYPE:
|
embedder |
The embedder to use for converting entries to vectors.
TYPE:
|
embedding_type |
Which part of the entry to embed, either text or image. The other part will be ignored.
TYPE:
|
distance_method |
The distance method to use.
TYPE:
|
hnsw_params |
The parameters for the HNSW index. If None, the default parameters will be used.
TYPE:
|
default_options |
The default options for querying the vector store.
TYPE:
|
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/pgvector.py
subclass_from_config
classmethod
#
Initializes the class with the provided configuration. May return a subclass of the class, if requested by the configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A model containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The class can't be found or is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
subclass_from_factory
classmethod
#
Creates the class using the provided factory function. May return a subclass of the class, if requested by the factory.
PARAMETER | DESCRIPTION |
---|---|
factory_path |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided factory function. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The factory can't be found or the object returned is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
preferred_subclass
classmethod
#
preferred_subclass(config: CoreConfig, factory_path_override: str | None = None, yaml_path_override: Path | None = None) -> Self
Tries to create an instance by looking at project's component preferences, either from YAML or from the factory. Takes optional overrides for both, which takes a higher precedence.
PARAMETER | DESCRIPTION |
---|---|
config |
The CoreConfig instance containing preferred factory and configuration details.
TYPE:
|
factory_path_override |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
yaml_path_override |
A string representing the path to the YAML file containing the Ragstack instance configuration.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
If the default factory or configuration can't be found. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
from_config
classmethod
#
Initializes the class with the provided configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A dictionary containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/base.py
create_table
async
#
Create a pgVector table with an HNSW index for given similarity.
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/pgvector.py
store
async
#
store(entries: list[VectorStoreEntry]) -> None
Stores entries in the pgVector collection.
PARAMETER | DESCRIPTION |
---|---|
entries |
The entries to store.
TYPE:
|
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/pgvector.py
remove
async
#
remove(ids: list[UUID]) -> None
Remove entries from the vector store.
PARAMETER | DESCRIPTION |
---|---|
ids |
The list of entries' IDs to remove.
TYPE:
|
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/pgvector.py
retrieve
async
#
retrieve(text: str, options: VectorStoreOptionsT | None = None) -> list[VectorStoreResult]
Retrieves entries from the pgVector collection.
PARAMETER | DESCRIPTION |
---|---|
text |
The text to query the vector store with.
TYPE:
|
options |
The options for querying the vector store.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[VectorStoreResult]
|
The retrieved entries. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/pgvector.py
list
async
#
list(where: WhereQuery | None = None, limit: int | None = None, offset: int = 0) -> list[VectorStoreEntry]
List entries from the vector store. The entries can be filtered, limited and offset.
PARAMETER | DESCRIPTION |
---|---|
where |
The filter dictionary - the keys are the field names and the values are the values to filter by. Not specifying the key means no filtering.
TYPE:
|
limit |
The maximum number of entries to return.
TYPE:
|
offset |
The number of entries to skip.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[VectorStoreEntry]
|
The entries. |