fix: make vision and embedding tests pass with openai, anthropic and gemini

NOTE - Anthropic embeddings do not work due to LiteLLM not supporting
them.
This commit is contained in:
Ashwin Bharambe 2025-02-26 10:52:33 -08:00
parent abfc4b3bce
commit 4cf95475e5
4 changed files with 10 additions and 5 deletions

View file

@ -523,15 +523,19 @@ async def convert_message_to_openai_dict_new(message: Message | Dict) -> OpenAIC
) -> Union[str, Iterable[OpenAIChatCompletionContentPartParam]]:
# Llama Stack and OpenAI spec match for str and text input
if isinstance(content, str):
return content
return OpenAIChatCompletionContentPartTextParam(
type="text",
text=content,
)
elif isinstance(content, TextContentItem):
return OpenAIChatCompletionContentPartTextParam(
type="text",
text=content.text,
)
elif isinstance(content, ImageContentItem):
return OpenAIChatCompletionContentPartImageParam(
image_url=OpenAIImageURL(url=await convert_image_content_to_url(content)),
type="image_url",
image_url=OpenAIImageURL(url=await convert_image_content_to_url(content)),
)
elif isinstance(content, List):
return [await _convert_user_message_content(item) for item in content]