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

Uploaded CPython 3.14Windows x86-64

fabricatio_rag-0.2.0.dev0-cp314-cp314-manylinux_2_35_x86_64.whl (53.4 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.35+ x86-64

fabricatio_rag-0.2.0.dev0-cp314-cp314-manylinux_2_35_aarch64.whl (46.4 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.35+ ARM64

fabricatio_rag-0.2.0.dev0-cp314-cp314-macosx_11_0_arm64.whl (46.9 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

fabricatio_rag-0.2.0.dev0-cp313-cp313-win_amd64.whl (50.9 MB view details)

Uploaded CPython 3.13Windows x86-64

fabricatio_rag-0.2.0.dev0-cp313-cp313-manylinux_2_35_x86_64.whl (53.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.35+ x86-64

fabricatio_rag-0.2.0.dev0-cp313-cp313-manylinux_2_35_aarch64.whl (46.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.35+ ARM64

fabricatio_rag-0.2.0.dev0-cp313-cp313-macosx_11_0_arm64.whl (46.9 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

fabricatio_rag-0.2.0.dev0-cp312-cp312-win_amd64.whl (50.9 MB view details)

Uploaded CPython 3.12Windows x86-64

fabricatio_rag-0.2.0.dev0-cp312-cp312-manylinux_2_35_x86_64.whl (53.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.35+ x86-64

fabricatio_rag-0.2.0.dev0-cp312-cp312-manylinux_2_35_aarch64.whl (46.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.35+ ARM64

fabricatio_rag-0.2.0.dev0-cp312-cp312-macosx_11_0_arm64.whl (46.9 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.0.dev0-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 50.9 MB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","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.0.dev0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 2624ce5aaa9a642fda96c6f0bbd08d883b3d771742444a64ff9232e41be96ae9
MD5 3e111428b0d99fffb989699dcc6fb670
BLAKE2b-256 bb903ab032fdd13076e392a61e7280295cedad50e0550fc7d70bc176986232e9

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.2.0.dev0-cp314-cp314-manylinux_2_35_x86_64.whl.

File metadata

  • Download URL: fabricatio_rag-0.2.0.dev0-cp314-cp314-manylinux_2_35_x86_64.whl
  • Upload date:
  • Size: 53.4 MB
  • Tags: CPython 3.14, manylinux: glibc 2.35+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","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.0.dev0-cp314-cp314-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 c48b6b7363c0e282852143243cc075e78ae6d505184882882f1f075c44edcdaa
MD5 3c0cce633125c085acfa269e939007d0
BLAKE2b-256 56687ffef2ebbd5378e89ac4b2876a077e9075df34b28c04612f63e198f7b1cd

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.2.0.dev0-cp314-cp314-manylinux_2_35_aarch64.whl.

File metadata

  • Download URL: fabricatio_rag-0.2.0.dev0-cp314-cp314-manylinux_2_35_aarch64.whl
  • Upload date:
  • Size: 46.4 MB
  • Tags: CPython 3.14, manylinux: glibc 2.35+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","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.0.dev0-cp314-cp314-manylinux_2_35_aarch64.whl
Algorithm Hash digest
SHA256 fc5090599960ebea9e528948a2ca27673ae119d39639edf4e19f020dcd077f98
MD5 c9fd8fdb70136ea692121da325bf57df
BLAKE2b-256 53eb4d7e37c0d23b4eb7cb52ef26563c562d2c9ea910dde77595a4d0cb8fe5ee

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.0.dev0-cp314-cp314-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 46.9 MB
  • Tags: CPython 3.14, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","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.0.dev0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 70d823ec662dd0e2b2e4ecb8bf0a63e79ea8756a21d1feb9bba4d8f628c842d2
MD5 204011e4bdbc3b2323642d14ee0da534
BLAKE2b-256 88a5c75cf1fdbb5c858f1ad4ffff40b96f22e8864b8d64e0d2165f6771676e49

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.0.dev0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 50.9 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","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.0.dev0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 637817b2e4c2429bbee28234bfa6a926b2a68fac16f8f4891bea409d97976dde
MD5 0ccd0a442da0735c8adff3ce33ad7503
BLAKE2b-256 f86bf998210e1e7157d9ca3cdabdebde6de0b0edf5948bf565d356a7f277d39f

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.2.0.dev0-cp313-cp313-manylinux_2_35_x86_64.whl.

File metadata

  • Download URL: fabricatio_rag-0.2.0.dev0-cp313-cp313-manylinux_2_35_x86_64.whl
  • Upload date:
  • Size: 53.4 MB
  • Tags: CPython 3.13, manylinux: glibc 2.35+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","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.0.dev0-cp313-cp313-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 bc51a2d208b17786633ae33db0cd3980deed17d00864c545dc4ef16962b0c460
MD5 2869d0c031ad0ad9ead3cd4576272f88
BLAKE2b-256 39da67ac24b811183504a6fd3adc3d4c4a561c0f222cd9fa54894d28e916ba28

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.2.0.dev0-cp313-cp313-manylinux_2_35_aarch64.whl.

File metadata

  • Download URL: fabricatio_rag-0.2.0.dev0-cp313-cp313-manylinux_2_35_aarch64.whl
  • Upload date:
  • Size: 46.4 MB
  • Tags: CPython 3.13, manylinux: glibc 2.35+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","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.0.dev0-cp313-cp313-manylinux_2_35_aarch64.whl
Algorithm Hash digest
SHA256 80f6ea074199c73e2638896fd696263af91da164460dca8429cfc6186d1f2249
MD5 0075e0c1d43fd20a4cfe65c239058223
BLAKE2b-256 2e7f6acb165a35ebefa8166a8d8388fa1bac053f0f7017993d3f071676550635

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.0.dev0-cp313-cp313-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 46.9 MB
  • Tags: CPython 3.13, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","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.0.dev0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8ff9cf68d083b04ed28b0e64ba12732da6a38f037ddf561ec2a06a710508f51b
MD5 1237fa16129e14f6fef56b90ea475296
BLAKE2b-256 c5b4ca1024584efd51adb7e77da4a45754c7419972f9f4945ba2047f5cf6a433

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.0.dev0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 50.9 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","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.0.dev0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ebfbd0a096577e8ebbf042a8838a84fbc3512bb0e27313c523132cf3dad19969
MD5 b46d7ad941e718cdfcad6f9167c25853
BLAKE2b-256 19c3d1edba5912215e8140fa7b775acfb7857a7876022335f113325bf9eba385

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.2.0.dev0-cp312-cp312-manylinux_2_35_x86_64.whl.

File metadata

  • Download URL: fabricatio_rag-0.2.0.dev0-cp312-cp312-manylinux_2_35_x86_64.whl
  • Upload date:
  • Size: 53.4 MB
  • Tags: CPython 3.12, manylinux: glibc 2.35+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","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.0.dev0-cp312-cp312-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 a4e2e356a2825c851918ccb15e91c69ff7be3030dadcd99bd321c3c9137e2c62
MD5 47c43a90e6127ffb2ccf90dd89cc34b1
BLAKE2b-256 f573d59332c2ed1a13c6fcdce92b3717574e563f1a107e8dcd2b8fdce446e397

See more details on using hashes here.

File details

Details for the file fabricatio_rag-0.2.0.dev0-cp312-cp312-manylinux_2_35_aarch64.whl.

File metadata

  • Download URL: fabricatio_rag-0.2.0.dev0-cp312-cp312-manylinux_2_35_aarch64.whl
  • Upload date:
  • Size: 46.4 MB
  • Tags: CPython 3.12, manylinux: glibc 2.35+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","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.0.dev0-cp312-cp312-manylinux_2_35_aarch64.whl
Algorithm Hash digest
SHA256 80bc5de2593a5dae2abdf9bc739e5a3f644db304eae9a78bf96feb1913c275f1
MD5 22876b15f9917f1fe281ffdd2451500e
BLAKE2b-256 aec856591b961d3482b7fc0d53782c68e591649aadf3d78965fa4f4155d559a8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_rag-0.2.0.dev0-cp312-cp312-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 46.9 MB
  • Tags: CPython 3.12, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","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.0.dev0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 859b2cdf6c8e987682dfab28eac8caa57e52b644c75fd43a2949f148849c2779
MD5 29fc1e0b081f3241089b46a28abc7efa
BLAKE2b-256 f05782c8d2160a73fa5e82e021d505127dffee582b1c5c36a75b6cae4b920e34

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