RAG+Citation Endpoint
The /ragc Endpoint
Endpoint URI:https://api.ragbuddy.ai/ragc/v1Note that this endpoint only works for the specific use case where the LLM returns the most relevant article from the context next to the actual answer.
Make sure to check out this
Playground to experiment with the RAG+Citation Endpoint.
Versioning of the /ragc Endpoint
The /ragc endpoint implements versioning in its URL path, ensuring stable and predictable interactions with the RAG-Buddy service. The current version, designated as /ragc/v1, is established to be backward-compatible. This means that the v1 interface, encompassing its features and functionalities, will remain consistent and unchanged.As RAG-Buddy evolves, new versions may be introduced to include advanced features or improvements. These will be accessible under different version paths (e.g., /ragc/v2). Importantly, new versions will not affect the existing v1 endpoint, allowing your current integrations to continue operating seamlessly.We are dedicated to keeping our users informed about updates. New version releases and significant changes will be communicated through email notifications and posts on our blog, enabling users to stay updated and plan their transition to newer versions at their convenience./ragc Endpoint - Request
The /ragc endpoint in RAG-Buddy’s REST API is designed for handling requests specific to a RAG with citations use case.A complete request to the /ragc endpoint consists of the following elements:
- RAG-C Request Fields
- Additonal LLM Fields
- Request Headers
Read on for more detail on each of these components.RAG-C Request Fields
These request fields are used to specify the remote LLM and to construct the (system and user) messages fields of the LLM.
-
remote_llm_url (required):
- Type: string
- Description: The URL of the remote Large Language Model (LLM) that RAG-Buddy will interact with.
- For example:
https://api.openai.com/v1/chat/completions
Currently, RAG-Buddy only supports the OpenAI Chat models. Please
contact us if you would like to use a different LLM.
-
system_intro (required):
- Type: string
- Description: A brief introduction or description that sets the context for the RAG interaction.
- For example:
You are a customer support agent of the e-banking application called Piggy Bank Extraordinaire.
-
system_instructions (optional):
- Type: string or null
- Description: Custom instructions for how the system should handle the request. If not provided, default instructions are used. These instructions are used to control the RAG-Buddy Citation Engine. It is recommended to use the default instructions unless you are familiar with the RAG-Buddy Citation Engine.
- Default instructions (omit this field in case you make no changes to it):
Select the best article to reply to the question of the user below.
If you can find the answer in the articles listed below, then:
You MUST select exactly one article from the listed articles.
You MUST add the ID of the selected article at the start of your answer in the format "(ID:number) your answer", For example: (ID:1) your answer.
You MUST provide a short summarized answer.
If you cannot find the answer in the list of articles below, then:
You MUST say "(ID:None) I cannot answer this" and MUST say nothing more.
- articles (required):
- Type: array of objects (Article)
- Description: A collection of articles, each with an ID and content. These articles serve as the context for the LLM to generate a grounded response.
- Article:
- ID: string (required) - A unique identifier for the article.
- content: string (required) - The content of the article.
- For example:
[
{
"ID": "123e4567-e89b-12d3-a456-426655440000",
"content": "Interest Rates on Piggy Bank Extraordinaire's Savings Accounts\nAt Piggy Bank Extraordinaire, we understand the importance of saving for your future. That's why our Gold Plus Savings Account offers a competitive interest rate of 2.6% per annum, ensuring your savings grow steadily over time. For those seeking more flexibility, our Silver Flexi Savings Account provides an interest rate of 1.8% per annum, with the added benefit of no minimum balance requirement. Our Bronze Everyday Savings Account is perfect for daily transactions, offering a 1.2% interest rate per annum. With Piggy Bank Extraordinaire, you can choose the savings account that best suits your financial goals and lifestyle."
},
{
"ID": "123e4567-e89b-12d3-a456-426655440001",
"content": "Comparing Interest Rates: Piggy Bank Extraordinaire vs. Other Banks\nWhen it comes to choosing a bank for your savings, interest rates play a crucial role. Piggy Bank Extraordinaire stands out with its competitive rates. Our Gold Plus Savings Account offers an interest rate of 2.6% per annum, significantly higher than the industry average of 2.0%. In comparison, Big Bank offers 2.2% on its equivalent account, and Global Trust offers 2.1%. Furthermore, Piggy Bank Extraordinaire's Silver Flexi and Bronze Everyday accounts also outperform their counterparts at other banks, offering higher returns on your deposits. With Piggy Bank Extraordinaire, you can be assured of getting one of the best rates in the market for your savings."
},
{
"ID": "123e4567-e89b-12d3-a456-426655440002",
"content": "Understanding Fixed Deposit Interest Rates at Piggy Bank Extraordinaire\nFixed Deposits at Piggy Bank Extraordinaire are an excellent way to earn higher interest on your savings. Our Fixed Deposit accounts offer various tenures ranging from 6 months to 5 years, with interest rates varying accordingly. For a 6-month deposit, enjoy an interest rate of 2.0% per annum. The rate increases to 2.5% for a 1-year term and peaks at 3.5% for a 5-year term. These rates are designed to reward longer commitments with higher returns. Our Fixed Deposits are perfect for customers who wish to lock in their savings for a fixed period to earn a guaranteed return without the risks associated with market fluctuations."
}
]
- user_message (required):
- Type: string
- Description: The user’s query or message that the RAG+Citation pipeline will process.
- For example:
What are the interest rates for the Gold Plus Savings Account?
/ragc Endpoint - Response
The response is essentially the response as it would have been returned by the LLM directly. The only difference is that the RAG-Buddy Citation Engine parses the result and provides the response content and the selected article (the citation) in explicit fields: answer and article_id.The answer and article_id are not returned explicitely for a streaming response. In that case these values need to be parsed by the client from the choices.message.content response field.
Here is an example response from the /ragc endpoint:{
"id": "chatcmpl-8hzHAAX********GG",
"object": "chat.completion",
"created": 1705494340,
"model": "gpt-4",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "(ID:123e4567-e89b-12d3-a456-426655440000) The interest rate for the Gold Plus Savings Account at Piggy Bank Extraordinaire is 2.6% per annum."
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 634,
"completion_tokens": 29,
"total_tokens": 663
},
"system_fingerprint": "fp_b738595050",
"answer": "The interest rate for the Gold Plus Savings Account at Piggy Bank Extraordinaire is 2.6% per annum.",
"article_id": "123e4567-e89b-12d3-a456-426655440000"
}
The content below is independent of the use case.Text Classification Endpoint
The /tc Endpoint
Endpoint URI:https://api.ragbuddy.ai/tc/v1Note that this endpoint only works for the specific use case where the LLM return the most relevant class from the list of classes provided while creating your Text Classification cache.
Make sure to check out this
Playground to experiment with the Text-Classification Endpoint.
Versioning of the /tc Endpoint
The /tc endpoint implements versioning in its URL path, ensuring stable and predictable interactions with the RAG-Buddy service. The current version, designated as /tc/v1, is established to be backward-compatible. This means that the v1 interface, encompassing its features and functionalities, will remain consistent and unchanged.As RAG-Buddy evolves, new versions may be introduced to include advanced features or improvements. These will be accessible under different version paths (e.g., /tc/v2). Importantly, new versions will not affect the existing v1 endpoint, allowing your current integrations to continue operating seamlessly.We are dedicated to keeping our users informed about updates. New version releases and significant changes will be communicated through email notifications and posts on our blog, enabling users to stay updated and plan their transition to newer versions at their convenience./tc Endpoint - Request
The /tc endpoint in RAG-Buddy’s REST API is designed for handling requests specific the text classification use case.A complete request to the /tc endpoint consists of the following elements:
- Text Classification Request Fields
- Additonal LLM Fields
- Request Headers
Read on for more detail on each of these components.Text Classification Request Fields
These request fields are used to specify the remote LLM and to construct the (system and user) messages fields of the LLM.
-
remote_llm_url (required):
- Type: string
- Description: The URL of the remote Large Language Model (LLM) that RAG-Buddy will interact with.
- For example:
https://api.openai.com/v1/chat/completions
Currently, RAG-Buddy only supports the OpenAI Chat models. Please
contact us if you would like to use a different LLM.
-
system_instructions:
- Type: string
- Description: Guidelines for the LLM to select the most relevant class and to return that.
- For example:
You are an expert assistant in the field of customer service. Your task is to help workers in the customer service department of a company.
Your task is to classify the customer's question in order to help the customer service worker to answer the question. In order to help the worker, you MUST respond with the name of one of the following classes you know.
In case you reply with something else, you will be penalized.
The classes are the following:
-
user_message (required):
- Type: string
- Description: The user’s query or message that the Text Classification pipeline will process.
- For example:
What to do if I lost my card?
/tc Endpoint - Response
The response, whether directly from the LLM or retrieved from the cache, remains consistent with the LLM’s original output.Here is an example response from the /tc endpoint:{
"id": "chatcmpl-8paA7********A2lthE",
"object": "chat.completion",
"created": 1707304427,
"model": "gpt-4-0613",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "lost_or_stolen_card"
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 498,
"completion_tokens": 5,
"total_tokens": 503
},
"system_fingerprint": null
}
The content below is independent of the use case.