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 a757ecf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/khoj/processor/conversation/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@

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}
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 a757ecf

Please sign in to comment.