Skip to main content

A Python library for Retrieval-Augmented Generation (RAG) capabilities in LLM applications.

Project description

fabricatio-rag

MIT Python Versions PyPI Version PyPI Downloads PyPI Downloads Bindings: PyO3 Build Tool: uv + maturin

A Python library for Retrieval-Augmented Generation (RAG) capabilities in LLM applications.

📦 Installation

This package is part of the fabricatio monorepo and can be installed as an optional dependency using either pip or uv:

pip install fabricatio[rag]
# or
uv pip install fabricatio[rag]

For a full installation that includes this package and all other components of fabricatio:

pip install fabricatio[full]
# or
uv pip install fabricatio[full]

🔍 Overview

Provides tools for:

  • Document embedding and vector storage using Milvus This feature uses the Milvus vector database to store document embeddings. Document embeddings are numerical representations of text documents that capture their semantic meaning. The library first converts text documents into embeddings using appropriate embedding models. These embeddings are then stored in Milvus, which provides efficient storage and retrieval capabilities. For example, it can handle large - scale document collections and perform fast similarity searches.
  • Semantic search and context retrieval The semantic search and context retrieval feature allows users to search for relevant documents based on the meaning of their queries. It uses the stored document embeddings in Milvus to find documents that are semantically similar to the query. This is more powerful than traditional keyword - based search as it can understand the intent behind the query. For example, if a user searches for "effects of pollution on wildlife", it can retrieve documents that discuss related concepts even if the exact keywords are not present.
  • Integration with TEI (Text Embeddings Inference) services The integration with TEI services enables the generation of text embeddings. TEI services provide pre - trained models that can convert text into embeddings. The library can send text data to the TEI service and receive the corresponding embeddings. This allows for the use of state - of - the - art embedding models without having to manage the model training and inference process locally.
  • Database injection workflows The database injection workflows are responsible for inserting new documents into the Milvus database. It takes care of the process of converting the documents into embeddings, and then inserting them into the appropriate collections in Milvus. This includes handling tasks such as collection creation, data indexing, and error handling.
  • Asynchronous RAG execution patterns The asynchronous RAG execution patterns allow the library to perform multiple RAG tasks concurrently without blocking the main thread. This is useful for improving the performance and responsiveness of the application. For example, it can handle multiple user queries simultaneously, reducing the overall response time.

Built on top of Fabricatio's agent framework with support for asynchronous execution and Rust extensions.

🧩 Usage Example

from fabricatio_rag.capabilities.rag import MilvusRAG
# The `RAG` class is the core component of the library. It provides methods for performing retrieval - augmented generation tasks. It interacts with the Milvus database for document retrieval and uses the generated embeddings to augment the generation process.
from fabricatio_rag.models.milvus import MilvusDataBase


# The `MilvusDataBase` class represents the connection to the Milvus vector database. It provides methods for creating collections, inserting documents, and performing searches. It abstracts the low - level details of working with Milvus, making it easier to use in the application.


async def search_knowledge():
    # Initialize database connection
    db = MilvusDataBase(collection_name="science_papers")
    # This line initializes a connection to the Milvus database with a specific collection named "science_papers". The collection is where the document embeddings will be stored and retrieved from.

    # Initialize RAG capability
    rag = MilvusRAG(db)
    # This line creates an instance of the `RAG` class, passing in the `MilvusDataBase` object. This allows the `RAG` class to interact with the Milvus database for document retrieval.

    # Search for relevant information
    results = await rag.retrieve("climate change impact on coral reefs", limit=3)
    # The `retrieve` method of the `RAG` class is used to perform a semantic search in the Milvus database. It takes a query string and a limit as parameters. In this example, it searches for documents related to "climate change impact on coral reefs" and returns the top 3 relevant documents.

    print("Top 3 relevant documents:")
    for result in results:
        print(f"- {result['title']}")
        print(f"  Relevance: {result['score']:.2f}")
        print(f"  Snippet: {result['text'][:150]}...")

📁 Structure

fabricatio-rag/
├── actions/          - Data injection workflows
├── capabilities/     - Core RAG functionality
├── models/           - Database and query models
├── proto/            - TEI service definitions
└── rust.pyi          - Rust extension interfaces

🔗 Dependencies

Core dependencies:

  • pymilvus>=2.5.4 - Vector database integration
  • fabricatio-core - Core interfaces and utilities

Rust extensions:

  • TEI client bindings
  • Protobuf definitions for gRPC communication

📄 License

MIT – see LICENSE

Project details


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 Distributions

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

fabricatio_rag-0.2.0-cp314-cp314-win_amd64.whl (48.0 MB view details)

Uploaded CPython 3.14Windows x86-64

fabricatio_rag-0.2.0-cp314-cp314-manylinux_2_35_x86_64.whl (50.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.35+ x86-64

fabricatio_rag-0.2.0-cp314-cp314-manylinux_2_35_aarch64.whl (43.5 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.35+ ARM64

fabricatio_rag-0.2.0-cp314-cp314-macosx_11_0_arm64.whl (43.9 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

fabricatio_rag-0.2.0-cp313-cp313-win_amd64.whl (48.0 MB view details)

Uploaded CPython 3.13Windows x86-64

fabricatio_rag-0.2.0-cp313-cp313-manylinux_2_35_x86_64.whl (50.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.35+ x86-64

fabricatio_rag-0.2.0-cp313-cp313-manylinux_2_35_aarch64.whl (43.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.35+ ARM64

fabricatio_rag-0.2.0-cp313-cp313-macosx_11_0_arm64.whl (43.9 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

fabricatio_rag-0.2.0-cp312-cp312-win_amd64.whl (48.0 MB view details)

Uploaded CPython 3.12Windows x86-64

fabricatio_rag-0.2.0-cp312-cp312-manylinux_2_35_x86_64.whl (50.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.35+ x86-64

fabricatio_rag-0.2.0-cp312-cp312-manylinux_2_35_aarch64.whl (43.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.35+ ARM64

fabricatio_rag-0.2.0-cp312-cp312-macosx_11_0_arm64.whl (43.9 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

Details for the file fabricatio_rag-0.2.0-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: fabricatio_rag-0.2.0-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 48.0 MB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for fabricatio_rag-0.2.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 1d962ea2c338ccef86b0b9873cc184ea61f1d95db961dc611166dfac363ee449
MD5 cdd7edd8ed81d86a8b7ca31244598095
BLAKE2b-256 134933ea379d56160533301ed3db40088d28ac107702b0e9556e81eb69ab28e8

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.2.0-cp314-cp314-manylinux_2_35_x86_64.whl.

File metadata

  • Download URL: fabricatio_rag-0.2.0-cp314-cp314-manylinux_2_35_x86_64.whl
  • Upload date:
  • Size: 50.2 MB
  • Tags: CPython 3.14, manylinux: glibc 2.35+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","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_rag-0.2.0-cp314-cp314-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 49b9937ca5a27b82fc6722a26d19922a1194e1d32ab5f952200feee733c9aa95
MD5 fe4806da45ef7b9d59a560cfbdb56019
BLAKE2b-256 ba761fec610c0c12ea4f166104ed1bf74e9e8c6d7eb0c434dd1e924ab79c0a02

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.2.0-cp314-cp314-manylinux_2_35_aarch64.whl.

File metadata

  • Download URL: fabricatio_rag-0.2.0-cp314-cp314-manylinux_2_35_aarch64.whl
  • Upload date:
  • Size: 43.5 MB
  • Tags: CPython 3.14, manylinux: glibc 2.35+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","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_rag-0.2.0-cp314-cp314-manylinux_2_35_aarch64.whl
Algorithm Hash digest
SHA256 cbd9112d37c5fcf652607e20d9c73de035dfd1698482e32123f08b964bda5086
MD5 b60609df78d9478a71a8355d2b4f9383
BLAKE2b-256 2315e22066bf1fe3bb13b74174c8f4462449aafeb967bb6cc9bb99e9cb040db1

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.2.0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

  • Download URL: fabricatio_rag-0.2.0-cp314-cp314-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 43.9 MB
  • Tags: CPython 3.14, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"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_rag-0.2.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a869d36b9a858c92551ef45ee8147d6c240ff6eb127dbc7772f086ee5ba8d3c8
MD5 ba1242e2ceba054cb15dcb868ff87317
BLAKE2b-256 3241d1fa4106c9029dbef00e389e5909b605160f314d27769d10ce3846f2294c

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.2.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: fabricatio_rag-0.2.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 48.0 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for fabricatio_rag-0.2.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c40cf86ed9d7f976a0aa3a95f3945990abc5c5c6804f51f12d99455efa059c04
MD5 decf9137a0bfe75f3d1babdd79e88bae
BLAKE2b-256 2958c65e6f3a0b7ba81f7eae5d4e415a3b125a8036bf12866fc8add8a9d95b09

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.2.0-cp313-cp313-manylinux_2_35_x86_64.whl.

File metadata

  • Download URL: fabricatio_rag-0.2.0-cp313-cp313-manylinux_2_35_x86_64.whl
  • Upload date:
  • Size: 50.2 MB
  • Tags: CPython 3.13, manylinux: glibc 2.35+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","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_rag-0.2.0-cp313-cp313-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 d22e3ba7773f2b58d9a718bc576f171ca6a786d53425684d98639386ef22fde5
MD5 34fd4c93992b64b99549ece6387caf19
BLAKE2b-256 f8687484df5bba7207fff5a560a1a8892797a599af5b9fa7f06322480a625dee

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.2.0-cp313-cp313-manylinux_2_35_aarch64.whl.

File metadata

  • Download URL: fabricatio_rag-0.2.0-cp313-cp313-manylinux_2_35_aarch64.whl
  • Upload date:
  • Size: 43.5 MB
  • Tags: CPython 3.13, manylinux: glibc 2.35+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","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_rag-0.2.0-cp313-cp313-manylinux_2_35_aarch64.whl
Algorithm Hash digest
SHA256 b9089a95b08abd525b0f896be18492768a5e431931bb8d0796bbf935dcd5c987
MD5 c67c910de48335a0bcd12452216b1d09
BLAKE2b-256 60cfd2c32361cd3e409f33337eb86dd4e5a6a2f508d016f340f06b947ee87713

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.2.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

  • Download URL: fabricatio_rag-0.2.0-cp313-cp313-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 43.9 MB
  • Tags: CPython 3.13, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"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_rag-0.2.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b7fd31d2d60b7fbf4dedc8115c04f829081a9b12ea86541d4453b9914e75632b
MD5 468ea516c07623986ba5493c68337a50
BLAKE2b-256 ff5876828d474e69fc58a25485b3bb861982de37cd1a3ae7063c217ea56d0a10

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.2.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: fabricatio_rag-0.2.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 48.0 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for fabricatio_rag-0.2.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 81d72a8b8a586f894f1390e3157a14a3424fe2514faa6d0aa9adef21497100f8
MD5 f6748994abbc4bcbf974927eef77c2a1
BLAKE2b-256 526880b1fe4bb7dc66c2f8a1966fee2c6c54c62090f465c31d7af76d1cd8288f

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.2.0-cp312-cp312-manylinux_2_35_x86_64.whl.

File metadata

  • Download URL: fabricatio_rag-0.2.0-cp312-cp312-manylinux_2_35_x86_64.whl
  • Upload date:
  • Size: 50.3 MB
  • Tags: CPython 3.12, manylinux: glibc 2.35+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","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_rag-0.2.0-cp312-cp312-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 7979ade55059af7c531ff653fb7baf51698ec32af21358c72664106249db37af
MD5 f7406554ec517ec89e7f6420f67bcfcc
BLAKE2b-256 222d1a74ad4f40fcb9e9f11388393596879ed94a5344ebd2bebd879aeb1b1b70

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.2.0-cp312-cp312-manylinux_2_35_aarch64.whl.

File metadata

  • Download URL: fabricatio_rag-0.2.0-cp312-cp312-manylinux_2_35_aarch64.whl
  • Upload date:
  • Size: 43.5 MB
  • Tags: CPython 3.12, manylinux: glibc 2.35+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","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_rag-0.2.0-cp312-cp312-manylinux_2_35_aarch64.whl
Algorithm Hash digest
SHA256 08b9f6808bb95c35bf4b3b907dbf4c6f46a7021e1485a285fb333d64696f97bb
MD5 dfe58e6eb15b32e3790613d9c0d5f6a4
BLAKE2b-256 ae9df0ae98c09c1de52b7d082973245e6fb7adc4cfc10b0116f6311a48d4191e

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.2.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

  • Download URL: fabricatio_rag-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 43.9 MB
  • Tags: CPython 3.12, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"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_rag-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8b60e74ef35dd9772d6c920af6355479ee9abc2485383a3213ac65f5f01b9d15
MD5 b62336f2d37a52aea47b7942883a4664
BLAKE2b-256 2d6d594db259f57bd52c7d0c98f0cb29280def46fa9ef8f11bf556b4fcb76b9c

See more details on using hashes here.

Supported by

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