Skip to content

Commit 1e93d84

Browse files
authored
fix: make prompt required for lucy-2-v2v (can be empty string) (#37)
Update VideoEdit2Input to require prompt field (allowing empty strings) to match API spec. Remove model_validator for prompt/reference_image since prompt is always required.
1 parent b94e543 commit 1e93d84

2 files changed

Lines changed: 5 additions & 25 deletions

File tree

decart/models.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,23 +129,17 @@ def validate_prompt_or_reference_image(self) -> "VideoRestyleInput":
129129
class VideoEdit2Input(DecartBaseModel):
130130
"""Input for lucy-2-v2v model.
131131
132-
Must provide at least one of `prompt` or `reference_image`.
133-
Both can be provided together.
132+
Prompt is required but can be an empty string.
133+
Optional reference_image can also be provided.
134134
"""
135135

136-
prompt: Optional[str] = Field(default=None, min_length=1, max_length=1000)
136+
prompt: str = Field(..., max_length=1000)
137137
reference_image: Optional[FileInput] = None
138138
data: FileInput
139139
seed: Optional[int] = None
140140
resolution: Optional[str] = None
141141
enhance_prompt: Optional[bool] = None
142142

143-
@model_validator(mode="after")
144-
def validate_prompt_or_reference_image(self) -> "VideoEdit2Input":
145-
if self.prompt is None and self.reference_image is None:
146-
raise ValueError("Must provide at least one of 'prompt' or 'reference_image'")
147-
return self
148-
149143

150144
class TextToImageInput(BaseModel):
151145
prompt: str = Field(

tests/test_queue.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ async def test_queue_lucy2_v2v_with_prompt() -> None:
289289

290290

291291
@pytest.mark.asyncio
292-
async def test_queue_lucy2_v2v_with_reference_image_only() -> None:
292+
async def test_queue_lucy2_v2v_with_empty_prompt_and_reference_image() -> None:
293293
client = DecartClient(api_key="test-key")
294294

295295
with patch("decart.queue.client.submit_job") as mock_submit:
@@ -298,6 +298,7 @@ async def test_queue_lucy2_v2v_with_reference_image_only() -> None:
298298
job = await client.queue.submit(
299299
{
300300
"model": models.video("lucy-2-v2v"),
301+
"prompt": "",
301302
"reference_image": b"fake image data",
302303
"data": b"fake video data",
303304
}
@@ -330,21 +331,6 @@ async def test_queue_lucy2_v2v_with_both_prompt_and_reference_image() -> None:
330331
mock_submit.assert_called_once()
331332

332333

333-
@pytest.mark.asyncio
334-
async def test_queue_lucy2_v2v_rejects_neither_prompt_nor_reference_image() -> None:
335-
client = DecartClient(api_key="test-key")
336-
337-
with pytest.raises(DecartSDKError) as exc_info:
338-
await client.queue.submit(
339-
{
340-
"model": models.video("lucy-2-v2v"),
341-
"data": b"fake video data",
342-
}
343-
)
344-
345-
assert "at least one of 'prompt' or 'reference_image'" in str(exc_info.value).lower()
346-
347-
348334
# Tests for lucy-restyle-v2v with reference_image
349335

350336

0 commit comments

Comments
 (0)