Is there a way to add progress bar to this async function?async def…
- User
Is there a way to add progress bar to this async function?async def run_batch_pairwise_evaluation( judge_client: AsyncOpenAI, evaluation_data: List[Dict[str, Any]], output_dir: str = "outputs", max_concurrent: int = 3 ) -> List[Dict[str, Any]]: """ Run batch pairwise evaluations Args: judge_client: AsyncOpenAI client for judge model evaluation_data: List of evaluation dictionaries output_dir: Directory to save results max_concurrent: Maximum concurrent evaluations Expected format for evaluation_data: [ { "instruction": "User instruction", "response_1": "Response from model 1", "response_2": "Response from model 2", "model_1_name": "GPT-4", # optional "model_2_name": "Claude", # optional "uid": "eval_001" # optional } ] Returns: List of evaluation results """ semaphore = asyncio.Semaphore(max_concurrent) results = [] async def evaluate_with_semaphore(eval_item): async with semaphore: return await run_pairwise_evaluation( judge_client=judge_client, instruction=eval_item['instruction'], response_1=eval_item['response_1'], response_2=eval_item['response_2'], model_1_name=eval_item.get('model_1_name', 'Model1'), model_2_name=eval_item.get('model_2_name', 'Model2'), uid=eval_item.get('uid'), output_dir=output_dir ) tasks = [evaluate_with_semaphore(item) for item in evaluation_data] results = await asyncio.gather(*tasks, return_exceptions=True) # Save summary results summary_file = os.path.join(output_dir, f"batchsummary{datetime.now().strftime('%Y%m%d_%H%M%S')}.json") async with aiofiles.open(summary_file, 'w', encoding='utf-8') as f: await f.write(json.dumps(results, indent=2, ensure_ascii=False)) return results
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.