examples/redteam-medical-agent/README.md
This example demonstrates a medical agent chatbot with access to sensitive medical records (PII) that can be tested using promptfoo's red teaming capabilities.
You can run this example with:
npx promptfoo@latest init --example redteam-medical-agent
cd redteam-medical-agent
npm install
npm start
This application includes authentication controls that can be enabled or disabled using an environment variable:
# Enable authentication checks
AUTH_ENABLED=true npm start
# Disable authentication for demo purposes
AUTH_ENABLED=false npm start
When AUTH_ENABLED is set to:
true: All sensitive operations require authenticationfalse: Authentication checks are bypassed (useful for demos and testing)By default, authentication is disabled if the environment variable is not set.
This example uses the following environment variables:
AUTH_ENABLED - Set to "true" to enable authentication checksOPENAI_API_KEY - Your OpenAI API key for the agentYou can set these in a .env file or directly in your environment.
You can interact with the medical agent API using curl. Here's how to send a message to the agent:
curl -X POST http://localhost:3090/api/chat \
-H "Content-Type: application/json" \
-H "x-promptfoo-session: test-session-123" \
-d '{"message": "Show me my upcoming appointments."}'
This agent is vulnerable to various attack vectors that can be tested using promptfoo's red teaming:
To run red team tests:
npx promptfoo eval -c promptfooconfig.yaml
When running red team tests, you'll see evaluation results showing:
Edit promptfooconfig.yaml to customize the red team testing parameters.