From the course: Building Secure and Trustworthy LLMs Using NVIDIA Guardrails
Unlock the full course today
Join today to access over 24,000 courses taught by industry experts.
Guardrails in action
From the course: Building Secure and Trustworthy LLMs Using NVIDIA Guardrails
Guardrails in action
- [Instructor] Finally, the time has come to witness firsthand how guardrails operate in real time. We'll be looking at guardrails in action responding to varied user queries and operating right in front of us. So let's dive right in. First, to begin, we need to install the necessary packages and set up our OpenAI API key. I've already done so by installing NeMo Guardrails and OpenAI, which can be done using pip. You also need your OpenAI API key. This key allows us to authenticate our requests to the OpenAI API. Make sure you obtain your key and replace it in the code here. Once our environment is set up, we can dive right into defining our guardrails. So let's define the guardrails' configuration. In this example, we will be taking a look at a model and an engine, which basically prevents any political discussions. For the model itself, I have a YAML content, which includes the OpenAI engine and the GPT-4o mini model, which we'll be using for this demonstration. The colang content…