Skip to content

Commit

Permalink
test(audio): improve coverage of validate prompt and media
Browse files Browse the repository at this point in the history
  • Loading branch information
g-prz committed Dec 11, 2024
1 parent d7d6b65 commit b529821
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions outlines/generate/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,8 +691,11 @@ def _validate_prompt_media_types(
def valid_types(prompts, media):
import numpy as np # type: ignore

if not isinstance(prompts, (str, list)):
return False
if not isinstance(prompts, str):
if not isinstance(prompts, list):
return False
if not all(isinstance(p, str) for p in prompts):
return False
if not isinstance(media, list):
return False
if not all(isinstance(m, np.ndarray) for m in media):
Expand Down
2 changes: 2 additions & 0 deletions tests/generate/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def test_vision_sequence_generator_validate_types(prompts, media, type_error):
"prompts,media,type_error",
[
("single prompt", [AUDIO_ARRAY], False),
(0, [AUDIO_ARRAY], True),
([AUDIO_ARRAY], "single prompt", True),
(["single prompt"], [AUDIO_ARRAY], False),
(["prompt0", "prompt1"], [AUDIO_ARRAY, AUDIO_ARRAY], False),
("single prompt", [AUDIO_ARRAY, AUDIO_ARRAY], False),
Expand Down

0 comments on commit b529821

Please sign in to comment.