Skip to content

Commit e74d5ff

Browse files
authored
Fix for applying concurrency control (#41280)
* Fix for concurrency control * fix * fix for safety eval * fix for safety eval * fix for safety eval
1 parent 6cbabb4 commit e74d5ff

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_safety_evaluation/_safety_evaluation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,7 @@ async def __call__(
825825
source_text=source_text,
826826
direct_attack=_SafetyEvaluator.DIRECT_ATTACK in evaluators,
827827
randomization_seed=randomization_seed,
828+
concurrent_async_tasks=concurrent_async_tasks,
828829
)
829830
elif data_path:
830831
data_paths = {Path(data_path).stem: data_path}

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/simulator/_adversarial_simulator.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -365,23 +365,28 @@ async def _simulate_async(
365365
)
366366
bots = [user_bot, system_bot]
367367

368+
async def run_simulation(session_obj):
369+
async with semaphore:
370+
_, conversation_history = await simulate_conversation(
371+
bots=bots,
372+
session=session_obj,
373+
turn_limit=max_conversation_turns,
374+
api_call_delay_sec=api_call_delay_sec,
375+
language=language,
376+
)
377+
return conversation_history
378+
368379
if isinstance(self.rai_client, AIProjectClient):
369380
session = self.rai_client
370-
else:
381+
else:
371382
session = get_async_http_client().with_policies(
372383
retry_policy=AsyncRetryPolicy(
373384
retry_total=api_call_retry_limit,
374385
retry_backoff_factor=api_call_retry_sleep_sec,
375386
retry_mode=RetryMode.Fixed,
376387
)
377388
)
378-
_, conversation_history = await simulate_conversation(
379-
bots=bots,
380-
session=session,
381-
turn_limit=max_conversation_turns,
382-
api_call_delay_sec=api_call_delay_sec,
383-
language=language,
384-
)
389+
conversation_history = await run_simulation(session)
385390

386391
return self._to_chat_protocol(
387392
conversation_history=conversation_history,

0 commit comments

Comments
 (0)