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.3-cp314-cp314-win_amd64.whl (47.0 MB view details)

Uploaded CPython 3.14Windows x86-64

fabricatio_rag-0.2.3-cp314-cp314-manylinux_2_34_x86_64.whl (49.8 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

fabricatio_rag-0.2.3-cp314-cp314-manylinux_2_34_aarch64.whl (43.0 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ ARM64

fabricatio_rag-0.2.3-cp314-cp314-macosx_11_0_arm64.whl (43.5 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

fabricatio_rag-0.2.3-cp313-cp313-win_amd64.whl (47.0 MB view details)

Uploaded CPython 3.13Windows x86-64

fabricatio_rag-0.2.3-cp313-cp313-manylinux_2_34_x86_64.whl (49.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

fabricatio_rag-0.2.3-cp313-cp313-manylinux_2_34_aarch64.whl (43.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ ARM64

fabricatio_rag-0.2.3-cp313-cp313-macosx_11_0_arm64.whl (43.5 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

fabricatio_rag-0.2.3-cp312-cp312-win_amd64.whl (47.0 MB view details)

Uploaded CPython 3.12Windows x86-64

fabricatio_rag-0.2.3-cp312-cp312-manylinux_2_34_x86_64.whl (49.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

fabricatio_rag-0.2.3-cp312-cp312-manylinux_2_34_aarch64.whl (43.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ ARM64

fabricatio_rag-0.2.3-cp312-cp312-macosx_11_0_arm64.whl (43.5 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.3-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 47.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.3-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 700fa47a3c2817ef1168ad8033e9e065cd5ed5bd5f98eb655dd342406eeed904
MD5 4faf5b00cd78fa2985f0cdd0fe5d90e6
BLAKE2b-256 d0de0423ee08ef65d077d6361b5126f34ccf868f8e610b07927e6b80c5de6a94

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.3-cp314-cp314-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 49.8 MB
  • Tags: CPython 3.14, manylinux: glibc 2.34+ 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.3-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 80a9a1bad4255a33710fbfa73104d4ebffa8d983e7065b81b0e74597248630c6
MD5 04f6de58917ebfa8062fa7125e8f4bfa
BLAKE2b-256 3d0ec4b6ec5702bdbf678f7b395bd3b3fb273f5f679dd7b4b0f5d89f8c896323

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.3-cp314-cp314-manylinux_2_34_aarch64.whl
  • Upload date:
  • Size: 43.0 MB
  • Tags: CPython 3.14, manylinux: glibc 2.34+ 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.3-cp314-cp314-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 3ffe30bafb46fcc5b5965bb76e7e7ea780b50a7a156056d3021d9c2892f5d64c
MD5 e3da3f74ce24c107717a659b14db99f1
BLAKE2b-256 c13e049634f866f47d289f3f27e72c3894d4865eb69d1e50a0881845d79d0c88

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.3-cp314-cp314-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 43.5 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.3-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d9393bd2730ed7c1a3ede99bf5beaaa71631cb989783a34e58400ccadca9140a
MD5 6886ec0920509e4c3614399daa9def33
BLAKE2b-256 485bef00cf688ff623d4162c4a7d415d920a44bf5dc78734a73b847e4aabb981

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 47.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.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ce97b9dbd310556725fd5f3655de7ed329c599add32328e14af7ce190c46ffa9
MD5 717dc5dbd0a1ddbc706cc9cd6d172718
BLAKE2b-256 b9f0de012f0618d01104fae51a3600d320a736cebae36958094b0521f02ac4ca

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.3-cp313-cp313-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 49.8 MB
  • Tags: CPython 3.13, manylinux: glibc 2.34+ 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.3-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 e700e919186196d47a33a358213b8cfb9fa91f696d2b39f64e503d6517ce9dd3
MD5 83d013aad9e176a9e3640804c1456970
BLAKE2b-256 171621492d3192292c2284adf9d125aa494347bc565f77ea42bafa008d9ff9ab

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.3-cp313-cp313-manylinux_2_34_aarch64.whl
  • Upload date:
  • Size: 43.0 MB
  • Tags: CPython 3.13, manylinux: glibc 2.34+ 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.3-cp313-cp313-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 e191336e8cd6e148846060281d2024386f51888189c75cbce686b3e826a8a4d7
MD5 1ac25111a9dd5e8c780cae499166b1f8
BLAKE2b-256 64a06f9f8117eef7d62dea82f1012f7b0a41e5a53f21378af2a9cac8b714d7fa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.3-cp313-cp313-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 43.5 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.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e6d9b09ab9ef30da759d90a0093ec7b5dbda626d32935e7fe6bbe9429aada56e
MD5 9143072b2a68337e6504b572b0988e3b
BLAKE2b-256 440e403d3b0a93ba57f1c9de8d80b129771b45218f627f30212f7b3fadf48824

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 47.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.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 73693b855019eb0567791a2b1e7772be33151be41fa3185dc0883df791cfd937
MD5 40ef3b6a82cea37cbc7b052a01489cc7
BLAKE2b-256 fc25a1cdc8df048610d2ab7cb6102e3c63288d98fe9292f8772f7f8c84c17a75

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.3-cp312-cp312-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 49.8 MB
  • Tags: CPython 3.12, manylinux: glibc 2.34+ 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.3-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 239b9e62399369e0799bd41964e026bf0b8b7c83ddb3a24c4676397530b86c0f
MD5 0f87e54a5ce3adf9924b9b94776961e8
BLAKE2b-256 b16c16ac7dab4bb27f09fbda9221dcb7b3b7f9a32b1c051f1f3c1a0d2067ac92

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.3-cp312-cp312-manylinux_2_34_aarch64.whl
  • Upload date:
  • Size: 43.0 MB
  • Tags: CPython 3.12, manylinux: glibc 2.34+ 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.3-cp312-cp312-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 dd0b8b39155dd14746bc5d75d373e87223dc10f4d4d732da21c510af904c0d6a
MD5 200291aab94d869059b71f49ae61f742
BLAKE2b-256 ed62fd04b933e0553a06021e6f4ccf148da1fafe2668a5067302153522e91cac

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.3-cp312-cp312-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 43.5 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.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ce8eedafcac4d736bd269f7730eb167a0cd98acd87c80181945f48355052277a
MD5 e10775e4e4f4763c8390c8172c8482d4
BLAKE2b-256 6c8557bf20b8d3b8d42957651fc4bf4995c628dc028ca1827ffd8707be6b7beb

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