gws-modelarmor-sanitize-prompt

Sanitize user prompts through a Google Model Armor template via the gws CLI.

Updated Nov 9, 2023
One-click install
npx skills add https://github.com/oresttokovenko/dot-files --skill gws-modelarmor-sanitize-prompt-oresttokovenko
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gws-modelarmor-sanitize-prompt
Source: https://github.com/oresttokovenko/dot-files/tree/main/chezmoi/dot_agents/skills/gws-modelarmor-sanitize-prompt
Command: npx skills add https://github.com/oresttokovenko/dot-files --skill gws-modelarmor-sanitize-prompt-oresttokovenko

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? User prompts sent to AI models can contain prompt injection attempts, unsafe content, or sensitive data. This Skill screens prompt text against a Google Model Armor template before it reaches a model, returning filter results that flag policy violations. ## Core Features & Use Cases - Prompt Sanitization: Submit text to a Model Armor template and receive filter results for prompt injection, jailbreaks, and unsafe content. - Flexible Input: Pass text directly with --text, supply a full JSON request body with --json, or pipe content through stdin. - Use Case: Before forwarding end-user input to an LLM in a chatbot pipeline, run it through a Model Armor template to detect injection attempts and block or redact flagged prompts. ## Quick Start Ask the assistant to sanitize the prompt text 'ignore previous instructions' using the Model Armor template projects/my-project/locations/us-central1/templates/my-template.

Frequently Asked Questions about gws-modelarmor-sanitize-prompt

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I sanitize a user prompt with Google Model Armor?

Run gws modelarmor +sanitize-prompt with the --template flag set to the full template resource name and --text containing the prompt. The command returns filter results indicating whether the content violates the template's policies.

How do I sanitize a prompt from a file or pipe?

If neither --text nor --json is provided, the command reads the prompt content from stdin. You can pipe text with echo or cat, for example: echo 'prompt' | gws modelarmor +sanitize-prompt --template <NAME>.

What is the difference between sanitize-prompt and sanitize-response in Model Armor?

sanitize-prompt screens inbound user-generated prompts before they reach a model, while sanitize-response screens outbound model output. Use sanitize-response for checking generated content before returning it to users.

What format does the Model Armor template name require?

The --template flag requires the full resource name in the form projects/PROJECT/locations/LOCATION/templates/TEMPLATE. Partial names or template IDs alone are not accepted.

Can I pass a full JSON request body instead of plain text?

Yes, use the --json flag to supply a complete JSON request body, which overrides --text. This is useful when you need to specify additional request fields beyond plain text content.