Skip to content
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
40ca32c
update promptflow-eval dependencies to azure-ai-evaluation
slister1001 Sep 26, 2024
3c98269
clear local variables
slister1001 Sep 26, 2024
2ccdfb2
fix errors and remove 'question' col from data
slister1001 Sep 27, 2024
fc46d6c
small fix in evaluator config
slister1001 Sep 27, 2024
c6d52a4
Merge branch 'Azure-Samples:main' into main
slister1001 Oct 11, 2024
4d6fc68
Merge branch 'Azure-Samples:main' into main
slister1001 Oct 22, 2024
d5cd237
Merge branch 'Azure-Samples:main' into main
slister1001 Oct 30, 2024
724c315
Merge branch 'Azure-Samples:main' into main
slister1001 Oct 31, 2024
57b9d02
Merge branch 'Azure-Samples:main' into main
slister1001 Nov 11, 2024
554f358
Merge branch 'Azure-Samples:main' into main
slister1001 Nov 11, 2024
c6b1727
Merge branch 'Azure-Samples:main' into main
slister1001 Nov 19, 2024
1408cff
Merge branch 'Azure-Samples:main' into main
slister1001 Nov 19, 2024
95dc1ba
Merge branch 'Azure-Samples:main' into main
slister1001 Nov 20, 2024
c751f69
Merge branch 'Azure-Samples:main' into main
slister1001 Dec 11, 2024
81a7217
Merge branch 'Azure-Samples:main' into main
slister1001 Jan 6, 2025
95e5d00
Merge branch 'Azure-Samples:main' into main
slister1001 Jan 16, 2025
d22f585
Merge branch 'Azure-Samples:main' into main
slister1001 Jan 16, 2025
39172a4
Merge branch 'Azure-Samples:main' into main
slister1001 Jan 21, 2025
0a39497
Merge branch 'Azure-Samples:main' into main
slister1001 Feb 4, 2025
283e850
Merge branch 'Azure-Samples:main' into main
slister1001 Feb 5, 2025
ed34bb5
Merge branch 'Azure-Samples:main' into main
slister1001 Mar 26, 2025
15b6023
Merge branch 'Azure-Samples:main' into main
slister1001 Apr 4, 2025
31877f2
red team updates
slister1001 Apr 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 30 additions & 8 deletions scenarios/evaluate/AI_RedTeaming/AI_RedTeaming.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"\n",
"```bash\n",
"pip install uv\n",
"uv pip install azure-ai-evaluation[redteam] termcolor==2.5.0 azure-identity openai\n",
"uv pip install azure-ai-evaluation[redteam] azure-identity openai\n",
"```\n",
"\n",
"\n",
Expand Down Expand Up @@ -64,7 +64,7 @@
"\n",
"# Azure imports\n",
"from azure.identity import DefaultAzureCredential, get_bearer_token_provider\n",
"from azure.ai.evaluation import RedTeam, RiskCategory, AttackStrategy\n",
"from azure.ai.evaluation.red_team import RedTeam, RiskCategory, AttackStrategy\n",
"\n",
"# OpenAI imports\n",
"from openai import AzureOpenAI\n",
Expand Down Expand Up @@ -126,6 +126,28 @@
"azure_openai_api_version = \"2023-12-01-preview\" # Use the latest API version"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Azure AI Project information\n",
"azure_ai_project = {\n",
" \"subscription_id\": os.environ.get(\"AZURE_SUBSCRIPTION_ID\"),\n",
" \"resource_group_name\": os.environ.get(\"AZURE_RESOURCE_GROUP_NAME\"),\n",
" \"project_name\": os.environ.get(\"AZURE_PROJECT_NAME\"),\n",
"}\n",
"\n",
"# Azure OpenAI deployment information\n",
"azure_openai_deployment = os.environ.get(\"AZURE_OPENAI_DEPLOYMENT\") # e.g., \"gpt-4\"\n",
"azure_openai_endpoint = os.environ.get(\n",
" \"AZURE_OPENAI_ENDPOINT\"\n",
") # e.g., \"https://endpoint-name.openai.azure.com/openai/deployments/deployment-name/chat/completions\"\n",
"azure_openai_api_key = os.environ.get(\"AZURE_OPENAI_API_KEY\") # e.g., \"your-api-key\"\n",
"azure_openai_api_version = \"2023-12-01-preview\" # Use the latest API version"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -322,17 +344,17 @@
" messages=[\n",
" {\"role\": \"user\", \"content\": latest_message},\n",
" ],\n",
" max_tokens=500,\n",
" temperature=0.7,\n",
" # max_tokens=500, # If using an o1 base model, comment this line out\n",
" max_completion_tokens=500, # If using an o1 base model, uncomment this line\n",
" # temperature=0.7, # If using an o1 base model, comment this line out (temperature param not supported for o1 base models)\n",
" )\n",
"\n",
" # Format the response to follow the expected chat protocol format\n",
" formatted_response = {\"content\": response.choices[0].message.content, \"role\": \"assistant\"}\n",
"\n",
" return {\"messages\": [formatted_response]}\n",
" except Exception as e:\n",
" print(f\"Error calling Azure OpenAI: {e!s}\")\n",
" return \"I encountered an error and couldn't process your request.\""
" formatted_response = \"I encountered an error and couldn't process your request.\"\n",
" return {\"messages\": [formatted_response]}"
]
},
{
Expand Down Expand Up @@ -428,7 +450,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "3-28",
"display_name": ".venv",
"language": "python",
"name": "python3"
},
Expand Down
Loading