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

Milvus settings are loaded from the Fabricatio config system under the milvus namespace:

from fabricatio_milvus.config import milvus_config

# milvus_config.milvus_uri       → str | None
# milvus_config.milvus_timeout   → float | None
# milvus_config.milvus_token     → SecretStr | None
# milvus_config.milvus_dimensions → int | None

These can also be set per-instance via MilvusScopedConfig (pydantic model with the same fields).

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.4-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fabricatio_milvus-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 11.1 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e94b2513c9a97e6ac3230f0bb8e261acad145802b728b1cfd987d61cb35fd31b
MD5 805b923ef179979714827c9fc1defb63
BLAKE2b-256 33556db7d3a2b52787d184a4cbf567fc122c98b367c39161787bf2d6d8d9b18f

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.5

1 file

This release

0.3.4 This release

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