The Quickstart below is designed to get you up and running with RAG-Buddy in the shortest time possible. We do however recommend that you use the REST API version of RAG-Buddy. It is more reliable and offers additional advantages over the method described below. That having said, please do follow the quickstart below to get a feel of how RAG-Buddy works with a minimum of effort.
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
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.
The first project of your account is a trial project, meaning you get to experience the Business plan for a week. After the week passes your project’s plan will be updated to the Free plan and the cache’s data will be reset. If you wish to keep your data, subscribe to the Business plan for your project.
-
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.For the RAG+Citatio use case please refer to the Proxy Endpoint in the Guidebook. Below we continue with the Text-Classification use case exclusively.
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:Typical TC OpenAI API call
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.
TC Integration
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…