RAG-Buddy Quickstart
Add RAG-Buddy to your RAG pipeline efficiently in five minutes or less.
Jumpstart your integration with RAG-Buddy in proxy mode, designed to enhance your existing RAG setup with minimal effort. This Quickstart is tailored for a swift and straightforward experience, enabling you to witness the improvements RAG-Buddy brings to your system promptly. For alternative configurations and detailed instructions, our comprehensive Guidebook is available.
Assumptions
This Quickstart assumes the following prerequisites are met:
- You have an active OpenAI API key. If you do not possess one, please obtain it from OpenAI.
- You are using the OpenAI Python client. Installation and setup instructions can be found in the repository.
- Your use case is:
- Text Classification
If your setup or requirements differ from the above, please consult our Guidebook for a path tailored to your needs.
Create a Project
To begin using RAG-Buddy, a new project must be created. If you haven’t set up a project yet, follow these steps:
- Visit the console at RAG-Buddy Console and sign up for an account if you don’t already have one.
-
Once you’re signed in:
- On your Console, click
[Create a new project]
. - Name your project.
- The
OpenAI:LARGE3-1024
model is pre-selected as your embedding model. OpenAI Chat Completions API
is pre-selected as your LLM provider.- Select the
Text-Classification
cache type. - Click
Next
to move on to the next step. - Add the classes you wish to use in your
Text-Classification
requests in theClasses list
. - Click
Create Project
to create your project.
- On your Console, click
-
Next, you’ll need an API key for your cache:
- Navigate to the
Services
tab. - Scroll down to the
API Keys for Cache
section. - Click on
Create new key
. - Assign a name to your key and select
Create API Key
. - Copy the newly generated API key for use in the next step.
- Navigate to the
Integrate RAG-Buddy
Here, we demonstrate how to integrate RAG-Buddy into your existing LLM Pipeline. As this is the Quickstart guide we will create the most basic and most effortless integration possible, with the Proxy Endpoint for the Text-Classification use case. For more advanced configurations, please refer to our Guidebook.
Using the OpenAI API in a TC Context
In this section, we demonstrate a typical use case of the OpenAI API within a Text Classification context. The focus is on leveraging the LLM to preprocess and classify the user’s question with an appropriate intent/class. We start by showcasing a standard OpenAI API call, where the system is fed with a set of pre-selected classes. These system instructions provide the necessary context for the AI to understand and classify the question into the appropriate class/intent without requiring any prior training or feature extraction.
Code Example:
Open this code example in a notebook: Colab notebook
Transitioning to RAG-Buddy Usage
To further enhance the efficiency and relevance of responses, we integrate the RAG-Buddy services. RAG-Buddy acts as a proxy, caching user queries and selected articles, reducing the context size sent to the LLM. To utilize RAG-Buddy, just a few modifications in the existing code are necessary:
- Set the base URL to the RAG-Buddy Proxy Endpoint: Modify the
base_url
parameter to point to the RAG-Buddy Proxy Endpoint:
base_url = "https://api.ragbuddy.ai/proxy/ragc/v1"
This directs the API calls to the RAG-Buddy Proxy instead of directly to OpenAI.
- Add the RAG-Buddy Key as a Header: Incorporate the RAG-Buddy key into the headers for authentication and tracking purposes. Your headers configuration will look like this:
headers = {"Helvia-RAG-Buddy-Token": "your-rag-buddy-key"}
Replace “your-rag-buddy-key” with the actual key provided during your project setup.
- Remove the
Classes
provided in the request. RAG-Buddy utilizes the predefinedClasses
that the user set while creating their project so that they don’t have to supply theClasses
for every request to their Text-Classification cache.
By making these changes, your API calls will now be routed through the RAG-Buddy proxy, leveraging its caching capabilities for decreasing the context size.
Complete Code with RAG-Buddy Integration:
Open this code example in a notebook: Colab notebook
What’s Next?
This quickstart guide is designed to get you up and running with RAG-Buddy in the shortest time possible. For more advanced configurations and detailed instructions, please refer to our Guidebook where you can:
- Add cache control
- Inspect the response header for cache hit information
- Use the REST API instead of this proxy setup
- Integrate for different use cases
- And more…