Skip to main content

fabricatio-milvus

MIT Python Versions PyPI Version PyPI Downloads PyPI Downloads Build Tool: uv

Milvus vector database integration for Fabricatio — store, search, and retrieve document embeddings with the Fabricatio RAG framework.

Installation

pip install fabricatio[milvus]

Or install all Fabricatio components:

pip install fabricatio[full]

Overview

fabricatio-milvus extends Fabricatio's RAG (Retrieval-Augmented Generation) system with a Milvus vector database backend. It provides:

  • Pydantic-based document models that auto-generate Milvus collection schemas from field type annotations.
  • A MilvusRAG capability class implementing the add_document/afetch_document/aretrieve contract backed by pymilvus.
  • Ready-to-use Action subclasses (InjectToDB, MilvusRAGTalk) for building agent pipelines.

Configuration

All options below are read through the fabricatio configuration chain (see the Configuration Guide at ../../docs/source/configuration.rst). Set them under the [ext.milvus] table in fabricatio.toml, equivalently under [tool.fabricatio.ext.milvus] in pyproject.toml, or via FABRICATIO_EXT__MILVUS__<FIELD_UPPER> environment variables.

# fabricatio.toml
[ext.milvus]
milvus_uri = "http://localhost:19530"
milvus_timeout = 10.0
milvus_dimensions = 1536
Option Type Default Description
milvus_uri Optional[str] None The URI of the Milvus server.
milvus_timeout Optional[float] None The timeout of the Milvus server in seconds.
milvus_token Optional[SecretStr] None The token for Milvus authentication.
milvus_dimensions Optional[int] None The dimensions for Milvus vectors.

Access at runtime: from fabricatio_milvus.config import milvus_config.

Key Components

Models — fabricatio_milvus.models

Class Description
MilvusDataBase[ST] Abstract base combining StoredDocumentModel and SearchedDocumentModel. Generates Milvus CollectionSchema from Pydantic fields (intINT64, strVARCHAR, floatDOUBLE, list[str]ARRAY[VARCHAR], JsonValueJSON). Default index type FLAT, metric type COSINE.
MilvusClassicModel[SD] Minimal concrete model with a single text: str field.
MilvusScopedConfig Per-instance override for Milvus connection parameters (uri, token, timeout, dimensions).

Capabilities — fabricatio_milvus.capabilities

Class / Function Description
create_client(uri, token, timeout) Cached factory returning a pymilvus.MilvusClient.
AddConfig Configuration for add_document: collection_name, flush.
FetchConfig[D] Configuration for afetch_document: document_model, collection_name, similarity_threshold (default 0.37), result_per_query (default 10), tei_endpoint, reranker_threshold, filter_expr.
MilvusRAG[D, AC, FC] Core RAG class backed by Milvus. Inherits from RAG, MilvusScopedConfig, UseEmbedding, UseReranker, UseLLM.

MilvusRAG methods:

  • client — property returning the MilvusClient, eagerly created on construction from config.
  • add_document(data, config) — vectorize documents and insert into a collection. Creates the collection if it doesn't exist.
  • afetch_document(query, config) — vectorize query strings, search Milvus, deduplicate by ID, sort by distance descending, and deserialize into typed document models.
  • aretrieve(query, document_model, ...) — convenience wrapper that builds a FetchConfig and calls afetch_document.

Actions — fabricatio_milvus.actions

Action Description
InjectToDB Action that injects MilvusDataBase instances into a Milvus collection. Automatically creates the collection with the correct schema and index if needed. Supports override_inject to drop and recreate.
MilvusRAGTalk Interactive RAG conversation loop. Queries Milvus with user input, retrieves relevant documents, augments the LLM prompt, and returns generated responses. Runs until the user exits.

Usage Example

from fabricatio_milvus.actions.rag import InjectToDB
from fabricatio_milvus.models.milvus import MilvusClassicModel

# Create document models
docs = [
    MilvusClassicModel(text="Fabricatio is a Python library for building LLM applications."),
    MilvusClassicModel(text="Milvus is an open-source vector database."),
]

# Inject into Milvus
action = InjectToDB(
    collection_name="my_knowledge_base",
    milvus_uri="http://localhost:19530",
)
await action.execute(to_inject=docs)

Dependencies

  • fabricatio-core — core interfaces, config, and utilities
  • fabricatio-rag — RAG abstractions (RAG, document models)
  • pymilvus (>=2.5.4) — Milvus Python SDK
  • pydantic (>=2.7.1) — data validation and schema generation
  • more-itertools (>=10.8.0) — additional itertools

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fabricatio_milvus-0.3.5-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file fabricatio_milvus-0.3.5-py3-none-any.whl.

File metadata

  • Download URL: fabricatio_milvus-0.3.5-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for fabricatio_milvus-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 9874e490687ca0ff59b795f284aa96e0bf21f12c41472d69086bc2ca6b5b0eaa
MD5 56dccda46015c5532746939e0431c413
BLAKE2b-256 707fd00e220510a92b446dc4df872f666d4b8979b6fe3fa80694e9af0d171842

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.5 This release

1 file

0.3.4

1 file

0.3.3

1 file

0.3.2

1 file

0.3.1

1 file

0.3.0

1 file

0.2.1

1 file

0.2.0

1 file

0.1.1

1 file

0.1.0

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page