Skip to content

Vectorstores

flowtask.interfaces.vectorstores

abstract

AbstractStore

AbstractStore(*args, **kwargs)

Bases: ABC

AbstractStore class.

Parameters:

Name Type Description Default
embedding_model dict

Embeddings.

required

milvus

MilvusStore

MilvusStore(*args, **kwargs)

Bases: AbstractStore, CredentialsInterface

Interface for managing document storage in Milvus using LangChain.

connect async
connect(alias=None)

Connects to the Milvus database.

create_collection async
create_collection(collection_name, origin=None, dimension=768, index_type='HNSW', metric_type='L2', **kwargs)

Create a Milvus collection based on an origin.

Parameters:

Name Type Description Default
collection_name str

Name of the Milvus collection.

required
origin Union[str, Path, Any]

None for minimal schema, Path for Avro file, or dataclass for schema.

None
dimension int

Dimension of the vector field. Defaults to 768.

768
index_type str

Index type for vector field. Defaults to "HNSW".

'HNSW'
metric_type str

Metric type for vector index. Defaults to "L2".

'L2'

Returns:

Name Type Description
dict dict

Result of the collection creation.

create_default_collection async
create_default_collection(collection_name, document=None, dimension=768, index_type=None, metric_type=None, schema_type='default', database=None, metadata_field=None, **kwargs)

create_collection.

Create a Schema (Milvus Collection) on the Current Database.

Parameters:

Name Type Description Default
collection_name str

Collection Name.

required
document Any

List of Documents.

None
dimension int

Vector Dimension. Defaults to 768.

768
index_type str

Default index type of Vector Field. Defaults to "HNSW".

None
metric_type str

Default Metric for Vector Index. Defaults to "L2".

None
schema_type str

Description of Model. Defaults to 'default'.

'default'

Returns:

Name Type Description
dict dict

description

delete_documents_by_attr async
delete_documents_by_attr(collection_name, attribute_name, attribute_value)

Deletes documents in the Milvus collection that match a specific attribute.

This asynchronous method removes documents from a specified Milvus collection where the given attribute matches the provided value.

Parameters:

Name Type Description Default
collection_name str

The name of the Milvus collection to delete from.

required
attribute_name str

The name of the attribute to filter on.

required
attribute_value str

The value of the attribute to match for deletion.

required

Raises:

Type Description
Exception

If the deletion operation fails, the error is logged and re-raised.

Returns:

Type Description

None

Note

The method logs a notice with the number of deleted documents upon successful deletion.

load_documents async
load_documents(documents, upsert=True, collection=None, pk='source_type', dimension=768, index_type='HNSW', metric_type='L2', **kwargs)

Loads LangChain documents into the Milvus collection.

Parameters:

Name Type Description Default
documents List[Document]

List of LangChain Document objects.

required
upsert bool

If True, delete existing documents with matching attributes before inserting.

True
pk str

str: If upsert True, Key to be used for deleting documents before inserting.

'source_type'
collection str

Name of the collection.

None