diff --git a/decart/models.py b/decart/models.py index 2e59c47..7eca043 100644 --- a/decart/models.py +++ b/decart/models.py @@ -32,21 +32,29 @@ class ModelDefinition(DecartBaseModel): class TextToVideoInput(BaseModel): - prompt: str = Field(..., min_length=1) + prompt: str = Field(..., min_length=1, max_length=1000) seed: Optional[int] = None resolution: Optional[str] = None orientation: Optional[str] = None class ImageToVideoInput(DecartBaseModel): - prompt: str = Field(..., min_length=1) + prompt: str = Field( + ..., + min_length=1, + max_length=1000, + ) data: FileInput seed: Optional[int] = None resolution: Optional[str] = None class VideoToVideoInput(DecartBaseModel): - prompt: str = Field(..., min_length=1) + prompt: str = Field( + ..., + min_length=1, + max_length=1000, + ) data: FileInput seed: Optional[int] = None resolution: Optional[str] = None @@ -55,7 +63,11 @@ class VideoToVideoInput(DecartBaseModel): class FirstLastFrameInput(DecartBaseModel): - prompt: str = Field(..., min_length=1) + prompt: str = Field( + ..., + min_length=1, + max_length=1000, + ) start: FileInput end: FileInput seed: Optional[int] = None @@ -70,14 +82,22 @@ class ImageToMotionVideoInput(DecartBaseModel): class TextToImageInput(BaseModel): - prompt: str = Field(..., min_length=1) + prompt: str = Field( + ..., + min_length=1, + max_length=1000, + ) seed: Optional[int] = None resolution: Optional[str] = None orientation: Optional[str] = None class ImageToImageInput(DecartBaseModel): - prompt: str = Field(..., min_length=1) + prompt: str = Field( + ..., + min_length=1, + max_length=1000, + ) data: FileInput seed: Optional[int] = None resolution: Optional[str] = None diff --git a/tests/test_process.py b/tests/test_process.py index fcd6e92..d717db9 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -87,6 +87,22 @@ async def test_process_video_to_video() -> None: assert result == b"fake video data" +@pytest.mark.asyncio +async def test_process_max_prompt_length() -> None: + client = DecartClient(api_key="test-key") + prompt = "a" * 1001 + with pytest.raises(DecartSDKError) as exception: + await client.process( + { + "model": models.image("lucy-pro-t2i"), + "prompt": prompt, + } + ) + assert "Invalid inputs for lucy-pro-t2i: 1 validation error for TextToImageInput" in str( + exception + ) + + @pytest.mark.asyncio async def test_process_image_to_motion_video() -> None: client = DecartClient(api_key="test-key") diff --git a/uv.lock b/uv.lock index a15cbf3..0b2dadf 100644 --- a/uv.lock +++ b/uv.lock @@ -900,7 +900,7 @@ wheels = [ [[package]] name = "decart" -version = "0.0.7" +version = "0.0.8" source = { editable = "." } dependencies = [ { name = "aiofiles" },