From 3d930b341024efecf4e59bf7589b018bb91ecfdc Mon Sep 17 00:00:00 2001 From: ninglinLiu Date: Wed, 28 Oct 2026 14:38:59 +0800 Subject: [PATCH] Python: use FOUNDRY_* settings in the red teaming sample README --- .../evaluation/red_teaming/.env.example | 12 ++++-------- .../evaluation/red_teaming/README.md | 15 ++++++--------- .../red_teaming/red_team_agent_sample.py | 2 +- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/python/samples/05-end-to-end/evaluation/red_teaming/.env.example b/python/samples/05-end-to-end/evaluation/red_teaming/.env.example index 584c630542e..64b6b2dc43e 100644 --- a/python/samples/05-end-to-end/evaluation/red_teaming/.env.example +++ b/python/samples/05-end-to-end/evaluation/red_teaming/.env.example @@ -1,8 +1,4 @@ -# Azure OpenAI Configuration (for the agent being tested) -AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/ -AZURE_OPENAI_MODEL=gpt-4o -# AZURE_OPENAI_API_KEY=your-api-key-here - -# Azure AI Project Configuration (for red teaming) -# Create these resources at: https://portal.azure.com -FOUNDRY_PROJECT_ENDPOINT=your-ai-project-name +# Microsoft Foundry project, used by both the agent being tested (FoundryChatClient) +# and the red teaming scan. Authenticate with `az login`. +FOUNDRY_PROJECT_ENDPOINT=https://.services.ai.azure.com/api/projects/ +FOUNDRY_MODEL=gpt-4o diff --git a/python/samples/05-end-to-end/evaluation/red_teaming/README.md b/python/samples/05-end-to-end/evaluation/red_teaming/README.md index e1e68d3a4aa..6b3cb524167 100644 --- a/python/samples/05-end-to-end/evaluation/red_teaming/README.md +++ b/python/samples/05-end-to-end/evaluation/red_teaming/README.md @@ -26,7 +26,7 @@ A focused sample demonstrating Azure AI's RedTeam functionality to assess the sa ### Azure Resources 1. **Azure AI Hub and Project**: Create these in the Azure Portal - Follow: https://learn.microsoft.com/azure/ai-foundry/how-to/create-projects -2. **Azure OpenAI Deployment**: Deploy a model (e.g., gpt-4o) +2. **Model Deployment**: Deploy a model (e.g., gpt-4o) in the Foundry project 3. **Azure CLI**: Install and authenticate with `az login` ### Python Environment @@ -41,13 +41,10 @@ Note: The sample uses `python-dotenv` to load environment variables from a `.env Create a `.env` file in this directory or set these environment variables: ```bash -# Azure OpenAI (for the agent being tested) -AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/ -AZURE_OPENAI_MODEL=gpt-4o -# AZURE_OPENAI_API_KEY is optional if using Azure CLI authentication - -# Azure AI Project (for red teaming) -FOUNDRY_PROJECT_ENDPOINT=https://your-project.api.azureml.ms +# Microsoft Foundry project, used by both the agent being tested (FoundryChatClient) +# and the red teaming scan. Authentication uses Azure CLI credentials (`az login`). +FOUNDRY_PROJECT_ENDPOINT=https://.services.ai.azure.com/api/projects/ +FOUNDRY_MODEL=gpt-4o ``` See `.env.example` for a template. @@ -60,7 +57,7 @@ python red_team_agent_sample.py ``` The sample will: -1. Create a financial advisor agent using Azure OpenAI +1. Create a financial advisor agent using `FoundryChatClient` 2. Set up an async callback to interface the agent with RedTeam 3. Run a comprehensive scan with 11 different attack strategies 4. Display results as a scorecard in the console diff --git a/python/samples/05-end-to-end/evaluation/red_teaming/red_team_agent_sample.py b/python/samples/05-end-to-end/evaluation/red_teaming/red_team_agent_sample.py index 755217a12d1..9c53c7e11ab 100644 --- a/python/samples/05-end-to-end/evaluation/red_teaming/red_team_agent_sample.py +++ b/python/samples/05-end-to-end/evaluation/red_teaming/red_team_agent_sample.py @@ -53,7 +53,7 @@ async def main() -> None: credential = AzureCliCredential() # Create the agent # Constructor automatically reads from environment variables: - # AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_MODEL, AZURE_OPENAI_API_KEY + # FOUNDRY_PROJECT_ENDPOINT, FOUNDRY_MODEL agent = Agent( client=FoundryChatClient(credential=credential), name="FinancialAdvisor",