Put the generated assets message after the user query and fix prompt

This commit is contained in:
Debanjum 2024-12-10 19:20:19 -08:00
parent 40e4f2ec2e
commit a757ecfd2b
2 changed files with 10 additions and 7 deletions

View file

@ -180,8 +180,8 @@ Improved Prompt:
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}

View file

@ -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(
@ -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"