feat: use managed sample resolution in request builders

parent 9537c9b8
......@@ -380,6 +380,41 @@ def test_build_request_spec_for_transcription_downloads_missing_managed_default(
uploaded_file.close()
def test_build_request_spec_for_transcription_downloads_missing_default_audio(tmp_path, monkeypatch):
managed_path = tmp_path / "samples" / "transcription.wav"
calls = []
config = {
"mode": "transcription",
"url": "http://127.0.0.1:6745",
"model": "audio:test",
"prompt": "Transcribe carefully",
"output_dir": tmp_path,
"token": None,
"audio_file": str(managed_path),
"video_file": None,
"response_format": None,
}
def fake_ensure(path_value, flag_name):
calls.append((path_value, flag_name))
managed_path.parent.mkdir(parents=True, exist_ok=True)
managed_path.write_bytes(b"downloaded-audio")
return managed_path
monkeypatch.setattr(
"tools.manual_multimodal_test_client.ensure_sample_file",
fake_ensure,
)
spec = build_request_spec(config)
uploaded_name, uploaded_file = spec["files"]["file"]
assert calls == [(str(managed_path), "--audio-file")]
assert uploaded_name == "transcription.wav"
assert uploaded_file.read() == b"downloaded-audio"
uploaded_file.close()
def test_build_request_spec_for_audio_generation_uses_json_payload(tmp_path):
config = {
"mode": "audio-generation",
......@@ -460,6 +495,39 @@ def test_build_request_spec_for_video_doubt_request_builder_uses_text_endpoint_w
assert "acknowledge that limitation" in spec["json"]["messages"][0]["content"]
def test_build_request_spec_for_video_doubt_downloads_missing_default_video(tmp_path, monkeypatch):
managed_path = tmp_path / "samples" / "question-video.mp4"
calls = []
config = {
"mode": "video-doubt",
"url": "http://127.0.0.1:6745",
"model": "vision:test",
"prompt": "What happens in this clip?",
"output_dir": tmp_path,
"token": None,
"audio_file": None,
"video_file": str(managed_path),
"response_format": None,
}
def fake_ensure(path_value, flag_name):
calls.append((path_value, flag_name))
managed_path.parent.mkdir(parents=True, exist_ok=True)
managed_path.write_bytes(b"video-bytes")
return managed_path
monkeypatch.setattr(
"tools.manual_multimodal_test_client.ensure_sample_file",
fake_ensure,
)
spec = build_request_spec(config)
assert calls == [(str(managed_path), "--video-file")]
assert str(managed_path) in spec["json"]["messages"][0]["content"]
assert "What happens in this clip?" in spec["json"]["messages"][0]["content"]
def test_build_request_spec_for_music_audio_doubt_request_builder_uses_text_endpoint_with_audio_context(tmp_path):
audio_path = tmp_path / "clip.wav"
audio_path.write_bytes(b"audio-bytes")
......
......@@ -197,7 +197,7 @@ def build_request_spec(config: dict) -> dict:
}
if mode == "video-doubt":
video_path = _require_file(config.get("video_file"), "--video-file")
video_path = ensure_sample_file(config.get("video_file"), "--video-file")
content = (
f"Video file: {video_path}\n"
f"Question: {config['prompt']}\n"
......@@ -215,7 +215,7 @@ def build_request_spec(config: dict) -> dict:
}
if mode == "music-audio-doubt":
audio_path = _require_file(config.get("audio_file"), "--audio-file")
audio_path = ensure_sample_file(config.get("audio_file"), "--audio-file")
content = (
f"Audio file: {audio_path}\n"
f"Question: {config['prompt']}\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment