mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-17 23:51:30 +00:00
fix: update EmbeddingInput type, validate nested sub-elements, add tests
This commit is contained in:
parent
ca37ced620
commit
960108939d
3 changed files with 14 additions and 1 deletions
|
|
@ -216,6 +216,13 @@ def transform_openai_input_gemini_content(
|
|||
|
||||
for element in input_list:
|
||||
if isinstance(element, list):
|
||||
if not element:
|
||||
raise ValueError("Nested input list must not be empty")
|
||||
for sub in element:
|
||||
if not isinstance(sub, str):
|
||||
raise ValueError(
|
||||
f"Elements inside a nested input list must be strings, got {type(sub)}"
|
||||
)
|
||||
parts = [
|
||||
_build_part_for_input(sub, resolved_files=resolved_files)
|
||||
for sub in element
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ FileTypes = Union[
|
|||
]
|
||||
|
||||
|
||||
EmbeddingInput = Union[str, List[str]]
|
||||
EmbeddingInput = Union[str, List[Union[str, List[str]]]]
|
||||
|
||||
|
||||
class HttpxBinaryResponseContent(_HttpxBinaryResponseContent):
|
||||
|
|
|
|||
|
|
@ -44,6 +44,12 @@ class TestIsMultimodalInput:
|
|||
def test_mixed_text_and_image(self):
|
||||
assert _is_multimodal_input(["hello", IMAGE_DATA_URI]) is True
|
||||
|
||||
def test_nested_list_is_multimodal(self):
|
||||
assert _is_multimodal_input([["text_a", "text_b"]]) is True
|
||||
|
||||
def test_nested_list_with_image_is_multimodal(self):
|
||||
assert _is_multimodal_input([["a red shoe", IMAGE_DATA_URI]]) is True
|
||||
|
||||
|
||||
class TestBuildPartForInput:
|
||||
def test_text_input(self):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue