Keep chatml message content simple for wider compat unless attachments
Some checks are pending
dockerize / Publish Khoj Docker Images (push) Waiting to run
build and deploy github pages for documentation / deploy (push) Waiting to run
pre-commit / Setup Application and Lint (push) Waiting to run
pypi / Publish Python Package to PyPI (push) Waiting to run
test / Run Tests (push) Waiting to run

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})