Skip to main content

A simple RAG (Retrieval-Augmented Generation) framework for Python.

Project description

RAGy

RAGy is a simple framework for building Retrieval-Augmented Generation (RAG) applications. It provides a set of tools and utilities to help you create RAG applications quickly and easily.

It ships with a simple interface for building RAG applications, as well as a set of pre-built components that you can use to get started quickly (OpenAI LLMs, Chroma vector stores, etc.).

Installation

You can install RAGy using pip:

pip install ragy

Usage

Here's a simple example of how to use RAGy to build a RAG application:

from ragy.rag import RAG
from ragy.reasoning import OpenAIEmbeddingModel, OpenAIGPTEngine
from ragy.rawdoc import DirectoryRawDocumentRetriever
from ragy.vector import ChromaVectorStore

# Create a RAG interface with the necessary components
system_prompt = """
You are a helpful assistant that provides accurate and concise answers to user queries based on the retrieved documents.
Always cite the sources of your information and provide references when applicable.
Include the ID of the retrieved documents in your response to help users verify the information.
If you don't know the answer because the retrieved documents don't contain the information, say "I don't know" instead of making up an answer.
"""
embedding_model = OpenAIEmbeddingModel(model='text-embedding-3-small')
raw_document_retriever = DirectoryRawDocumentRetriever(dir='./docs')
vector_store = ChromaVectorStore(path="./chroma", collection_name='my_collection')
ai_engine = OpenAIGPTEngine(model='gpt-5.2')

rag = RAG(
    system_prompt=system_prompt,
    embedding_model=embedding_model,
    raw_document_retriever=raw_document_retriever,
    vector_store=vector_store,
    ai_engine=ai_engine
)

# Use the RAG interface to ingest documents into the vector store
rag.ingest(chunk_size=512, chunk_overlap=128)

# Use the RAG interface to generate a response to a query
response = rag.generate('What is the capital of France?')
print(response)

Contributing

Contributions to RAGy are welcome! If you have an idea for a new feature or improvement, please open an issue or submit a pull request.

Full AI generated contributions are not accepted. If you use AI to assist in writing code, please ensure that you review and understand the code before submitting it. You should also provide a clear explanation of the changes you made and the reasoning behind them in your pull request.

AI is a powerful tool that can help you write code faster and more efficiently, but it is not a substitute for human creativity and judgment. When contributing to RAGy, please use AI as a tool to assist you, rather than relying on it to do all the work for you.

We encourage you to contribute in the simplest way possible, avoiding unnecessary complexity and over-engineering. Focus on making meaningful contributions that improve the functionality and usability of RAGy, rather than trying to impress others with complex code.

What things to consider when contributing:

  • Ensure that your code is well-documented and follows the existing code style.
  • Write tests for any new features or changes you make.
  • Be respectful and considerate when communicating with other contributors.

License

RAGy is licensed under the MIT License. See the LICENSE file for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ragy-0.2.0.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ragy-0.2.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file ragy-0.2.0.tar.gz.

File metadata

  • Download URL: ragy-0.2.0.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for ragy-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c1b0687934b207da2de6d3c64f11a0b1ebbee72dec16825ed66bcfa1af98f027
MD5 21f7247befab482c2c64dc8b081e3153
BLAKE2b-256 b0bac21246855bd2816af7fcea97d936ec2c489c710d2521bb14737921fffac5

See more details on using hashes here.

File details

Details for the file ragy-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ragy-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for ragy-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 318a5526445d2ce8538071eedfb88f20c2a3038673439da611a2da8ea545b12e
MD5 b14ffc1e05b6d2bda2212296e3dfcac7
BLAKE2b-256 f296b28f85f8a99f2c8353a82dc15068c2b336503d746dec9f8a79ee699d884e

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