Skip to content

Commit

Permalink
Put the generated assets message after the user query and fix prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
debanjum committed Dec 11, 2024
1 parent 40e4f2e commit 2b0dad9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/khoj/processor/conversation/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,13 @@

generated_assets_context = PromptTemplate.from_template(
"""
Assets that you created have already been created to respond to the query. Below, there are references to the descriptions used to create the assets.
You can provide a summary of your reasoning from the information below or use it to respond to the original query.
You have ALREADY created the assets described below. They will automatically be added to the final response.
You can provide a summary of your reasoning from the information below or use it to respond to my previous query.
Generated Assets:
{generated_assets}
Limit your response to 3 sentences max. Be succinct, clear, and informative.
Keep your response succinct, clear, and informative.
""".strip()
)

Expand Down
13 changes: 8 additions & 5 deletions src/khoj/processor/conversation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,14 @@ def generate_chatml_messages_with_context(

messages = []

if not is_none_or_empty(generated_asset_results):
messages.append(
ChatMessage(
content=f"{prompts.generated_assets_context.format(generated_assets=yaml_dump(generated_asset_results))}\n\n",
role="user",
)
)

if not is_none_or_empty(user_message):
messages.append(
ChatMessage(
Expand All @@ -482,11 +490,6 @@ def generate_chatml_messages_with_context(
message_attached_files = gather_raw_query_files({file.name: file.content for file in generated_files})
messages.append(ChatMessage(content=message_attached_files, role="assistant"))

if not is_none_or_empty(generated_asset_results):
context_message += (
f"{prompts.generated_assets_context.format(generated_assets=yaml_dump(generated_asset_results))}\n\n"
)

if program_execution_context:
program_context_text = "\n".join(program_execution_context)
context_message += f"{prompts.additional_program_context.format(context=program_context_text)}\n"
Expand Down

0 comments on commit 2b0dad9

Please sign in to comment.