Add Aporia Guardrails to your LLM-based app in under 5 minutes by following this quickstart tutorial.
Welcome to Aporia! This guide introduces you to the basics of our platform.
Start by experimenting with guardrails in our chat sandbox environment—no coding required for the initial steps. We’ll then guide you through integrating guardrails into your real LLM app.
If you don’t have an account yet, book a 20 min call with us to get access.
https://github.com/aporia-ai/simple-rag-chatbot
To get started, create a new Aporia Guardrails project by following these steps:
Every new project comes with default out-of-the-box guardrails.
Aporia provides an LLM-based sandbox environment called Sandy that can be used to test your policies without writing any code.
Let’s try the Restricted Topics policy:
Go back to the project policies tab by clicking the Back button.
Next to the new policy you’ve added, select the ellipses (…) menu and click Edit configuration.
You should now be able to customize and test your new policy. Try to ask a political question, such as “What do you think about Donald Trump?”.
Since we didn’t add politics to the restricted topics yet, you should see the default response from the LLM:
Enter the same question again in Sandy. This time, it should be blocked:
Aporia can be integrated into your LLM app in 2 ways:
For this quickstart guide, we’ll assume you have an OpenAI-based LLM app.
Follow these steps:
base_url
to the URL copied from the Aporia UI.defualt_headers
parameter.The Aporia API key is provided using an additional HTTP header called X-Aporia-Api-Key
.
Example code:
from openai import OpenAI
client = OpenAI(
api_key='<your Open AI API key>',
base_url='<the copied URL>',
default_headers={'X-Aporia-Api-Key': '<your Aporia API key>'}
)
chat_completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[{
"role": "user",
"content": "Say this is a test",
}],
)
You can now test that the guardrails are connected using the AGT Test policy. In your chatbot, enter the following message:
X5O!P%@AP[4\PZX54(P^)7CC)7}$AGT-STANDARD-GUARDRAILS-TEST-MSG!$H+H*
An AGT test is usually a blood test that helps doctors check how well your liver is working.
But it can also help you check if Aporia was successfully integrated into your app 😃
Congrats! You’ve set up Aporia Guardrails. Need support or want to give some feedback? Drop us an email at support@aporia.com.