mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-04 05:39:06 +00:00
Pass username, location context in system prompt instead of chat message
The username and location in system prompt should disambiguate user context from user's actual message for the chat model. It doesn't need to be told to not mention the context or acknowledge the context instructions in it's response, as it understands that this information is just context and not part of the user's actual message.
This commit is contained in:
@@ -155,11 +155,11 @@ def converse_offline(
|
||||
if location_data:
|
||||
location = f"{location_data.city}, {location_data.region}, {location_data.country}"
|
||||
location_prompt = prompts.user_location.format(location=location)
|
||||
conversation_primer = f"{location_prompt}\n{conversation_primer}"
|
||||
system_prompt = f"{system_prompt}\n{location_prompt}"
|
||||
|
||||
if user_name:
|
||||
user_name_prompt = prompts.user_name.format(name=user_name)
|
||||
conversation_primer = f"{user_name_prompt}\n{conversation_primer}"
|
||||
system_prompt = f"{system_prompt}\n{user_name_prompt}"
|
||||
|
||||
# Get Conversation Primer appropriate to Conversation Type
|
||||
if conversation_commands == [ConversationCommand.Notes] and is_none_or_empty(compiled_references_message):
|
||||
|
||||
@@ -137,11 +137,11 @@ def converse(
|
||||
if location_data:
|
||||
location = f"{location_data.city}, {location_data.region}, {location_data.country}"
|
||||
location_prompt = prompts.user_location.format(location=location)
|
||||
conversation_primer = f"{location_prompt}\n{conversation_primer}"
|
||||
system_prompt = f"{system_prompt}\n{location_prompt}"
|
||||
|
||||
if user_name:
|
||||
user_name_prompt = prompts.user_name.format(name=user_name)
|
||||
conversation_primer = f"{user_name_prompt}\n{conversation_primer}"
|
||||
system_prompt = f"{system_prompt}\n{user_name_prompt}"
|
||||
|
||||
# Get Conversation Primer appropriate to Conversation Type
|
||||
if conversation_commands == [ConversationCommand.Notes] and is_none_or_empty(compiled_references):
|
||||
|
||||
@@ -511,14 +511,12 @@ You are using the **{model}** model on the **{device}**.
|
||||
# --
|
||||
user_location = PromptTemplate.from_template(
|
||||
"""
|
||||
Mention the user's location only if it's relevant to the conversation.
|
||||
User's Location: {location}
|
||||
""".strip()
|
||||
)
|
||||
|
||||
user_name = PromptTemplate.from_template(
|
||||
"""
|
||||
Mention the user's name only if it's relevant to the conversation.
|
||||
User's Name: {name}
|
||||
""".strip()
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user