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 RAG
# 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.rag 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 = RAG(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.1.13-cp314-cp314-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.14Windows x86-64

fabricatio_rag-0.1.13-cp314-cp314-manylinux_2_34_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

fabricatio_rag-0.1.13-cp314-cp314-manylinux_2_34_aarch64.whl (2.9 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ ARM64

fabricatio_rag-0.1.13-cp314-cp314-macosx_11_0_arm64.whl (2.9 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

fabricatio_rag-0.1.13-cp313-cp313-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.13Windows x86-64

fabricatio_rag-0.1.13-cp313-cp313-manylinux_2_34_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

fabricatio_rag-0.1.13-cp313-cp313-manylinux_2_34_aarch64.whl (2.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ ARM64

fabricatio_rag-0.1.13-cp313-cp313-macosx_11_0_arm64.whl (2.9 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

fabricatio_rag-0.1.13-cp312-cp312-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.12Windows x86-64

fabricatio_rag-0.1.13-cp312-cp312-manylinux_2_34_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

fabricatio_rag-0.1.13-cp312-cp312-manylinux_2_34_aarch64.whl (2.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ ARM64

fabricatio_rag-0.1.13-cp312-cp312-macosx_11_0_arm64.whl (2.9 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: fabricatio_rag-0.1.13-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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.1.13-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 f65273216afc151237a5d9788c954a084b936f6ba361fc86376a4bdb57730e7b
MD5 c203f662d4f0e96a2d9c8c26a6121f85
BLAKE2b-256 b24ce1c62d0e7d8492e132fb59a720af09abbb3f304483ccb0eddf7553f0731d

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.1.13-cp314-cp314-manylinux_2_34_x86_64.whl.

File metadata

  • Download URL: fabricatio_rag-0.1.13-cp314-cp314-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 3.2 MB
  • Tags: CPython 3.14, manylinux: glibc 2.34+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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.1.13-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 1334e002266ec01e7138876d34e5ea0ea69f54b1e992ca568e5760abcc514e50
MD5 9de677dc6f1b2d8967a64d015453f5bf
BLAKE2b-256 f32257957952f4c758c33f62a4f7089bdceb92a4f157ce84fcd1c53e98dad6b1

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.1.13-cp314-cp314-manylinux_2_34_aarch64.whl.

File metadata

  • Download URL: fabricatio_rag-0.1.13-cp314-cp314-manylinux_2_34_aarch64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.14, manylinux: glibc 2.34+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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.1.13-cp314-cp314-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 1c81463e8eef88d81bbf6692402aaa8530424e21dabdcfb176ac460518705d79
MD5 84146482a73ab827e8b45a53351b2920
BLAKE2b-256 0630a7c9bd61eebde720c94be11b21f2d3c6b151627bc55097f43c83053112e9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.1.13-cp314-cp314-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.14, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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.1.13-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 547ecfba265c59b6e9ee14d97cfd1caee65c907fb60eb0af2d23a092a0f6ee26
MD5 a8872cf34713738f65afbe8a32a8a462
BLAKE2b-256 729ed5906d71b6ca610751ed0118ef7095dbcb87e7315a69575a37f9af5c0820

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.1.13-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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.1.13-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 429606ec1cdf43a0330f1dbc35c1b0c2ebfd69f7bcbe753ae1cd8afdc801efa9
MD5 8467497d4f6331f5f345a1ae701c8e47
BLAKE2b-256 5f979dc4b6eead18e9d9d8092735577c0790e606327b8c8727b93b9dde1cee58

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.1.13-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

  • Download URL: fabricatio_rag-0.1.13-cp313-cp313-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 3.2 MB
  • Tags: CPython 3.13, manylinux: glibc 2.34+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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.1.13-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 13e01ddf6fee3be6b65d1b233c9dd1a9d0d1aa9fe22b1be8e25b09874bf6b281
MD5 e7d04628707d6bf04c3c7b0c73f4f66e
BLAKE2b-256 97592e00fb48e513de8297acb335a6c4dabb0bcfa604e4680e6cead31d62d15f

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.1.13-cp313-cp313-manylinux_2_34_aarch64.whl.

File metadata

  • Download URL: fabricatio_rag-0.1.13-cp313-cp313-manylinux_2_34_aarch64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.13, manylinux: glibc 2.34+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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.1.13-cp313-cp313-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 67b571932438f02427fb221b39c255ba2ad2d1cc2b800bfbc31d5a0ab7ca6236
MD5 fe95813a9b3474b6ca5ce9e7c943b13a
BLAKE2b-256 5626b0851f621e4f4069ea289a7721e407d5e059781d5f20fa99d7590b27ffe9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.1.13-cp313-cp313-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.13, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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.1.13-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d5cca5e3a84e48555cf07dcb6111e9e620779f6d847bec017cc047d52cea2e06
MD5 2e2a0c9c9c53ce7909d601b34c7d9e4e
BLAKE2b-256 0c29ef364bce9cc5481b0c7d5312bf853b9f5fde2546740850d7b251d2cfe339

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.1.13-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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.1.13-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a527a25907ab4ca98938c5a27237c948e82bff7b5e9ab7d1ab30e55bb2190925
MD5 8888ea001d29be25da444609c2d8eac5
BLAKE2b-256 fc09b0acfff87453ef9a4d314b72beb8b89ea187ea5de7419e8f154b59b87807

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.1.13-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

  • Download URL: fabricatio_rag-0.1.13-cp312-cp312-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 3.2 MB
  • Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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.1.13-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 1676ca7b69c0d4a1fdfb2dab149264031d7c29dc5a944448a0dfb3da4bc64459
MD5 c906fe384e5be7dc446af6daeae3c001
BLAKE2b-256 43f778da45e151be7ecde3dd9747fa31de1470563061590700f5cb92aca1e514

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.1.13-cp312-cp312-manylinux_2_34_aarch64.whl.

File metadata

  • Download URL: fabricatio_rag-0.1.13-cp312-cp312-manylinux_2_34_aarch64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.12, manylinux: glibc 2.34+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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.1.13-cp312-cp312-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 7c75f350b2fa750e2dc3fd87751b43f2c4ebd19d6fab8e8cbbfea1b353e5f407
MD5 f2258162a0ac0b646a9126c6068f8b8e
BLAKE2b-256 37884bd591a81e5b850bb23eb1a19f1b9cc6d672d82cd5d5b4657f2f32654c32

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.1.13-cp312-cp312-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.12, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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.1.13-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 09ccd044b3d6d193d2199e5d60e67c0ed9915bc69c11c0baa640e2f3c3ebc802
MD5 1e03778b227e9b7d1d05a2a88ff7a9a9
BLAKE2b-256 c8ccff0898cffee8ec0d3e5ded2892982517d4e53166e63e4d0cebf4c16b3e1f

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