Testing the Semantic Guardrails deployment
Steps to test the deployment for Semantic Guardrails
Perform the following steps to test the Semantic Guardrails deployment.
1. Testing Semantic Guardrails API
To test the Semantic Guardrails API endpoint, run the following command.
Note: The endpoints require authentication. For more information on creating a user with correct permissions and getting the JWT token, refer to PPC documentation.
GATEWAY_URL=$(kubectl get gateway pty-main -n api-gateway -o jsonpath='{.status.addresses[0].value}')
USERNAME="semantic_guardrails_user"
PASSWORD="Admin123!"
YOUR_JWT_TOKEN=$(curl -sk -X POST "${GATEWAY_URL}/api/v1/auth/login/token" \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d "loginname=${USERNAME}&password=${PASSWORD}" \
-D - -o /dev/null | grep -i 'pty_access_jwt_token' | awk '{print $2}' | tr -d '\r\n')
The sample response appears as follows.
{
"from": "user",
"to": "ai",
"content": "This is a test message for semantic analysis",
"outcome": "approved",
"score": 0.2,
"explanation": "in-domain"
}
2. Testing Data Discovery Integration
If Data Discovery is installed, then to test the Data Discovery integration, run the following command.
curl -sk -X POST "${GATEWAY_URL}/pty/semantic-guardrails/v1.1/conversations/messages/scan" -H 'Content-Type: application/json' -H "Authorization: Bearer $YOUR_JWT_TOKEN" --data '{
"messages": [
{
"from": "ai",
"to": "user",
"content": "My name is John Smith, my credit card number is 4868 7191 9682 9038",
"processors": ["pii"]
}
]
}'
The sample response appears as follows.
{
"messages": [
{
"id": "1",
"outcome": "rejected",
"score": 0.8774,
"processors": [
{
"name": "data-discovery",
"score": 0.8773500025272369,
"explanation": "['PERSON : [16, 21]', 'CREDIT_CARD : [48, 67]']"
}
]
}
],
"batch": {
"outcome": "rejected",
"score": 0.8774,
"rejected_messages": [
"1"
]
}
}
Feedback
Was this page helpful?