Skip to main content

EasyRAG: A Simple and Secure RAG Framework

EasyRAG is a Python library that simplifies the implementation of Retrieval-Augmented Generation (RAG) systems. It provides a modular and extensible framework for building RAG applications with various embedding models, vector stores, and language models.

Features

  • Secure handling of API keys
  • Support for multiple embedding providers (OpenAI, HuggingFace)
  • Integration with various vector stores (Chroma, FAISS)
  • Flexible LLM support (OpenAI, Google Gemini)
  • Easy document management
  • Configurable text splitting

Installation

pip install rag-easy

Getting Started

Here is a basic example to get started using the EasyRAG framework:

from easy_rag import SecureRAGFramework, Document

# User-provided API keys
api_keys = {
    "openai": "",
    "gemini": "",
    "huggingface": ""
}

# Use the SecureRAGFramework in a with statement
with SecureRAGFramework(
    embedding_provider="huggingface",
    vectorstore_provider="chroma",
    llm_provider="gemini",
    api_keys=api_keys,
    embedding_model="sentence-transformers/all-MiniLM-L6-v2",
    llm_model="gemini-pro",
    system_prompt="You are a helpful assistant that answers questions based on the given context."
) as rag:

    # Add documents
    documents = [
        Document("Paris is the capital of France, known for its art, fashion, and culture.", {"source": "geo.txt"}),
    ]
    rag.add_documents(documents)

    # Query the RAG system
    query = "Give a few lines about Paris and its specialities in 3 words."
    response = rag.query(query)
    print(f"Query: {query}")
    print(f"Response: {response}")

This example uses the gemini LLM with the sentence-transformers/all-MiniLM-L6-v2 embedding model. You can customize it with OpenAI or any other supported provider based on your convenience. The framework ensures secure handling of API keys and provides flexibility in choosing different models and vector stores.

Customization

You can easily customize the framework to use different embedding providers, vector stores, and language models. Here is an example using OpenAI's embedding model and LLM:

from easy_rag import SecureRAGFramework, Document

# User-provided API keys
api_keys = {
    "openai": "your_openai_api_key",
    "gemini": "",
    "huggingface": ""
}

# Use the SecureRAGFramework in a with statement
with SecureRAGFramework(
    embedding_provider="openai",
    vectorstore_provider="faiss",
    llm_provider="openai",
    api_keys=api_keys,
    embedding_model="text-embedding-ada-002",
    llm_model="text-davinci-003",
    system_prompt="You are a helpful assistant that answers questions based on the given context."
) as rag:

    # Add documents
    documents = [
        Document("Paris is the capital of France, known for its art, fashion, and culture.", {"source": "geo.txt"}),
    ]
    rag.add_documents(documents)

    # Query the RAG system
    query = "Give a few lines about Paris and its specialities in 3 words."
    response = rag.query(query)
    print(f"Query: {query}")
    print(f"Response: {response}")

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

We welcome contributions to improve EasyRAG. Please fork the repository and submit pull requests.

Metadata

Release files for rag-easy 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for rag-easy 0.1.1
File Interpreter ABI Platform
rag_easy-0.1.1-py3-none-any.whl Python 3 none any Details

Release files / rag_easy-0.1.1-py3-none-any.whl

Download URL rag_easy-0.1.1-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8390cbf02c24744e796b9dfff1b74e6d6707c75ff3d44744414e7610c2106ef3
BLAKE2b-256 checksum
How to use checksums
f4f84593aa2b7f89c948d040f37bcc4dbbe6fd2154f662b5f1784ed18d2129c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.16

Security for rag-easy 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page