Remove model type check to construct structured messages

All model types use a normalized, chatml structured message format
This check isn't used since offline model support was dropped.
This commit is contained in:
Debanjum
2025-08-25 14:13:26 -07:00
parent 386a17371d
commit 0fb6020f30

View File

@@ -23,7 +23,6 @@ from transformers import AutoTokenizer, PreTrainedTokenizer, PreTrainedTokenizer
from khoj.database.adapters import ConversationAdapters
from khoj.database.models import (
ChatMessageModel,
ChatModel,
ClientApplication,
Intent,
KhojUser,
@@ -528,11 +527,6 @@ def construct_structured_message(
Assume vision is enabled and chat model provider supports messages in chatml format, unless specified otherwise.
"""
if not model_type or model_type in [
ChatModel.ModelType.OPENAI,
ChatModel.ModelType.GOOGLE,
ChatModel.ModelType.ANTHROPIC,
]:
constructed_messages: List[dict[str, Any]] = []
if not is_none_or_empty(message):
constructed_messages += [{"type": "text", "text": message}] if isinstance(message, str) else message
@@ -546,12 +540,6 @@ def construct_structured_message(
constructed_messages += [{"type": "image_url", "image_url": {"url": image}}]
return constructed_messages
message = message if isinstance(message, str) else "\n\n".join(m["text"] for m in message)
if not is_none_or_empty(attached_file_context):
return f"{attached_file_context}\n\n{message}"
return message
def gather_raw_query_files(
query_files: Dict[str, str],