Skip to content

Commit

Permalink
Tweak model instructions for JSON responses
Browse files Browse the repository at this point in the history
  • Loading branch information
clareliguori committed Jan 18, 2025
1 parent 8c9001a commit e6066dd
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 11 deletions.
9 changes: 4 additions & 5 deletions stacks/meal_planner_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
meal_scoring_prompt += """
\}
</example>
Do not include any other content outside of the JSON object.
"""
Do not include any other content other than the JSON object in your response. Do not include any XML tags in your response."""

meal_scoring_job = get_anthropic_claude_invoke_chain(
self,
Expand Down Expand Up @@ -270,7 +269,8 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
Answer yes if the chefs suggested the same meal, similar meals, or meals that are a small variation of each other.
Start your response with an explanation of your reasoning, then provide a single 'yes' or 'no' indicating whether agreement has been reached.
Your response should be formatted as a JSON object. An example of a valid response is below when the chefs do agree, inside <example></example> XML tags.
Your response should be formatted as a JSON object.
An example of a valid response is below when the chefs do agree, inside <example></example> XML tags.
<example>
\{
"reasoning": "Brief reasons for why I believe the chefs have reached agreement...",
Expand All @@ -285,8 +285,7 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
"do_chefs_agree": "no"
\}
</example>
Do not include any other content outside of the JSON object.
"""
Do not include any other content other than the JSON object in your response. Do not include any XML tags in your response."""

meal_debate_referee_job = get_anthropic_claude_invoke_chain(
self,
Expand Down
3 changes: 1 addition & 2 deletions stacks/story_writer_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
\}
]
</example>
Do not include any other content outside of the JSON object.
""",
Do not include any other content other than the JSON object in your response. Do not include any XML tags in your response.""",
sfn.JsonPath.string_at("$$.Execution.Input.story_description"),
),
max_tokens_to_sample=512,
Expand Down
2 changes: 1 addition & 1 deletion techniques_bedrock_flows/stacks/map_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
}
]
</example>
Do not include any other content outside of the JSON object."""
Do not include any other content other than the JSON object in your response. Do not include any XML tags in your response."""

get_summary_prompt_content = (
"Write a 1-2 sentence summary for the novel {{title}} by {{author}}."
Expand Down
2 changes: 1 addition & 1 deletion techniques_step_functions/stacks/conditional_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
"is_book": "no"
\}
</example>
Do not include any other content outside of the JSON object.""",
Do not include any other content other than the JSON object in your response. Do not include any XML tags in your response.""",
sfn.JsonPath.string_at("$$.Execution.Input"),
),
}
Expand Down
2 changes: 1 addition & 1 deletion techniques_step_functions/stacks/map_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
\}
]
</example>
Do not include any other content outside of the JSON object.""",
Do not include any other content other than the JSON object in your response. Do not include any XML tags in your response.""",
}
],
}
Expand Down
2 changes: 1 addition & 1 deletion techniques_step_functions/stacks/validation_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
\}
]
</example>
Do not include any other content outside of the JSON object."""
Do not include any other content other than the JSON object in your response. Do not include any XML tags in your response."""

get_books = tasks.BedrockInvokeModel(
self,
Expand Down

0 comments on commit e6066dd

Please sign in to comment.