mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 13:18:18 +00:00
Fix system prompt construction for gemini models
System prompt was duplicating instructions for gemini models previously
This commit is contained in:
@@ -106,14 +106,14 @@ async def converse_gemini(
|
||||
day_of_week=current_date.strftime("%A"),
|
||||
)
|
||||
|
||||
system_prompt += f"{system_prompt}\n\n{prompts.gemini_verbose_language_personality}"
|
||||
system_prompt += f"\n\n{prompts.gemini_verbose_language_personality}"
|
||||
if location_data:
|
||||
location_prompt = prompts.user_location.format(location=f"{location_data}")
|
||||
system_prompt = f"{system_prompt}\n{location_prompt}"
|
||||
system_prompt += f"\n{location_prompt}"
|
||||
|
||||
if user_name:
|
||||
user_name_prompt = prompts.user_name.format(name=user_name)
|
||||
system_prompt = f"{system_prompt}\n{user_name_prompt}"
|
||||
system_prompt += f"\n{user_name_prompt}"
|
||||
|
||||
context_message = ""
|
||||
if not is_none_or_empty(references):
|
||||
|
||||
@@ -472,9 +472,12 @@ def format_messages_for_gemini(
|
||||
for message in messages.copy():
|
||||
if message.role == "system":
|
||||
if isinstance(message.content, list):
|
||||
system_prompt += "\n".join([part["text"] for part in message.content if part["type"] == "text"])
|
||||
system_prompt += "\n\n" + "\n".join(
|
||||
[part["text"] for part in message.content if part["type"] == "text"]
|
||||
)
|
||||
else:
|
||||
system_prompt += message.content
|
||||
system_prompt += "\n\n" + message.content
|
||||
system_prompt = system_prompt.strip()
|
||||
messages.remove(message)
|
||||
system_prompt = None if is_none_or_empty(system_prompt) else system_prompt
|
||||
|
||||
|
||||
Reference in New Issue
Block a user