mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-07 13:23:15 +00:00
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:
@@ -23,7 +23,6 @@ from transformers import AutoTokenizer, PreTrainedTokenizer, PreTrainedTokenizer
|
|||||||
from khoj.database.adapters import ConversationAdapters
|
from khoj.database.adapters import ConversationAdapters
|
||||||
from khoj.database.models import (
|
from khoj.database.models import (
|
||||||
ChatMessageModel,
|
ChatMessageModel,
|
||||||
ChatModel,
|
|
||||||
ClientApplication,
|
ClientApplication,
|
||||||
Intent,
|
Intent,
|
||||||
KhojUser,
|
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.
|
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]] = []
|
constructed_messages: List[dict[str, Any]] = []
|
||||||
if not is_none_or_empty(message):
|
if not is_none_or_empty(message):
|
||||||
constructed_messages += [{"type": "text", "text": message}] if isinstance(message, str) else 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}}]
|
constructed_messages += [{"type": "image_url", "image_url": {"url": image}}]
|
||||||
return constructed_messages
|
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(
|
def gather_raw_query_files(
|
||||||
query_files: Dict[str, str],
|
query_files: Dict[str, str],
|
||||||
|
|||||||
Reference in New Issue
Block a user