diff --git a/scenarios/evaluate/AI_RedTeaming/AI_RedTeaming.ipynb b/scenarios/evaluate/AI_RedTeaming/AI_RedTeaming.ipynb index a17ffc18..180c215a 100644 --- a/scenarios/evaluate/AI_RedTeaming/AI_RedTeaming.ipynb +++ b/scenarios/evaluate/AI_RedTeaming/AI_RedTeaming.ipynb @@ -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", @@ -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", @@ -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": {}, @@ -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]}" ] }, { @@ -428,7 +450,7 @@ ], "metadata": { "kernelspec": { - "display_name": "3-28", + "display_name": ".venv", "language": "python", "name": "python3" },