Evaluate a single image using a local vLLM server.
(task)
| 335 | # ============================================================ |
| 336 | |
| 337 | def call_evaluation_vllm(task): |
| 338 | """Evaluate a single image using a local vLLM server.""" |
| 339 | from vllm_request import evaluate_batch |
| 340 | |
| 341 | index = task["index"] |
| 342 | prompt = task["prompt"] |
| 343 | testpoint = task["testpoint"] |
| 344 | test_desc = task["test_desc"] |
| 345 | img_path = task["img_path"] |
| 346 | lang = task["lang"] |
| 347 | max_retries = task["max_retries"] |
| 348 | api_url = task["api_url"] |
| 349 | |
| 350 | system_prompt = build_system_prompt(prompt, testpoint, test_desc, lang) |
| 351 | payload = [{"images": [img_path], "problem": system_prompt}] |
| 352 | |
| 353 | text = None |
| 354 | for attempt in range(max_retries + 1): |
| 355 | result = evaluate_batch(payload, api_url)[0] |
| 356 | |
| 357 | if not result.get("success"): |
| 358 | print(f"vLLM request failed (attempt {attempt + 1}/{max_retries + 1})") |
| 359 | continue |
| 360 | |
| 361 | text = result["model_output"] |
| 362 | parsed = parse_evaluation_response(text, testpoint) |
| 363 | if parsed is not None: |
| 364 | analysis, score = parsed |
| 365 | result_json = { |
| 366 | "prompt": prompt, |
| 367 | "testpoint": testpoint, |
| 368 | "analysis": analysis, |
| 369 | "score": score, |
| 370 | } |
| 371 | return make_result(index, testpoint, prompt, img_path, text, result_json) |
| 372 | |
| 373 | # All retries exhausted |
| 374 | return make_result(index, testpoint, prompt, img_path, text) |
| 375 | |
| 376 | |
| 377 | # ============================================================ |
nothing calls this directly
no test coverage detected