A Streamlit chatbot for testing Google Cloud Model Armor LLM safety and security offering.
- Supports the following language models:
Gemini 2.5 FlashandGemini 2.5 Flash Litevia Vertex AIClaude Sonnet 4via Anthropic on Vertex AIGPT-5 nanovia OpenAI
- Supports two modes of deployment:
cloud_run.py: For deployment on Google Cloud Run, will use Application Default Credentialsstreamlit_app.py: For off-Google Cloud deployment, requires Google Cloud service account credentials
- Supports the following Model Armor regions:
us-central1,us-east1, andasia-southeast1 - Offers prompt sanitization, with optional response sanitization, for the following detection types
- Malicious URLs
- Sensitive data protection (inspect only)
- Sensitive data protection (inspect and de-identify)
- Prompt injection & jailbreak
- Responsible AI
- All of the above
- Supports confidence levels (high only / medium & above / low & above)
- Displays detailed sanitization results inline (e.g., hate speech, explicit content)
- File upload support for following file types:
PDF,CSV,TXT,DOCX - Multi-language support (see languages supported)
- Template operations and prompt/response logging
-
Clone the repo & install dependencies:
pip install -r requirements.txt
-
Environment variables required:
GOOGLE_CLOUD_PROJECT_ID: Google Cloud project IDGOOGLE_CLOUD_LOCATION: Google Cloud location (default:us-central1)MODEL_ARMOR_ENDPOINT: Model Armor endpoint (default:modelarmor.us-central1.rep.googleapis.com)OPENAI_API_KEY(optional): OpenAI API key (if you intend to use OpenAI as the model provider)
-
Prepare Sensitive Data Protection (SDP) templates in your Google Cloud project for each location.
- Inspection and de-identification templates for the following InfoTypes:
CREDIT_CARD_DATAEMAIL_ADDRESSGOVERNMENT_IDIP_ADDRESSPASSPORTPHONE_NUMBERURL
- Inspection and de-identification templates for the following InfoTypes:
-
Prepare Model Armor templates in your Google Cloud project for each location. You'll need the
Model Armorrole to do this.- "All - high only":
ma-all-high - "All - medium and above":
ma-all-med - "All - low and above":
ma-all-low - "Prompt injection and jailbreak - high only":
ma-pijb-high - "Prompt injection and jailbreak - medium and above":
ma-pijb-med - "Prompt injection and jailbreak - low and above":
ma-pijb-low - "Sensitive data protection - inspect":
ma-sdp-inspect - "Sensitive data protection - de-identify":
ma-sdp-deid - "Malicious URL detection - only":
ma-mal-url - "Responsible AI - high only":
ma-rai-high - "Responsible AI - medium and above":
ma-rai-med - "Responsible AI - low and above":
ma-rai-low
- "All - high only":
-
Run the app:
streamlit run streamlit_app.py
