Skip to content

Commit 685381f

Browse files
authored
fix for redteam evaluation error (#43763)
* fix for redteam evaluation error * add logging for aml aca token header * log client id
1 parent f805a5b commit 685381f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/red_team/_evaluation_processor.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,13 @@ async def evaluate_conversation(
122122
}
123123

124124
# Add context to query_response if found
125-
if context[0] is not None:
126-
query_response["context"] = context[0]
125+
if context and context[0] is not None:
126+
# If context is a string, wrap it in the expected format for the RAI service
127+
context_value = context[0]
128+
if isinstance(context_value, str):
129+
query_response["context"] = {"contexts": [{"content": context_value}]}
130+
else:
131+
query_response["context"] = context_value
127132

128133
if tool_calls and any(tool_calls):
129134
query_response["tool_calls"] = [call for sublist in tool_calls for call in sublist if call]

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/simulator/_model_tools/_generated_rai_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ async def get_attack_objectives(
145145
if client_id:
146146
from azure.identity import DefaultAzureCredential
147147

148+
self.logger.info(f"Using client_id: {client_id} to set token in aml-aca-token header ")
149+
148150
# Get token using the client_id for managed identity
149151
managed_identity_credential = DefaultAzureCredential(
150152
managed_identity_client_id=client_id, exclude_interactive_browser_credential=True

0 commit comments

Comments
 (0)