arturzolkowski commited on
Commit
9ae57c4
·
1 Parent(s): 9d3c345

Let callers set the critic's request parameters

Browse files

VLMQualityJudge built its chat-completions request with fixed parameters, so the
reasoning and sampling settings used for the critic could not be configured: callers
reproducing a specific evaluation setup had no way to pin e.g. reasoning_effort.

Add an extra_body passthrough (default None, so the request is unchanged unless a
caller sets it) and raise the critic's max_tokens default to 16384. With reasoning
models the thinking tokens come out of the same budget (measured up to ~6.7k tokens
for gemini-3.1-pro at reasoning_effort=high), which leaves little headroom under 8192
for the analysis JSON itself.

agentic_upsampling/clients.py CHANGED
@@ -477,8 +477,9 @@ class VLMQualityJudge:
477
  api_token: str,
478
  endpoint_url: str = DEFAULT_CRITIC_ENDPOINT_URL,
479
  model: str = DEFAULT_CRITIC_MODEL,
480
- max_tokens: int = 8192,
481
  image_jpeg_quality: int | None = DEFAULT_JPEG_QUALITY,
 
482
  ) -> None:
483
  self.chat_client = OpenAIChatClient(
484
  ChatClientConfig(
@@ -487,6 +488,7 @@ class VLMQualityJudge:
487
  api_token=api_token,
488
  max_tokens=max_tokens,
489
  max_retries=3,
 
490
  )
491
  )
492
  self.image_jpeg_quality = image_jpeg_quality
 
477
  api_token: str,
478
  endpoint_url: str = DEFAULT_CRITIC_ENDPOINT_URL,
479
  model: str = DEFAULT_CRITIC_MODEL,
480
+ max_tokens: int = 16384,
481
  image_jpeg_quality: int | None = DEFAULT_JPEG_QUALITY,
482
+ extra_body: dict[str, Any] | None = None,
483
  ) -> None:
484
  self.chat_client = OpenAIChatClient(
485
  ChatClientConfig(
 
488
  api_token=api_token,
489
  max_tokens=max_tokens,
490
  max_retries=3,
491
+ extra_body=extra_body,
492
  )
493
  )
494
  self.image_jpeg_quality = image_jpeg_quality
tests/test_agentic_upsampling.py CHANGED
@@ -10,7 +10,7 @@ from typing import Any
10
 
11
  from PIL import Image
12
 
13
- from agentic_upsampling.clients import ImageGenerationClient, PromptRewriterClient
14
  from agentic_upsampling.constants import (
15
  DEFAULT_CRITIC_ENDPOINT_URL,
16
  DEFAULT_CRITIC_MODEL,
@@ -521,3 +521,14 @@ def test_extract_best_images_copies_images_and_writes_manifests(tmp_path: Path)
521
  assert (tmp_path / "export" / "best_generations.jsonl").exists()
522
  assert (tmp_path / "export" / "best_generations.csv").exists()
523
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  from PIL import Image
12
 
13
+ from agentic_upsampling.clients import ImageGenerationClient, PromptRewriterClient, VLMQualityJudge
14
  from agentic_upsampling.constants import (
15
  DEFAULT_CRITIC_ENDPOINT_URL,
16
  DEFAULT_CRITIC_MODEL,
 
521
  assert (tmp_path / "export" / "best_generations.jsonl").exists()
522
  assert (tmp_path / "export" / "best_generations.csv").exists()
523
 
524
+
525
+ def test_vlm_quality_judge_sends_no_extra_body_by_default() -> None:
526
+ judge = VLMQualityJudge(api_token="token")
527
+
528
+ assert judge.chat_client.config.extra_body is None
529
+
530
+
531
+ def test_vlm_quality_judge_forwards_extra_body() -> None:
532
+ judge = VLMQualityJudge(api_token="token", extra_body={"reasoning_effort": "high"})
533
+
534
+ assert judge.chat_client.config.extra_body == {"reasoning_effort": "high"}