[Misc] Validate Cohere Embed Mixed Content Payloads (#45873)
Signed-off-by: Taneem Ibrahim <taneem.ibrahim@gmail.com>
This commit is contained in:
@@ -150,6 +150,16 @@ class TestCohereEmbedRequestParsing:
|
||||
{"content": [{"type": "text", "text": "hello"}]},
|
||||
],
|
||||
},
|
||||
{
|
||||
"model": "test",
|
||||
"inputs": [
|
||||
{
|
||||
"content": [
|
||||
{"type": "image_url", "image_url": {"url": "image-uri"}}
|
||||
]
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
)
|
||||
def test_accepts_exactly_one_non_empty_input_field(self, request_body):
|
||||
@@ -157,6 +167,38 @@ class TestCohereEmbedRequestParsing:
|
||||
|
||||
assert request.model == "test"
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("content", "error"),
|
||||
[
|
||||
(
|
||||
{"type": "text"},
|
||||
"CohereEmbedContent with type='text' requires text",
|
||||
),
|
||||
(
|
||||
{"type": "image_url"},
|
||||
"CohereEmbedContent with type='image_url' requires image_url.url",
|
||||
),
|
||||
(
|
||||
{"type": "image_url", "image_url": {}},
|
||||
"CohereEmbedContent with type='image_url' requires image_url.url",
|
||||
),
|
||||
(
|
||||
{"type": "image_url", "image_url": {"url": ""}},
|
||||
"CohereEmbedContent with type='image_url' requires image_url.url",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_rejects_invalid_mixed_content_payloads(self, content, error):
|
||||
with pytest.raises(ValidationError, match=error):
|
||||
CohereEmbedRequest(
|
||||
model="test",
|
||||
inputs=[
|
||||
{
|
||||
"content": [content],
|
||||
},
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
class TestResolveTruncation:
|
||||
"""Unit tests for EmbedIOProcessor._resolve_cohere_truncation."""
|
||||
|
||||
Reference in New Issue
Block a user