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

Uploaded CPython 3.14Windows x86-64

fabricatio_rag-0.2.2-cp314-cp314-manylinux_2_35_x86_64.whl (49.4 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.35+ x86-64

fabricatio_rag-0.2.2-cp314-cp314-manylinux_2_35_aarch64.whl (42.7 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.35+ ARM64

fabricatio_rag-0.2.2-cp314-cp314-macosx_11_0_arm64.whl (43.2 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

fabricatio_rag-0.2.2-cp313-cp313-win_amd64.whl (46.6 MB view details)

Uploaded CPython 3.13Windows x86-64

fabricatio_rag-0.2.2-cp313-cp313-manylinux_2_35_x86_64.whl (49.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.35+ x86-64

fabricatio_rag-0.2.2-cp313-cp313-manylinux_2_35_aarch64.whl (42.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.35+ ARM64

fabricatio_rag-0.2.2-cp313-cp313-macosx_11_0_arm64.whl (43.2 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

fabricatio_rag-0.2.2-cp312-cp312-win_amd64.whl (46.6 MB view details)

Uploaded CPython 3.12Windows x86-64

fabricatio_rag-0.2.2-cp312-cp312-manylinux_2_35_x86_64.whl (49.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.35+ x86-64

fabricatio_rag-0.2.2-cp312-cp312-manylinux_2_35_aarch64.whl (42.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.35+ ARM64

fabricatio_rag-0.2.2-cp312-cp312-macosx_11_0_arm64.whl (43.2 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.2-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 46.6 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.2-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 b1b4cba9538f10f2acf0387b9974aae8f62ab510b70e1e4adda90203ffc1e20b
MD5 fb6cef8050eea3519a7cff7a24af0b43
BLAKE2b-256 71542af575e127b2c0d65845e682a7fc95d0112d67322e246fe69e5b4f1d3444

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.2-cp314-cp314-manylinux_2_35_x86_64.whl
  • Upload date:
  • Size: 49.4 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.2-cp314-cp314-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 554654430e6341ffa18c2250dcec3633ee6b8a118d4e5ba361cb0342ed29d0e2
MD5 eea5df5369066319fffd1493a1206596
BLAKE2b-256 9216d4943815584d5d454fd0fbbde6461a1af57155c176ac55f4689ca42f4482

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.2-cp314-cp314-manylinux_2_35_aarch64.whl
  • Upload date:
  • Size: 42.7 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.2-cp314-cp314-manylinux_2_35_aarch64.whl
Algorithm Hash digest
SHA256 def5e7578021f2910762c91b5060b0d8295df628b46737923fb1b33ec9dc750a
MD5 82868fcc33fa2850dad275d002656c21
BLAKE2b-256 0f745389ea6e916f69f06cc0f449b2768469598175848121782e73944a75ed98

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.2-cp314-cp314-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 43.2 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.2-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8c3ecb9ea165449b6d8b39f49e8d173547b2a75c0d339537e5c8d0920ed7c245
MD5 019a82334cf9efd0d67d39a0671ef7db
BLAKE2b-256 85c6f013e60a7ca585a709a79cf6b411eec4ad8e3c7d88c91735815e6077a4ad

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 46.6 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.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 0cef278a50d7e97959ddad39024513dd393bb49a97693269ce293a460717f8fe
MD5 c31f160a90cb65535c8d31c30055ba95
BLAKE2b-256 d9526df918803122b7a9c74c988e07963982aeec7659136e6c93613f7a17d2fd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.2-cp313-cp313-manylinux_2_35_x86_64.whl
  • Upload date:
  • Size: 49.4 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.2-cp313-cp313-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 f7fa6132d228fd2b98a1002716d17d1f16f6cf3142fd00972cc0cd2e492f2dfd
MD5 fc6d02cc15f87444bfa28b569454e7f6
BLAKE2b-256 beae95774e8a1941e46b6b171cf91e78d2a72112fdd2a3be5e46bdef19c066ec

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.2-cp313-cp313-manylinux_2_35_aarch64.whl
  • Upload date:
  • Size: 42.7 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.2-cp313-cp313-manylinux_2_35_aarch64.whl
Algorithm Hash digest
SHA256 0848fa10295500902a9a7462711f16cccb66b27d8d986b7c2f51649aa5e36285
MD5 8abba3d4c94d7382da38a0fb4916d1f9
BLAKE2b-256 2e839c08a41f39a89dfdba60dfc6cab1a07043b97045211e639ba81cf7a8fa66

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.2-cp313-cp313-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 43.2 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.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9c3e6d8f6c5e65099837624e111379dfa2386364257dc35bcf78faa852021053
MD5 5f57d1008cc1b744cfc74226e5966b24
BLAKE2b-256 e95e022b621f261181b167a1a840abaa4beb26f39f2f53ccedda0ad00a957d60

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 46.6 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.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9bf69c23c1124bc73e55bef6e04d9808040cd631554f09cfe861e556f690f9ae
MD5 ed9bd6fa992c5b3ee99ee0e35a06038a
BLAKE2b-256 f2f6f8bc81ec14611cd042d76f5f135d114dabafed75f04a8a555a2bec9428b9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.2-cp312-cp312-manylinux_2_35_x86_64.whl
  • Upload date:
  • Size: 49.4 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.2-cp312-cp312-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 9f091c203e42c9c5f044d4bd39c409c261fa0cef13bea4b008b242a9fbae612d
MD5 28a16f8d7cbf06de2679d35ec22120c8
BLAKE2b-256 13c23cee18098ebeffd46558113a97dcf8ef3c9231957e763f1a1926251f618e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.2-cp312-cp312-manylinux_2_35_aarch64.whl
  • Upload date:
  • Size: 42.7 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.2-cp312-cp312-manylinux_2_35_aarch64.whl
Algorithm Hash digest
SHA256 11f9779b3ba2d9c5f0d3df1260ff460f234a5481481b35f74247627c61d09121
MD5 7d182d49f7e984d617db54ff019e835a
BLAKE2b-256 24787ed7b7d6c5362046968795ed222f4976510ec3e1eea3fcf517a39654c5e0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.2-cp312-cp312-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 43.2 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.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6d9c34e34df51457ed8deab321198d5af425427a43eb873b5a27fbecca03236d
MD5 e56d42a9e6670a61a79b377701b24d73
BLAKE2b-256 ab3f369c3fb561d8bf2669c1f4c52210413ecd2f32980408eaddc25fa4b98371

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