|
1 | 1 | <div align="center">
|
2 | 2 |
|
3 |
| -<h1>Ragbits</h1> |
| 3 | +<h1>🐰 Ragbits</h1> |
4 | 4 |
|
5 | 5 | *Building blocks for rapid development of GenAI applications*
|
6 | 6 |
|
7 |
| -[Documentation](https://ragbits.deepsense.ai) | [Contact](https://deepsense.ai/contact/) |
| 7 | +[Homepage](https://deepsense.ai/rd-hub/ragbits/) | [Documentation](https://ragbits.deepsense.ai) | [Contact](https://deepsense.ai/contact/) |
8 | 8 |
|
9 | 9 | [](https://pypi.org/project/ragbits)
|
10 | 10 | [](https://pypi.org/project/ragbits)
|
|
17 | 17 | ## Features
|
18 | 18 |
|
19 | 19 | ### 🔨 Build Reliable & Scalable GenAI Apps
|
| 20 | + |
20 | 21 | - **Swap LLMs anytime** – Switch between [100+ LLMs via LiteLLM](https://ragbits.deepsense.ai/how-to/llms/use_llms/) or run [local models](https://ragbits.deepsense.ai/how-to/llms/use_local_llms/).
|
21 | 22 | - **Type-safe LLM calls** – Use Python generics to [enforce strict type safety](https://ragbits.deepsense.ai/how-to/prompts/use_prompting/#how-to-configure-prompts-output-data-type) in model interactions.
|
22 | 23 | - **Bring your own vector store** – Connect to [Qdrant](https://ragbits.deepsense.ai/api_reference/core/vector-stores/#ragbits.core.vector_stores.qdrant.QdrantVectorStore), [PgVector](https://ragbits.deepsense.ai/api_reference/core/vector-stores/#ragbits.core.vector_stores.pgvector.PgVectorStore), and more with built-in support.
|
23 | 24 | - **Developer tools included** – [Manage vector stores](https://ragbits.deepsense.ai/cli/main/#ragbits-vector-store), query pipelines, and [test prompts from your terminal](https://ragbits.deepsense.ai/quickstart/quickstart1_prompts/#testing-the-prompt-from-the-cli).
|
24 | 25 | - **Modular installation** – Install only what you need, reducing dependencies and improving performance.
|
25 | 26 |
|
26 | 27 | ### 📚 Fast & Flexible RAG Processing
|
27 |
| -- **Ingest 20+ formats** – Process PDFs, HTML, spreadsheets, presentations, and more. Process data using [docling](https://github.com/docling-project/docling), [unstructured](https://github.com/Unstructured-IO/unstructured) or create a custom parser. |
| 28 | + |
| 29 | +- **Ingest 20+ formats** – Process PDFs, HTML, spreadsheets, presentations, and more. Process data using [Docling](https://github.com/docling-project/docling), [Unstructured](https://github.com/Unstructured-IO/unstructured) or create a custom parser. |
28 | 30 | - **Handle complex data** – Extract tables, images, and structured content with built-in VLMs support.
|
29 | 31 | - **Connect to any data source** – Use prebuilt connectors for S3, GCS, Azure, or implement your own.
|
30 | 32 | - **Scale ingestion** – Process large datasets quickly with [Ray-based parallel processing](https://ragbits.deepsense.ai/how-to/document_search/distributed_ingestion/#how-to-ingest-documents-in-a-distributed-fashion).
|
31 | 33 |
|
32 | 34 | ### 🚀 Deploy & Monitor with Confidence
|
| 35 | + |
33 | 36 | - **Real-time observability** – Track performance with [OpenTelemetry](https://ragbits.deepsense.ai/how-to/project/use_tracing/#opentelemetry-trace-handler) and [CLI insights](https://ragbits.deepsense.ai/how-to/project/use_tracing/#cli-trace-handler).
|
34 | 37 | - **Built-in testing** – Validate prompts [with promptfoo](https://ragbits.deepsense.ai/how-to/prompts/promptfoo/) before deployment.
|
35 | 38 | - **Auto-optimization** – Continuously evaluate and refine model performance.
|
36 | 39 | - **Visual testing UI (Coming Soon)** – Test and optimize applications with a visual interface.
|
37 | 40 |
|
38 |
| - |
39 |
| -## What's Included? |
40 |
| - |
41 |
| -- [X] **[Core](https://github.com/deepsense-ai/ragbits/tree/main/packages/ragbits-core)** - Fundamental tools for working with prompts and LLMs. |
42 |
| -- [X] **[Document Search](https://github.com/deepsense-ai/ragbits/tree/main/packages/ragbits-document-search)** - Handles vector search to retrieve relevant documents. |
43 |
| -- [X] **[CLI](https://github.com/deepsense-ai/ragbits/tree/main/packages/ragbits-cli)** - The `ragbits` shell command, enabling tools such as GUI prompt management. |
44 |
| -- [x] **[Guardrails](https://github.com/deepsense-ai/ragbits/tree/main/packages/ragbits-guardrails)** - Ensures response safety and relevance. |
45 |
| -- [x] **[Evaluation](https://github.com/deepsense-ai/ragbits/tree/main/packages/ragbits-evaluate)** - Unified evaluation framework for Ragbits components. |
46 |
| -- [ ] **Flow Controls** - Manages multi-stage chat flows for performing advanced actions *(coming soon)*. |
47 |
| -- [ ] **Structured Querying** - Queries structured data sources in a predictable manner *(coming soon)*. |
48 |
| -- [ ] **Caching** - Adds a caching layer to reduce costs and response times *(coming soon)*. |
49 |
| - |
50 | 41 | ## Installation
|
51 | 42 |
|
52 |
| -To use the complete Ragbits stack, install the `ragbits` package: |
| 43 | +To get started quickly, you can install with: |
53 | 44 |
|
54 | 45 | ```sh
|
55 | 46 | pip install ragbits
|
56 | 47 | ```
|
57 | 48 |
|
58 |
| -Alternatively, you can use individual components of the stack by installing their respective packages: `ragbits-core`, `ragbits-document-search`, `ragbits-cli`. |
| 49 | +This is a starter bundle of packages, containing: |
| 50 | + |
| 51 | +- [`ragbits-core`](https://github.com/deepsense-ai/ragbits/tree/main/packages/ragbits-core) - fundamental tools for working with prompts, LLMs and vector databases. |
| 52 | +- [`ragbits-agents`](https://github.com/deepsense-ai/ragbits/tree/main/packages/ragbits-agents) - abstractions for building agentic systems. |
| 53 | +- [`ragbits-document-search`](https://github.com/deepsense-ai/ragbits/tree/main/packages/ragbits-document-search) - retrieval and ingestion piplines for knowledge bases. |
| 54 | +- [`ragbits-evaluate`](https://github.com/deepsense-ai/ragbits/tree/main/packages/ragbits-evaluate) - unified evaluation framework for Ragbits components. |
| 55 | +- [`ragbits-chat`](https://github.com/deepsense-ai/ragbits/tree/main/packages/ragbits-chat) - full-stack infrastructure for building conversational AI applications. |
| 56 | +- [`ragbits-cli`](https://github.com/deepsense-ai/ragbits/tree/main/packages/ragbits-cli) - `ragbits` shell command for interacting with Ragbits components. |
| 57 | + |
| 58 | +Alternatively, you can use individual components of the stack by installing their respective packages. |
59 | 59 |
|
60 | 60 | ## Quickstart
|
61 | 61 |
|
62 |
| -First, create a prompt and a model for the data used in the prompt: |
| 62 | +### Basics |
| 63 | + |
| 64 | +To define a prompt and run LLM: |
63 | 65 |
|
64 | 66 | ```python
|
| 67 | +import asyncio |
65 | 68 | from pydantic import BaseModel
|
| 69 | +from ragbits.core.llms import LiteLLM |
66 | 70 | from ragbits.core.prompt import Prompt
|
67 | 71 |
|
68 |
| -class Dog(BaseModel): |
69 |
| - breed: str |
70 |
| - age: int |
71 |
| - temperament: str |
| 72 | +class QuestionAnswerPromptInput(BaseModel): |
| 73 | + question: str |
72 | 74 |
|
73 |
| -class DogNamePrompt(Prompt[Dog, str]): |
| 75 | +class QuestionAnswerPromptOutput(BaseModel): |
| 76 | + answer: str |
| 77 | + |
| 78 | +class QuestionAnswerPrompt(Prompt[QuestionAnswerPromptInput, QuestionAnswerPromptOutput]): |
74 | 79 | system_prompt = """
|
75 |
| - You are a dog name generator. You come up with funny names for dogs given the dog details. |
| 80 | + You are a question answering agent. Answer the question to the best of your ability. |
76 | 81 | """
|
77 |
| - |
78 | 82 | user_prompt = """
|
79 |
| - The dog is a {breed} breed, {age} years old, and has a {temperament} temperament. |
| 83 | + Question: {{ question }} |
80 | 84 | """
|
| 85 | + |
| 86 | +llm = LiteLLM(model_name="gpt-4.1-nano", use_structured_output=True) |
| 87 | + |
| 88 | +async def main() -> None: |
| 89 | + prompt = QuestionAnswerPrompt(QuestionAnswerPromptInput(question="What are high memory and low memory on linux?")) |
| 90 | + response = await llm.generate(prompt) |
| 91 | + print(response.answer) |
| 92 | + |
| 93 | +if __name__ == "__main__": |
| 94 | + asyncio.run(main()) |
81 | 95 | ```
|
82 | 96 |
|
83 |
| -Next, create an instance of the LLM and the prompt: |
| 97 | +### Document Search |
84 | 98 |
|
85 |
| -```python |
86 |
| -from ragbits.core.llms.litellm import LiteLLM |
| 99 | +To build and query a simple vector store index: |
87 | 100 |
|
88 |
| -llm = LiteLLM("gpt-4o") |
89 |
| -example_dog = Dog(breed="Golden Retriever", age=3, temperament="friendly") |
90 |
| -prompt = DogNamePrompt(example_dog) |
| 101 | +```python |
| 102 | +import asyncio |
| 103 | +from ragbits.core.embeddings import LiteLLMEmbedder |
| 104 | +from ragbits.core.vector_stores import InMemoryVectorStore |
| 105 | +from ragbits.document_search import DocumentSearch |
| 106 | + |
| 107 | +embedder = LiteLLMEmbedder(model_name="text-embedding-3-small") |
| 108 | +vector_store = InMemoryVectorStore(embedder=embedder) |
| 109 | +document_search = DocumentSearch(vector_store=vector_store) |
| 110 | + |
| 111 | +async def run() -> None: |
| 112 | + await document_search.ingest("web://https://arxiv.org/pdf/1706.03762") |
| 113 | + result = await document_search.search("What are the key findings presented in this paper?") |
| 114 | + print(result) |
| 115 | + |
| 116 | +if __name__ == "__main__": |
| 117 | + asyncio.run(run()) |
91 | 118 | ```
|
92 | 119 |
|
93 |
| -Finally, generate a response from the LLM using the prompt: |
| 120 | +### Retrieval-Augmented Generation |
| 121 | + |
| 122 | +To build a simple RAG pipeline: |
94 | 123 |
|
95 | 124 | ```python
|
96 |
| -response = await llm.generate(prompt) |
97 |
| -print(f"Generated dog name: {response}") |
| 125 | +import asyncio |
| 126 | +from pydantic import BaseModel |
| 127 | +from ragbits.core.embeddings import LiteLLMEmbedder |
| 128 | +from ragbits.core.llms import LiteLLM |
| 129 | +from ragbits.core.prompt import Prompt |
| 130 | +from ragbits.core.vector_stores import InMemoryVectorStore |
| 131 | +from ragbits.document_search import DocumentSearch |
| 132 | + |
| 133 | +class QuestionAnswerPromptInput(BaseModel): |
| 134 | + question: str |
| 135 | + context: list[str] |
| 136 | + |
| 137 | +class QuestionAnswerPromptOutput(BaseModel): |
| 138 | + answer: str |
| 139 | + |
| 140 | +class QuestionAnswerPrompt(Prompt[QuestionAnswerPromptInput, QuestionAnswerPromptOutput]): |
| 141 | + system_prompt = """ |
| 142 | + You are a question answering agent. Answer the question that will be provided using context. |
| 143 | + If in the given context there is not enough information refuse to answer. |
| 144 | + """ |
| 145 | + user_prompt = """ |
| 146 | + Question: {{ question }} |
| 147 | + Context: {% for item in context %} |
| 148 | + {{ item }} |
| 149 | + {%- endfor %} |
| 150 | + """ |
| 151 | + |
| 152 | +embedder = LiteLLMEmbedder(model_name="text-embedding-3-small") |
| 153 | +vector_store = InMemoryVectorStore(embedder=embedder) |
| 154 | +document_search = DocumentSearch(vector_store=vector_store) |
| 155 | +llm = LiteLLM(model_name="gpt-4.1-nano", use_structured_output=True) |
| 156 | + |
| 157 | +async def run() -> None: |
| 158 | + question = "What are the key findings presented in this paper?" |
| 159 | + |
| 160 | + await document_search.ingest("web://https://arxiv.org/pdf/1706.03762") |
| 161 | + result = await document_search.search(question) |
| 162 | + |
| 163 | + prompt = QuestionAnswerPrompt(QuestionAnswerPromptInput( |
| 164 | + question=question, |
| 165 | + context=[element.text_representation for element in result], |
| 166 | + )) |
| 167 | + response = await llm.generate(prompt) |
| 168 | + print(response.answer) |
| 169 | + |
| 170 | +if __name__ == "__main__": |
| 171 | + asyncio.run(run()) |
98 | 172 | ```
|
99 | 173 |
|
100 |
| -## How Ragbits documentation is organized |
| 174 | +## Rapid development |
101 | 175 |
|
102 |
| -- [Quickstart](https://ragbits.deepsense.ai/quickstart/quickstart1_prompts/) - Get started with Ragbits in a few minutes |
103 |
| -- [How-to guides](https://ragbits.deepsense.ai/how-to/prompts/use_prompting/) - Learn how to use Ragbits in your projects |
104 |
| -- [CLI](https://ragbits.deepsense.ai/cli/main/) - Learn how to run Ragbits in your terminal |
105 |
| -- [API reference](https://ragbits.deepsense.ai/api_reference/core/prompt/) - Explore the underlying API of Ragbits |
| 176 | +Create Ragbits projects from templates: |
106 | 177 |
|
| 178 | +```sh |
| 179 | +uvx create-ragbits-app |
| 180 | +``` |
107 | 181 |
|
108 |
| -## License |
| 182 | +Explore `create-ragbits-app` repo [here](https://github.com/deepsense-ai/create-ragbits-app). If you have a new idea for a template, feel free to contribute! |
109 | 183 |
|
110 |
| -Ragbits is licensed under the [MIT License](https://github.com/deepsense-ai/ragbits/tree/main/LICENSE). |
| 184 | +## Documentation |
| 185 | + |
| 186 | +- [Quickstart](https://ragbits.deepsense.ai/quickstart/quickstart1_prompts/) - Get started with Ragbits in a few minutes |
| 187 | +- [How-to](https://ragbits.deepsense.ai/how-to/prompts/use_prompting/) - Learn how to use Ragbits in your projects |
| 188 | +- [CLI](https://ragbits.deepsense.ai/cli/main/) - Learn how to run Ragbits in your terminal |
| 189 | +- [API reference](https://ragbits.deepsense.ai/api_reference/core/prompt/) - Explore the underlying Ragbits API |
111 | 190 |
|
112 | 191 | ## Contributing
|
113 | 192 |
|
114 | 193 | We welcome contributions! Please read [CONTRIBUTING.md](https://github.com/deepsense-ai/ragbits/tree/main/CONTRIBUTING.md) for more information.
|
| 194 | + |
| 195 | +## License |
| 196 | + |
| 197 | +Ragbits is licensed under the [MIT License](https://github.com/deepsense-ai/ragbits/tree/main/LICENSE). |
0 commit comments