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

Uploaded CPython 3.14Windows x86-64

fabricatio_rag-0.1.12-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-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-cp314-cp314-macosx_11_0_arm64.whl (2.6 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.13Windows x86-64

fabricatio_rag-0.1.12-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-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-cp313-cp313-macosx_11_0_arm64.whl (2.6 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

fabricatio_rag-0.1.12-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-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-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-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: fabricatio_rag-0.1.12-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-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 ef40d6c55f5d2fb19defdc181a2fbbc23a6126a37b1cc28728cd3ed2d0e53330
MD5 ea247d4eb809eae2395f1ae8980a6007
BLAKE2b-256 40e2ef72ea4f61520e23a86f5600ccc3864df35401e35bbca835a66f156a2589

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.1.12-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-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 da5914683fcd4bfda52be3468697823bdb75cdd3ef26a45718b5cebb716c6954
MD5 2d636ae45cf5793e05fed307dfeb65e0
BLAKE2b-256 1ebfba3ea09af6690f15f6f60c4818bbc895b7d28cf183cb2d010ab469ce93b9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.1.12-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-cp314-cp314-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 481a9f9cb46b7b3dd117f776f03e153c2fa34e043256145469d71c237a747ce6
MD5 265f41ea1faf35d23117016038bdde73
BLAKE2b-256 7ba05aae539cfbce00c8148d3bbad76433ae66f5587f8eebe38ed49429ec0dd4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.1.12-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-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 98b11c363227fc286b19c22a79b6b3bb4fac8654d3f95aa86609c7a8c5460be7
MD5 ee228752a98d1c98e7bc9d98623a2ac5
BLAKE2b-256 2d6c7ff683f167ce266536daf7edaa42f1d0c99db0f992c941a935a02ffc84b6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.1.12-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-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 4cb559d56676585b48b7578c7435b7b19583bc888949d7ac19cf68127117f20c
MD5 e313831d812656b980e34bbd7247278f
BLAKE2b-256 ed5abf232f15de38ff6e78ddb1003386c8805e541e13df581766325fedeb42d6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.1.12-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-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 25ad240cce048a6e50db002b54eb05e98794e340a22ea5b6df9d91f9614e7a12
MD5 2cb19bce072b9d5f249e872e8cebe7e0
BLAKE2b-256 8778695096eee9cc9c051b6e6ce8c7cfd415c2e1ad18a070799ebde1dec00995

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.1.12-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-cp313-cp313-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 e85cd153fea60a267750e1ea2c410ffd1ca58e64dc089ae0e8f29db1dbd4a9eb
MD5 de5298c2e61f217b9ef04d94a3ef262f
BLAKE2b-256 eb9149bdb12b2c77da5d561289bb3a277b9b2ae34c6643030a44ae5bd44173de

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.1.12-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-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8ea6cae303ece1fe736e9ec2386ef139476620587cc7c3add4030b9ea03cca85
MD5 5e2d5bf9935563048acba62492cd4fcc
BLAKE2b-256 18a89585699511e47a43feb4f248fb3d63d8a053dce93b498e2af52963b31621

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.1.12-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-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 37686fa16233497a202ab53b241ee9d7b968c1a4f5b5c82fdc97bbe1ce76fd3c
MD5 71b1b09049a2adf63850b2edabb9af6b
BLAKE2b-256 50917d8de149ac51dc9c6e91bec7d2656ec8e235d344669a237859a02879ffde

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.1.12-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-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 e24beeae7b7f6b14037707281849a4430fcef4f8106a68c9315021e95e566510
MD5 734fc2a10235c73ab079a37132b6493f
BLAKE2b-256 fe0f6afa8be97f97669718ab47bd07cd79998c0dfe54c131a5b101f5f885f8af

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.1.12-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-cp312-cp312-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 bc7ff5c9ca374726d20304b10cb3cc158703b2d2d952e28d980c0aaf5d64f76e
MD5 d421d2ff336e0627a1a57efb4fe0679d
BLAKE2b-256 87914bd490ca32d7b4e66d9f4463c186447a3b16ac7597d69f6b4510ef636f82

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.1.12-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-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 583e1a1526046896dcba60dfc1e8ca26f9f15b71c5997921f3ff31887e2a243e
MD5 2a34ec4e188cf7ad8812609a7ce6cce7
BLAKE2b-256 aac9309458a4d83a541941dea4b2bec0677fe4fb8c7c37063904120ce201899b

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