Refactor prompt structure: move MESSAGES after instructions
Reordered prompt structure in extract_nodes.py to place MESSAGES section after instructions/guidelines in both extract_attributes and extract_summary functions for improved prompt clarity. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
896cb4e990
commit
78699b0139
1 changed files with 10 additions and 9 deletions
|
|
@ -260,10 +260,7 @@ def extract_attributes(context: dict[str, Any]) -> list[Message]:
|
||||||
role='user',
|
role='user',
|
||||||
content=f"""
|
content=f"""
|
||||||
|
|
||||||
<MESSAGES>
|
|
||||||
{to_prompt_json(context['previous_episodes'], indent=2)}
|
|
||||||
{to_prompt_json(context['episode_content'], indent=2)}
|
|
||||||
</MESSAGES>
|
|
||||||
|
|
||||||
Given the above MESSAGES and the following ENTITY, update any of its attributes based on the information provided
|
Given the above MESSAGES and the following ENTITY, update any of its attributes based on the information provided
|
||||||
in MESSAGES. Use the provided attribute descriptions to better understand how each attribute should be determined.
|
in MESSAGES. Use the provided attribute descriptions to better understand how each attribute should be determined.
|
||||||
|
|
@ -271,6 +268,11 @@ def extract_attributes(context: dict[str, Any]) -> list[Message]:
|
||||||
Guidelines:
|
Guidelines:
|
||||||
1. Do not hallucinate entity property values if they cannot be found in the current context.
|
1. Do not hallucinate entity property values if they cannot be found in the current context.
|
||||||
2. Only use the provided MESSAGES and ENTITY to set attribute values.
|
2. Only use the provided MESSAGES and ENTITY to set attribute values.
|
||||||
|
|
||||||
|
<MESSAGES>
|
||||||
|
{to_prompt_json(context['previous_episodes'], indent=2)}
|
||||||
|
{to_prompt_json(context['episode_content'], indent=2)}
|
||||||
|
</MESSAGES>
|
||||||
|
|
||||||
<ENTITY>
|
<ENTITY>
|
||||||
{context['node']}
|
{context['node']}
|
||||||
|
|
@ -289,17 +291,16 @@ def extract_summary(context: dict[str, Any]) -> list[Message]:
|
||||||
Message(
|
Message(
|
||||||
role='user',
|
role='user',
|
||||||
content=f"""
|
content=f"""
|
||||||
|
Given the MESSAGES and the ENTITY, update the summary that combines relevant information about the entity
|
||||||
|
from the messages and relevant information from the existing summary.
|
||||||
|
|
||||||
|
{summary_instructions}
|
||||||
|
|
||||||
<MESSAGES>
|
<MESSAGES>
|
||||||
{to_prompt_json(context['previous_episodes'], indent=2)}
|
{to_prompt_json(context['previous_episodes'], indent=2)}
|
||||||
{to_prompt_json(context['episode_content'], indent=2)}
|
{to_prompt_json(context['episode_content'], indent=2)}
|
||||||
</MESSAGES>
|
</MESSAGES>
|
||||||
|
|
||||||
Given the above MESSAGES and the following ENTITY, update the summary that combines relevant information about the entity
|
|
||||||
from the messages and relevant information from the existing summary.
|
|
||||||
|
|
||||||
{summary_instructions}
|
|
||||||
|
|
||||||
<ENTITY>
|
<ENTITY>
|
||||||
{context['node']}
|
{context['node']}
|
||||||
</ENTITY>
|
</ENTITY>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue