deepsense-ai / ragbits

Building blocks for rapid development of GenAI applications
https://ragbits.deepsense.ai
MIT License
13 stars 2 forks source link
document-search evaluation guardrails llms prompt-management rag rag-optimization ragstack

Ragbits

*Building blocks for rapid development of GenAI applications* [Documentation](https://ragbits.deepsense.ai) | [Contact](https://deepsense.ai/contact/) [![PyPI - License](https://img.shields.io/pypi/l/ragbits)](https://pypi.org/project/ragbits) [![PyPI - Version](https://img.shields.io/pypi/v/ragbits)](https://pypi.org/project/ragbits) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ragbits)](https://pypi.org/project/ragbits)

What's Included?

Installation

To use the complete Ragbits stack, install the ragbits package:

pip install ragbits

Alternatively, you can use individual components of the stack by installing their respective packages: ragbits-core, ragbits-document-search, ragbits-cli.

Quickstart

First, create a prompt and a model for the data used in the prompt:

from pydantic import BaseModel
from ragbits.core.prompt import Prompt

class Dog(BaseModel):
    breed: str
    age: int
    temperament: str

class DogNamePrompt(Prompt[Dog, str]):
    system_prompt = """
    You are a dog name generator. You come up with funny names for dogs given the dog details.
    """

    user_prompt = """
    The dog is a {breed} breed, {age} years old, and has a {temperament} temperament.
    """

Next, create an instance of the LLM and the prompt:

from ragbits.core.llms.litellm import LiteLLM

llm = LiteLLM("gpt-4o")
example_dog = Dog(breed="Golden Retriever", age=3, temperament="friendly")
prompt = DogNamePrompt(example_dog)

Finally, generate a response from the LLM using the prompt:

response = await llm.generate(prompt)
print(f"Generated dog name: {response}")

License

Ragbits is licensed under the MIT License.

Contributing

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