Skip to main content

Building blocks for rapid development of GenAI applications

Project description

🐰 Ragbits

Building blocks for rapid development of GenAI applications

Homepage | Documentation | Contact

deepsense-ai%2Fragbits | Trendshift

PyPI - License PyPI - Version PyPI - Python Version


Features

🔨 Build Reliable & Scalable GenAI Apps

📚 Fast & Flexible RAG Processing

  • Ingest 20+ formats – Process PDFs, HTML, spreadsheets, presentations, and more. Process data using Docling, Unstructured or create a custom parser.
  • Handle complex data – Extract tables, images, and structured content with built-in VLMs support.
  • Connect to any data source – Use prebuilt connectors for S3, GCS, Azure, or implement your own.
  • Scale ingestion – Process large datasets quickly with Ray-based parallel processing.

🚀 Deploy & Monitor with Confidence

  • Real-time observability – Track performance with OpenTelemetry and CLI insights.
  • Built-in testing – Validate prompts with promptfoo before deployment.
  • Auto-optimization – Continuously evaluate and refine model performance.
  • Chat UI – Deploy chatbot interface with API, persistance and user feedback.

Installation

To get started quickly, you can install with:

pip install ragbits

This is a starter bundle of packages, containing:

  • ragbits-core - fundamental tools for working with prompts, LLMs and vector databases.
  • ragbits-agents - abstractions for building agentic systems.
  • ragbits-document-search - retrieval and ingestion piplines for knowledge bases.
  • ragbits-evaluate - unified evaluation framework for Ragbits components.
  • ragbits-chat - full-stack infrastructure for building conversational AI applications.
  • ragbits-cli - ragbits shell command for interacting with Ragbits components.

Alternatively, you can use individual components of the stack by installing their respective packages.

Quickstart

Basics

To define a prompt and run LLM:

import asyncio
from pydantic import BaseModel
from ragbits.core.llms import LiteLLM
from ragbits.core.prompt import Prompt

class QuestionAnswerPromptInput(BaseModel):
    question: str

class QuestionAnswerPrompt(Prompt[QuestionAnswerPromptInput, str]):
    system_prompt = """
    You are a question answering agent. Answer the question to the best of your ability.
    """
    user_prompt = """
    Question: {{ question }}
    """

llm = LiteLLM(model_name="gpt-4.1-nano")

async def main() -> None:
    prompt = QuestionAnswerPrompt(QuestionAnswerPromptInput(question="What are high memory and low memory on linux?"))
    response = await llm.generate(prompt)
    print(response)

if __name__ == "__main__":
    asyncio.run(main())

Document Search

To build and query a simple vector store index:

import asyncio
from ragbits.core.embeddings import LiteLLMEmbedder
from ragbits.core.vector_stores import InMemoryVectorStore
from ragbits.document_search import DocumentSearch

embedder = LiteLLMEmbedder(model_name="text-embedding-3-small")
vector_store = InMemoryVectorStore(embedder=embedder)
document_search = DocumentSearch(vector_store=vector_store)

async def run() -> None:
    await document_search.ingest("web://https://arxiv.org/pdf/1706.03762")
    result = await document_search.search("What are the key findings presented in this paper?")
    print(result)

if __name__ == "__main__":
    asyncio.run(run())

Retrieval-Augmented Generation

To build a simple RAG pipeline:

import asyncio
from collections.abc import Iterable
from pydantic import BaseModel
from ragbits.core.embeddings import LiteLLMEmbedder
from ragbits.core.llms import LiteLLM
from ragbits.core.prompt import Prompt
from ragbits.core.vector_stores import InMemoryVectorStore
from ragbits.document_search import DocumentSearch
from ragbits.document_search.documents.element import Element

class QuestionAnswerPromptInput(BaseModel):
    question: str
    context: Iterable[Element]

class QuestionAnswerPrompt(Prompt[QuestionAnswerPromptInput, str]):
    system_prompt = """
    You are a question answering agent. Answer the question that will be provided using context.
    If in the given context there is not enough information refuse to answer.
    """
    user_prompt = """
    Question: {{ question }}
    Context: {% for chunk in context %}{{ chunk.text_representation }}{%- endfor %}
    """

llm = LiteLLM(model_name="gpt-4.1-nano")
embedder = LiteLLMEmbedder(model_name="text-embedding-3-small")
vector_store = InMemoryVectorStore(embedder=embedder)
document_search = DocumentSearch(vector_store=vector_store)

async def run() -> None:
    question = "What are the key findings presented in this paper?"

    await document_search.ingest("web://https://arxiv.org/pdf/1706.03762")
    chunks = await document_search.search(question)

    prompt = QuestionAnswerPrompt(QuestionAnswerPromptInput(question=question, context=chunks))
    response = await llm.generate(prompt)
    print(response)

if __name__ == "__main__":
    asyncio.run(run())

Chat UI

To expose your RAG application through Ragbits UI:

from collections.abc import AsyncGenerator, Iterable
from pydantic import BaseModel
from ragbits.chat.api import RagbitsAPI
from ragbits.chat.interface import ChatInterface
from ragbits.chat.interface.types import ChatContext, ChatResponse
from ragbits.core.embeddings import LiteLLMEmbedder
from ragbits.core.llms import LiteLLM
from ragbits.core.prompt import Prompt, ChatFormat
from ragbits.core.vector_stores import InMemoryVectorStore
from ragbits.document_search import DocumentSearch
from ragbits.document_search.documents.element import Element

class QuestionAnswerPromptInput(BaseModel):
    question: str
    context: Iterable[Element]

class QuestionAnswerPrompt(Prompt[QuestionAnswerPromptInput, str]):
    system_prompt = """
    You are a question answering agent. Answer the question that will be provided using context.
    If in the given context there is not enough information refuse to answer.
    """
    user_prompt = """
    Question: {{ question }}
    Context: {% for chunk in context %}{{ chunk.text_representation }}{%- endfor %}
    """

class MyChat(ChatInterface):
    async def setup(self) -> None:
        self.llm = LiteLLM(model_name="gpt-4.1-nano")
        self.embedder = LiteLLMEmbedder(model_name="text-embedding-3-small")
        self.vector_store = InMemoryVectorStore(embedder=self.embedder)
        self.document_search = DocumentSearch(vector_store=self.vector_store)
        await self.document_search.ingest("web://https://arxiv.org/pdf/1706.03762")

    async def chat(
        self,
        message: str,
        history: ChatFormat | None = None,
        context: ChatContext | None = None,
    ) -> AsyncGenerator[ChatResponse, None]:
        chunks = await self.document_search.search(message)
        prompt = QuestionAnswerPrompt(QuestionAnswerPromptInput(question=message, context=chunks))
        async for text in self.llm.generate_streaming(prompt):
            yield self.create_text_response(text)

if __name__ == "__main__":
    api = RagbitsAPI(MyChat)
    api.run()

Rapid development

Create Ragbits projects from templates:

uvx create-ragbits-app

Explore create-ragbits-app repo here. If you have a new idea for a template, feel free to contribute!

Documentation

  • Quickstart - Get started with Ragbits in a few minutes
  • How-to - Learn how to use Ragbits in your projects
  • CLI - Learn how to run Ragbits in your terminal
  • API reference - Explore the underlying Ragbits API

Contributing

We welcome contributions! Please read CONTRIBUTING.md for more information.

License

Ragbits is licensed under the MIT License.

Project details


Release history Release notifications | RSS feed

This version

1.1.0

Download files

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

Source Distribution

ragbits-1.1.0.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

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

ragbits-1.1.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file ragbits-1.1.0.tar.gz.

File metadata

  • Download URL: ragbits-1.1.0.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.18

File hashes

Hashes for ragbits-1.1.0.tar.gz
Algorithm Hash digest
SHA256 16dbe102d6340b7513f4ff2f050d345fce9cc38341cd9b20149915af7335765f
MD5 c77ab4beffae45b54ab5da5b2874346e
BLAKE2b-256 aa12a1cdb81e4108fc125f813ed68576593bc0647da21537cc2625e69ee4f6e7

See more details on using hashes here.

File details

Details for the file ragbits-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: ragbits-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.18

File hashes

Hashes for ragbits-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0cb8fdeff8d210621c19fb6496536b4caa9be7ad004857dae6d1f67941f04efa
MD5 3b87a476d0b6a330d55f692f187403bb
BLAKE2b-256 6b95ac3f3bf2e1a6d01dcb19f3b56d19089f2106b6c82cc96e0c2a5c42eb91a3

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