azureai-samples icon indicating copy to clipboard operation
azureai-samples copied to clipboard

Issues with AI Red Teaming Agent jupytner notebook sample does not work

Open kzhen12 opened this issue 8 months ago • 4 comments

Operating System

Windows

Version Information

FileNotFoundError: Could not find module 'c:\Program Files\Python311\Lib\site-packages\azure\cognitiveservices\speech\Microsoft.CognitiveServices.Speech.core.dll' (or one of its dependencies). Try using the full path with constructor syntax.

Steps to reproduce

trying this on a new vm everytime and i always end up having this error after following the steps provided

Expected behavior

expected the notebook to run smoothly

Actual behavior

a bunch of errors with very little documentation

Addition information

No response

kzhen12 avatar Apr 10 '25 22:04 kzhen12

Plus one to this bug. I followed the venv setup and still can't run the import cell

`--------------------------------------------------------------------------- ImportError Traceback (most recent call last) Cell In[2], line 6 4 # Azure imports 5 from azure.identity import DefaultAzureCredential, get_bearer_token_provider ----> 6 from azure.ai.evaluation.red_team import RedTeam, RiskCategory, AttackStrategy 8 # OpenAI imports 9 from openai import AzureOpenAI

ImportError: cannot import name 'RedTeam' from 'azure.ai.evaluation.red_team' (/Users/keatnuxsuo/Documents/Documents - Jia’s Laptop/Code/Microsoft/AzureAI-Samples/azureai-samples/scenarios/evaluate/AI_RedTeaming/.venv/lib/python3.11/site-packages/azure/ai/evaluation/red_team/init.py)`

Keatnuxsuo avatar Apr 11 '25 03:04 Keatnuxsuo

Hello, these seem to be two separate issues.

@kzhen12 have you been able to create a virtual environment to run this notebook in? Based on the attached error you shared, you do not seem to be running this in a virtual environment azure-ai-evaluation[redteam] is installed.

@Keatnuxsuo can you confirm which version of azure-ai-evaluation you have installed?

slister1001 avatar Apr 11 '25 22:04 slister1001

@slister1001 this is the detail

Name: azure-ai-evaluation Version: 1.5.0 Location: /Users/keatnuxsuo/Documents/Documents - Jia’s Laptop/Code/Microsoft/AzureAI-Samples/azureai-samples/scenarios/evaluate/AI_RedTeaming/.venv/lib/python3.11/site-packages Requires: azure-core, azure-identity, azure-storage-blob, httpx, msrest, nltk, openai, pandas, promptflow-core, promptflow-devkit, pyjwt, ruamel-yaml

Keatnuxsuo avatar Apr 12 '25 00:04 Keatnuxsuo

@slister1001 Fixed the issue with FileNotFoundError: Could not find module 'c:\Program Files\Python311\Lib\site-packages\azure\cognitiveservices\speech\Microsoft.CognitiveServices.Speech.core.dll' (or one of its dependencies). Try using the full path with constructor syntax. the issue was main the azure VM i spun up did not have .net framework installed. I'm facing another issue that I can't figure out. this is through an azure windows 11 Virtual machine im trying this on. It's not an issue with the permissions because I have full access and I've tried the same notebook on my personal machine, not azure virtual machine and it worked. Not sure what is missing from azure virtual machine that makes it not work.

Exception Traceback (most recent call last) Cell In[24], line 2 1 # Create the RedTeam instance with minimal configurations ----> 2 red_team = RedTeam( 3 azure_ai_project=azure_ai_project, 4 credential=credential, 5 risk_categories=[RiskCategory.Violence, RiskCategory.HateUnfairness], 6 num_objectives=1, 7 )

File c:\Users\kzhen\Desktop\aired.venv\Lib\site-packages\azure\ai\evaluation_common_experimental.py:80, in _add_class_docstring.._add_class_warning..wrapped(*args, **kwargs) 78 if not _should_skip_warning() and not _is_warning_cached(message): 79 module_logger.warning(message) ---> 80 return func(*args, **kwargs)

File c:\Users\kzhen\Desktop\aired.venv\Lib\site-packages\azure\ai\evaluation\red_team_red_team.py:128, in RedTeam.init(self, azure_ai_project, credential, risk_categories, num_objectives, application_scenario, custom_attack_seed_prompts, output_dir) 125 self.scan_output_dir = None 127 self.rai_client = RAIClient(azure_ai_project=self.azure_ai_project, token_manager=self.token_manager) --> 128 self.generated_rai_client = GeneratedRAIClient(azure_ai_project=self.azure_ai_project, token_manager=self.token_manager.get_aad_credential()) #type: ignore 130 # Initialize a cache for attack objectives by risk category and strategy 131 self.attack_objectives = {}

File c:\Users\kzhen\Desktop\aired.venv\Lib\site-packages\azure\ai\evaluation\simulator_model_tools_generated_rai_client.py:33, in GeneratedRAIClient.init(self, azure_ai_project, token_manager) 31 endpoint = os.environ["RAI_SVC_URL"].rstrip("/") ... ---> 69 raise Exception(msg) 71 # Parse the discovery URL 72 from urllib.parse import urlparse

Exception: Failed to connect to your Azure AI project. Please check if the project scope is configured correctly, and make sure you have the necessary access permissions. Status code: 403. Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...

kzhen12 avatar Apr 12 '25 03:04 kzhen12