The guarded RAG assistant is an easily customizable recipe for building a RAG-powered chatbot.
In addition to creating a hosted, shareable user interface, the guarded RAG assistant provides:
- Business logic and LLM-based guardrails.
- A predictive secondary model that evaluates response quality.
- GenAI-focused custom metrics.
- DataRobot MLOps hosting, monitoring, and governing the individual back-end deployments.
Warning
Application templates are intended to be starting points that provide guidance on how to develop, serve, and maintain AI applications. They require a developer or data scientist to adapt and modify them for their business requirements before being put into production.
- Setup
- Architecture overview
- Why build AI Apps with DataRobot app templates?
- Make changes
- Share results
- Delete all provisioned resources
- Setup for advanced users
- Data Privacy
Important
If you are running this template in a DataRobot codespace, pulumi
is already configured and the repo is automatically cloned;
skip to Step 3.
-
If
pulumi
is not already installed, install the CLI following instructions here. After installing for the first time, restart your terminal and run:pulumi login --local # omit --local to use Pulumi Cloud (requires separate account)
-
Clone the template repository.
git clone https://github.com/datarobot-community/guarded-rag-assistant.git cd guarded-rag-assistant
-
Rename the file
.env.template
to.env
in the root directory of the repo and populate your credentials. This template is pre-configured to use an Azure OpenAI endpoint. If you wish to use a different LLM provider, modifications to the code will be necessary.Please refer to the documentation inside
.env.template
-
In a terminal, run:
python quickstart.py YOUR_PROJECT_NAME # Windows users may have to use `py` instead of `python`
Python 3.9+ is required.
Advanced users desiring control over virtual environment creation, dependency installation, environment variable setup,
and pulumi
invocation see the advanced setup instructions.
App templates contain three families of complementary logic. For Guarded RAG you can opt-in to fully custom RAG logic and a fully custom frontend or utilize DR's off the shelf offerings:
- AI logic: Necessary to service AI requests and produce predictions and completions.
deployment_*/ # Predictive model scoring logic, RAG completion logic (DIY RAG) notebooks/ # Document chunking, VDB creation logic (DIY RAG)
- App Logic: Necessary for user consumption; whether via a hosted front-end or integrating into an external consumption layer.
frontend/ # Streamlit frontend (DIY frontend) docsassist/ # App business logic & runtime helpers (DIY front-end)
- Operational Logic: Necessary to activate DataRobot assets.
__main__.py # Pulumi program for configuring DataRobot to serve and monitor AI and App logic infra/ # Settings for resources and assets created in DataRobot
App Templates transform your AI projects from notebooks to production-ready applications. Too often, getting models into production means rewriting code, juggling credentials, and coordinating with multiple tools & teams just to make simple changes. DataRobot's composable AI apps framework eliminates these bottlenecks, letting you spend more time experimenting with your ML and app logic and less time wrestling with plumbing and deployment.
- Start building in minutes: Deploy complete AI applications instantly, then customize the AI logic or the front-end independently (no architectural rewrites needed).
- Keep working your way: Data scientists keep working in notebooks, developers in IDEs, and configs stay isolated. Update any piece without breaking others.
- Iterate with confidence: Make changes locally and deploy with confidence. Spend less time writing and troubleshooting plumbing and more time improving your app.
Each template provides an end-to-end AI architecture, from raw inputs to deployed application, while remaining highly customizable for specific business requirements.
- Replace
assets/datarobot_english_documentation_docsassist.zip
with a new zip file containing .pdf, .docx, .md, or .txt documents (example alternative docs here). - Update the
rag_documents
setting ininfra/settings_main.py
to specify the local path to the new zip file. - Run
pulumi up
to update your stack.source set_env.sh # On windows use `set_env.bat` pulumi up
- Modify the
LLM
setting ininfra/settings_generative.py
by changingLLM=GlobalLLM.AZURE_OPENAI_GPT_4_O
to any other LLM from theGlobalLLM
object. - Provide the required credentials in
.env
dependent on your choice. - Run
pulumi up
to update your stack (Or rerun your quickstart).source set_env.sh # On windows use `set_env.bat` pulumi up
- Modify the
system_prompt
variable ininfra/settings_generative.py
with your desired prompt. - If using fully custom RAG logic, instead please change the
stuff_prompt
variable innotebooks/build_rag.ipynb
.
- Edit
infra/settings_main.py
and updateapplication_type
toApplicationType.DIY
- Optionally, update
APP_LOCALE
indocsassist/i18n.py
to toggle the language. Supported locales are Japanese and English, with English set as the default.
- Optionally, update
- Run
pulumi up
to update your stack with the example custom Streamlit frontend:source set_env.sh # On windows use `set_env.bat` pulumi up
- After provisioning the stack at least once, you can also edit and test the Streamlit
front-end locally using
streamlit run app.py
from thefrontend/
directory (don't forget to initialize your environment usingset_env
).source set_env.sh # On windows use `set_env.bat` cd frontend streamlit run app.py
- Install additional requirements (e.g. FAISS, HuggingFace).
source set_env.sh # On windows use `set_env.bat` pip install -r requirements-extra.txt
- Edit
infra/settings_main.py
and updaterag_type
toRAGType.DIY
. - Run
pulumi up
to update your stack with the example custom RAG logic.source set_env.sh # On windows use `set_env.bat` pulumi up
- Edit
notebooks/build_rag.ipynb
to customize the doc chunking, vectorization logic. - Edit
deployment_diy_rag/custom.py
to customize the retrieval logic & LLM call. - Run
pulumi up
to update your stack.source set_env.sh # On windows use `set_env.bat` pulumi up
- Log into the DataRobot application.
- Navigate to Registry > Applications.
- Navigate to the application you want to share, open the actions menu, and select Share from the dropdown.
pulumi down
For manual control over the setup process adapt the following steps for MacOS/Linux to your environent:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
source set_env.sh
pulumi stack init YOUR_PROJECT_NAME
pulumi up
e.g. for Windows/conda/cmd.exe this would be:
conda create --prefix .venv pip
conda activate .\.venv
pip install -r requirements.txt
set_env.bat
pulumi stack init YOUR_PROJECT_NAME
pulumi up
For projects that will be maintained, DataRobot recommends forking the repo so upstream fixes and improvements can be merged in the future.
Your data privacy is important to us. Data handling is governed by the DataRobot Privacy Policy, please review before using your own data with DataRobot.