for agents API, provider data from the header is not parsed as for agents there is no provider_data_validator meta-reference implementation. Added Together data validator as the provider_data_validator for now. Did some code changes accordingly.

This commit is contained in:
Yogish Baliga 2024-09-27 14:59:24 -07:00
parent 208b861289
commit 572c01f454
5 changed files with 32 additions and 14 deletions

View file

@ -3,7 +3,6 @@
#
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
from typing import AsyncGenerator
from llama_models.llama3.api.chat_format import ChatFormat
@ -61,6 +60,20 @@ class TogetherInferenceAdapter(Inference):
role = "tool"
else:
role = message.role
if role == "user" and type(message.content) == list:
contents = []
for content in message.content:
if type(content) == str:
contents.append({"type": "text", "text": content})
elif type(content) == ImageMedia:
contents.append(
{
"type": "image_url",
"image_url": {"url": content.image.uri},
}
)
message.content = contents
together_messages.append({"role": role, "content": message.content})
return together_messages