Keep chatml message content simple for wider compat unless attachments

This allows for wider compatibility with chat models and openai proxy
ai model apis that expect message content to be string format, not
objects.
This commit is contained in:
Debanjum
2024-12-08 22:40:32 -08:00
parent 4b4e0e20d4
commit f8957e52bf

View File

@@ -333,9 +333,10 @@ def construct_structured_message(
ChatModelOptions.ModelType.GOOGLE,
ChatModelOptions.ModelType.ANTHROPIC,
]:
constructed_messages: List[Any] = [
{"type": "text", "text": message},
]
if not attached_file_context and not (vision_enabled and images):
return message
constructed_messages: List[Any] = [{"type": "text", "text": message}]
if not is_none_or_empty(attached_file_context):
constructed_messages.append({"type": "text", "text": attached_file_context})