mirror of
https://github.com/calesthio/OpenMontage.git
synced 2026-08-05 15:20:40 +08:00
fix: declare env dependencies and map selector duration to frames
- Add env:VOLC_ACCESSKEY and env:VOLC_SECRETKEY to dependencies - Map selector 'duration' (seconds) to Jimeng 'frames' (121/241) - Add 4 selector duration mapping regression tests - 59 tests pass Fixes calesthio's third review feedback on PR #341.
This commit is contained in:
@@ -378,3 +378,26 @@ class TestSchemaValidation:
|
||||
schema = JimengVideo().input_schema
|
||||
for valid in [0, 1, 42, 999999]:
|
||||
jsonschema.validate({"prompt": "test", "seed": valid}, schema)
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Selector duration → frames mapping
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
class TestSelectorDurationMapping:
|
||||
|
||||
def test_duration_5_maps_to_121_frames(self):
|
||||
payload = JimengVideo._build_payload({"prompt": "x", "duration": 5})
|
||||
assert payload["frames"] == 121
|
||||
|
||||
def test_duration_10_maps_to_241_frames(self):
|
||||
payload = JimengVideo._build_payload({"prompt": "x", "duration": 10})
|
||||
assert payload["frames"] == 241
|
||||
|
||||
def test_duration_defaults_to_5_when_absent(self):
|
||||
payload = JimengVideo._build_payload({"prompt": "x"})
|
||||
assert payload["frames"] == 121
|
||||
|
||||
def test_frames_takes_priority_over_duration(self):
|
||||
payload = JimengVideo._build_payload({"prompt": "x", "frames": 241, "duration": 5})
|
||||
assert payload["frames"] == 241
|
||||
|
||||
@@ -57,7 +57,7 @@ class JimengVideo(BaseTool):
|
||||
determinism = Determinism.STOCHASTIC
|
||||
runtime = ToolRuntime.API
|
||||
|
||||
dependencies = []
|
||||
dependencies = ["env:VOLC_ACCESSKEY", "env:VOLC_SECRETKEY"]
|
||||
install_instructions = (
|
||||
"Set VOLC_ACCESSKEY and VOLC_SECRETKEY to your Volcengine IAM credentials.\n"
|
||||
" Get them at https://console.volcengine.com/iam/keymanage\n"
|
||||
@@ -252,13 +252,22 @@ class JimengVideo(BaseTool):
|
||||
model=_REQ_KEY_VIDEO,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _duration_to_frames(duration: int) -> int:
|
||||
if duration >= 10:
|
||||
return 241
|
||||
return 121
|
||||
|
||||
@staticmethod
|
||||
def _build_payload(inputs: dict[str, Any]) -> dict[str, Any]:
|
||||
operation = inputs.get("operation", "text_to_video")
|
||||
frames = inputs.get("frames")
|
||||
if frames is None:
|
||||
frames = JimengVideo._duration_to_frames(int(inputs.get("duration", 5)))
|
||||
payload: dict[str, Any] = {
|
||||
"req_key": _REQ_KEY_VIDEO,
|
||||
"prompt": inputs["prompt"],
|
||||
"frames": int(inputs.get("frames", 121)),
|
||||
"frames": int(frames),
|
||||
"aspect_ratio": inputs.get("aspect_ratio", "16:9"),
|
||||
"seed": int(inputs.get("seed", -1)),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user