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.12.dev0-cp314-cp314-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.14Windows x86-64

fabricatio_rag-0.1.12.dev0-cp314-cp314-manylinux_2_34_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

fabricatio_rag-0.1.12.dev0-cp314-cp314-manylinux_2_34_aarch64.whl (2.6 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ ARM64

fabricatio_rag-0.1.12.dev0-cp314-cp314-macosx_11_0_arm64.whl (2.6 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

fabricatio_rag-0.1.12.dev0-cp313-cp313-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.13Windows x86-64

fabricatio_rag-0.1.12.dev0-cp313-cp313-manylinux_2_34_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

fabricatio_rag-0.1.12.dev0-cp313-cp313-manylinux_2_34_aarch64.whl (2.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ ARM64

fabricatio_rag-0.1.12.dev0-cp313-cp313-macosx_11_0_arm64.whl (2.6 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

fabricatio_rag-0.1.12.dev0-cp312-cp312-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.12Windows x86-64

fabricatio_rag-0.1.12.dev0-cp312-cp312-manylinux_2_34_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

fabricatio_rag-0.1.12.dev0-cp312-cp312-manylinux_2_34_aarch64.whl (2.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ ARM64

fabricatio_rag-0.1.12.dev0-cp312-cp312-macosx_11_0_arm64.whl (2.6 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

Details for the file fabricatio_rag-0.1.12.dev0-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: fabricatio_rag-0.1.12.dev0-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","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.12.dev0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 0defb16b9add70e3625b926a656931e7cccc14f513ae29057ae1df660a787553
MD5 aee96adcbf279effe0a76128759687c4
BLAKE2b-256 3b0145b6b19f1842ca8df479b1b836af2110342a839c21cb684595d011c10651

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.1.12.dev0-cp314-cp314-manylinux_2_34_x86_64.whl.

File metadata

  • Download URL: fabricatio_rag-0.1.12.dev0-cp314-cp314-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.14, manylinux: glibc 2.34+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","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.12.dev0-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 7d107c0b368b7b32345a073a2ddc82231b161236bba10d0eb9378e0572a2c7a2
MD5 83fc5f81a62e0784c867fc09ee0ef072
BLAKE2b-256 2924707cdb601349cddcadbaf62711765b70f807d8e7228f4a6b7f0482b0d695

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.1.12.dev0-cp314-cp314-manylinux_2_34_aarch64.whl.

File metadata

  • Download URL: fabricatio_rag-0.1.12.dev0-cp314-cp314-manylinux_2_34_aarch64.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: CPython 3.14, manylinux: glibc 2.34+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","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.12.dev0-cp314-cp314-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 4ba77e29f9ea9559f4cba3f848c0e8518839e73477edac066c8b72550389c9ce
MD5 b1e1468ea2d96486ad140002d4c92698
BLAKE2b-256 a93071df2006e0a763d839dd60f80087a85c6c23c4654c854be833b741e19d52

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.1.12.dev0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

  • Download URL: fabricatio_rag-0.1.12.dev0-cp314-cp314-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: CPython 3.14, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","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.12.dev0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 84eab67ffd6d60bed98cf392c7f1c2fbe379b6510371310066569219e4bb6337
MD5 7460a4ba61d49364bb5e50c049e824ac
BLAKE2b-256 a1b0fcb2815f931b1ab5790133c15783d7bceeeae488bfbe245d34f5ee45ae5d

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.1.12.dev0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: fabricatio_rag-0.1.12.dev0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","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.12.dev0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 d00ee221f76d0346c8c97162eb8d725b386725f27d38caf658912246fe403820
MD5 bba4d79a720060d83469b812cc54a433
BLAKE2b-256 79c310c7289f9be80d52396d2298d363c6061b48938a4082cb24299d290662d3

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.1.12.dev0-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

  • Download URL: fabricatio_rag-0.1.12.dev0-cp313-cp313-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.13, manylinux: glibc 2.34+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","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.12.dev0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 3fa5cc64aedd153c2098d889f0c138e4937a6b025ad3576da771adb479aa2f67
MD5 cf15df24c9e529ef894f76fac0dba9d2
BLAKE2b-256 15bff72f5cf637773e76ab96e1dec14e81d7c570c91a0fcb950e72106aae849f

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.1.12.dev0-cp313-cp313-manylinux_2_34_aarch64.whl.

File metadata

  • Download URL: fabricatio_rag-0.1.12.dev0-cp313-cp313-manylinux_2_34_aarch64.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: CPython 3.13, manylinux: glibc 2.34+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","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.12.dev0-cp313-cp313-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 f3cd13363b0adbe5cc3f1f1bbb69071bad81a4c670255f5ea01fadd28a2f8204
MD5 fc7ae39e5b63b0b709e55b72277f4e83
BLAKE2b-256 1a5d9dbdbc2884a1f345c820dc55d435e08ed11361afda84c2bb7e5271c9fdf2

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.1.12.dev0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

  • Download URL: fabricatio_rag-0.1.12.dev0-cp313-cp313-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: CPython 3.13, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","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.12.dev0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2ca8545e1fb0c96fcd552ca2d713651d571fee6edd37b79a4e8ce4d7fc5276af
MD5 6225570879a9ce5c2ddb11ca843af454
BLAKE2b-256 737fced606c42b49e2a8f81c4441c8a628ed61b93db78ab2d05a3e5055b16e39

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.1.12.dev0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: fabricatio_rag-0.1.12.dev0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","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.12.dev0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a0772dec5647b2158962452ca55bd967318c9d66b4d578bebb7a1632431fdc59
MD5 3946dd4f65fa06b0ddc8bad671289715
BLAKE2b-256 b90641c1ba88ff5a53e9abda78cad20e17d55f6756a93f863efbe5a62c1fc4b7

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.1.12.dev0-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

  • Download URL: fabricatio_rag-0.1.12.dev0-cp312-cp312-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","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.12.dev0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 44d9be079651dc394b820cb4ebf866163d23ad4e8e55a2d500f3009c8b785589
MD5 6e4c22ca5d7c6d098523571d7179b8c1
BLAKE2b-256 044ea97885e941287aa6164856eae6cce464a91a548f3a100ba3f86a6ceec1b9

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.1.12.dev0-cp312-cp312-manylinux_2_34_aarch64.whl.

File metadata

  • Download URL: fabricatio_rag-0.1.12.dev0-cp312-cp312-manylinux_2_34_aarch64.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: CPython 3.12, manylinux: glibc 2.34+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","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.12.dev0-cp312-cp312-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 794fa7b445f72e772ab6179c2f5596e06a8ebf627363e3ffe4d89a3aa0a223cf
MD5 53ae0cdc0d8e1c350cf3f41ff8021d25
BLAKE2b-256 654b1228ebc4f30dfad13213f8cbcaa00b0ed8348ab10894c14666830d0bcef0

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.1.12.dev0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

  • Download URL: fabricatio_rag-0.1.12.dev0-cp312-cp312-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: CPython 3.12, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","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.12.dev0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 edd2bce8294abc26041d511c32b95d6b3045f8804a476b4958c5851a2702b0bc
MD5 422cfaef8329be75a1585ce85d38d641
BLAKE2b-256 4ba3eccba85e3731f6625fb7b0c20bf643f93f43d13dc556125d0bf9ca7ad0c6

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