Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions decart/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,23 +129,17 @@ def validate_prompt_or_reference_image(self) -> "VideoRestyleInput":
class VideoEdit2Input(DecartBaseModel):
"""Input for lucy-2-v2v model.

Must provide at least one of `prompt` or `reference_image`.
Both can be provided together.
Prompt is required but can be an empty string.
Optional reference_image can also be provided.
"""

prompt: Optional[str] = Field(default=None, min_length=1, max_length=1000)
prompt: str = Field(..., max_length=1000)
reference_image: Optional[FileInput] = None
data: FileInput
seed: Optional[int] = None
resolution: Optional[str] = None
enhance_prompt: Optional[bool] = None

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


class TextToImageInput(BaseModel):
prompt: str = Field(
Expand Down
18 changes: 2 additions & 16 deletions tests/test_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ async def test_queue_lucy2_v2v_with_prompt() -> None:


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

with patch("decart.queue.client.submit_job") as mock_submit:
Expand All @@ -298,6 +298,7 @@ async def test_queue_lucy2_v2v_with_reference_image_only() -> None:
job = await client.queue.submit(
{
"model": models.video("lucy-2-v2v"),
"prompt": "",
"reference_image": b"fake image data",
"data": b"fake video data",
}
Expand Down Expand Up @@ -330,21 +331,6 @@ async def test_queue_lucy2_v2v_with_both_prompt_and_reference_image() -> None:
mock_submit.assert_called_once()


@pytest.mark.asyncio
async def test_queue_lucy2_v2v_rejects_neither_prompt_nor_reference_image() -> None:
client = DecartClient(api_key="test-key")

with pytest.raises(DecartSDKError) as exc_info:
await client.queue.submit(
{
"model": models.video("lucy-2-v2v"),
"data": b"fake video data",
}
)

assert "at least one of 'prompt' or 'reference_image'" in str(exc_info.value).lower()


# Tests for lucy-restyle-v2v with reference_image


Expand Down
Loading