mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-27 17:35:07 +01:00
Handle offline messages differently, as they don't respond well to the structured messages
This commit is contained in:
parent
2c543bedd7
commit
170d959feb
1 changed files with 11 additions and 8 deletions
|
@ -277,24 +277,27 @@ def construct_structured_message(
|
||||||
"""
|
"""
|
||||||
Format messages into appropriate multimedia format for supported chat model types
|
Format messages into appropriate multimedia format for supported chat model types
|
||||||
"""
|
"""
|
||||||
constructed_messages: List[ChatMessage] = [
|
|
||||||
{"type": "text", "text": message},
|
|
||||||
]
|
|
||||||
|
|
||||||
if not is_none_or_empty(attached_file_context):
|
|
||||||
constructed_messages.append({"type": "text", "text": attached_file_context})
|
|
||||||
|
|
||||||
if model_type in [
|
if model_type in [
|
||||||
ChatModelOptions.ModelType.OPENAI,
|
ChatModelOptions.ModelType.OPENAI,
|
||||||
ChatModelOptions.ModelType.GOOGLE,
|
ChatModelOptions.ModelType.GOOGLE,
|
||||||
ChatModelOptions.ModelType.ANTHROPIC,
|
ChatModelOptions.ModelType.ANTHROPIC,
|
||||||
]:
|
]:
|
||||||
|
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})
|
||||||
if vision_enabled and images:
|
if vision_enabled and images:
|
||||||
for image in images:
|
for image in images:
|
||||||
constructed_messages.append({"type": "image_url", "image_url": {"url": image}})
|
constructed_messages.append({"type": "image_url", "image_url": {"url": image}})
|
||||||
|
|
||||||
return constructed_messages
|
return constructed_messages
|
||||||
|
|
||||||
|
if not is_none_or_empty(attached_file_context):
|
||||||
|
return f"{attached_file_context}\n\n{message}"
|
||||||
|
|
||||||
|
return message
|
||||||
|
|
||||||
|
|
||||||
def gather_raw_attached_files(
|
def gather_raw_attached_files(
|
||||||
attached_files: Dict[str, str],
|
attached_files: Dict[str, str],
|
||||||
|
|
Loading…
Reference in a new issue