Skip to content

Commit 213e27e

Browse files
update templating
1 parent efc0f5e commit 213e27e

4 files changed

Lines changed: 55 additions & 38 deletions

File tree

cli/decompose/prompt_modules/validation_code_generator/_prompt/system_template.jinja2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ When writing your answer, follow these additional instructions below to be succe
4747
3. Use appropriate Python standard library modules (re, json, etc.) as needed
4848
4. Ensure the function is simple and doesn't have unnecessary complexity
4949
5. The validation logic should directly correspond to the provided constraint/requirement
50+
6. If you use any standard library modules (e.g. `re`, `json`), import them inside the function body before using them
5051

5152
## Common Validation Patterns
5253

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,58 @@
1-
=== 10:06:56-INFO ======
1+
=== 10:50:56-INFO ======
22
Starting Mellea session: backend=ollama, model=granite4:micro, context=SimpleContext
3-
=== 10:07:00-INFO ======
3+
=== 10:51:00-INFO ======
44
FAILED. Valid: 3/4. Failed:
55
- The post should include an introduction paragraph
6-
=== 10:07:03-INFO ======
6+
=== 10:51:04-INFO ======
77
FAILED. Valid: 3/4. Failed:
88
- The post should include an introduction paragraph
9-
=== 10:07:03-INFO ======
9+
=== 10:51:04-INFO ======
1010
Invoking select_from_failure after 2 failed attempts.
11-
=== 10:07:05-INFO ======
11+
=== 10:51:06-INFO ======
1212
SUCCESS
13-
=== 10:07:11-INFO ======
13+
=== 10:51:11-INFO ======
1414
SUCCESS
15-
=== 10:07:18-INFO ======
16-
FAILED. Valid: 3/4. Failed:
15+
=== 10:51:19-INFO ======
16+
FAILED. Valid: 2/4. Failed:
17+
- The blog post must have a catchy title
1718
- The post should include an introduction paragraph
18-
=== 10:07:25-INFO ======
19+
=== 10:51:26-INFO ======
1920
FAILED. Valid: 3/4. Failed:
2021
- The post should include an introduction paragraph
21-
=== 10:07:25-INFO ======
22+
=== 10:51:26-INFO ======
2223
Invoking select_from_failure after 2 failed attempts.
23-
=== 10:07:33-INFO ======
24-
FAILED. Valid: 3/4. Failed:
25-
- The post should include an introduction paragraph
26-
=== 10:07:41-INFO ======
27-
FAILED. Valid: 3/4. Failed:
28-
- The post should include an introduction paragraph
29-
=== 10:07:41-INFO ======
24+
=== 10:51:31-INFO ======
25+
FAILED. Valid: 2/4. Failed:
26+
- The post should include an introduction paragraph
27+
- The blog post must have a catchy title
28+
=== 10:51:34-INFO ======
29+
FAILED. Valid: 2/4. Failed:
30+
- The post should include an introduction paragraph
31+
- The blog post must have a catchy title
32+
=== 10:51:34-INFO ======
3033
Invoking select_from_failure after 2 failed attempts.
31-
=== 10:07:51-INFO ======
34+
=== 10:51:41-INFO ======
3235
FAILED. Valid: 3/4. Failed:
3336
- The post should include an introduction paragraph
34-
=== 10:08:01-INFO ======
37+
=== 10:51:49-INFO ======
3538
FAILED. Valid: 3/4. Failed:
3639
- The post should include an introduction paragraph
37-
=== 10:08:01-INFO ======
40+
=== 10:51:49-INFO ======
3841
Invoking select_from_failure after 2 failed attempts.
39-
**Morning Exercise Magic: Unleashing the Power of Your Day**
42+
**Title**: Revitalize Your Day: Unveiling the Top 3 Benefits of Morning Exercise
43+
44+
**Introduction**
45+
46+
Starting your day with a burst of energy and positivity can be achieved through various means, one of which is incorporating morning exercise into your daily routine. The benefits of this simple yet powerful practice are manifold, offering improvements in physical health, mental well-being, and overall productivity.
47+
48+
**Main Benefits of Morning Exercise**
4049

41-
Waking up before the sun does not mean you're depriving yourself of daylight; it means embracing a lifestyle full of vitality and positivity. Engaging in morning exercises offers more than just physical fitness—it transforms your entire day, enhancing mood, energy levels, and sleep quality. Let's explore how starting your day with exercise can significantly impact your well-being.
50+
1. **Boosted Metabolism**: One of the foremost advantages of engaging in morning workouts is the immediate increase in metabolic rate. This kickstarts your body's ability to burn calories more efficiently throughout the day, contributing to better weight management.
4251

43-
Starting your day with a burst of activity sets the stage for an uplifting mood throughout the rest of the day. Physical movement stimulates endorphins—the body's natural feel-good chemicals—helping to alleviate stress and elevate your spirits. A study published in *Psychological Science* highlights that those who exercise first thing in the morning report a noticeable reduction in symptoms related to depression and anxiety compared to late-day exercisers (Smith et al., 2020). For instance, Sarah, an accountant, often feels drained by mid-morning due to work-related stress. Since adopting a simple yoga routine at sunrise, she notices her mood improves significantly during her workday, allowing her to tackle tasks with calm and focus.
52+
2. **Enhanced Mood and Cognitive Functioning**: Physical activity stimulates the production of endorphins, often known as "feel-good" hormones, leading to an uplift in mood. Additionally, morning exercise has been linked to improved cognitive function, including better focus, memory retention, and problem-solving skills.
4453

45-
Morning exercise is like giving your body the perfect energy boost it needs for the day ahead. This increase in vigor comes from better circulation, oxygen flow, and metabolic activity triggered by physical activity. Research from the *Journal of Strength and Conditioning* found that individuals who work out in the morning report higher levels of energy throughout their daily activities compared to those who prefer exercising later (Johnson & Lee, 2021). Mark, a teacher, frequently battles fatigue through long shifts. Since adding a brisk jog before school starts, he's noticed not only increased energy during lessons but also an easier time staying alert and engaged throughout the day.
54+
3. **Improved Quality of Sleep**: Regular physical activity can significantly enhance sleep quality. By expending energy early in the day, individuals are more likely to fall asleep faster and enjoy deeper stages of rest during the night, thus waking up feeling refreshed and ready to tackle daily challenges.
4655

47-
Engaging in morning exercise can significantly enhance the quality of your sleep at night. This improvement is largely due to how exercising in the morning helps regulate your circadian rhythms, promoting deeper, more restorative sleep. A study from *Sleep Medicine* demonstrated that those who exercise in the morning experience longer periods of deep sleep and fewer interruptions throughout the night compared to late-day exercisers (Brown & Green, 2022). Lisa, a mother of two, has observed her children's sleep patterns improve after she began an early morning swimming routine. She wakes up feeling refreshed and ready for each new day without feeling sluggish.
56+
**Conclusion**
4857

49-
The benefits of morning exercise extend far beyond just physical health—they set the foundation for a more positive, energetic, and well-rested life. Whether you're looking to uplift your mood, stay energized throughout your tasks, or simply improve your rest, incorporating morning workouts into your routine can make all the difference. Take that first step today and experience the transformation for yourself!
58+
Embracing morning exercise is not merely about burning calories or building muscle; it's a holistic approach that revitalizes your body and mind. By understanding these benefits and how they manifest in our daily lives, we are empowered to make informed decisions that align with our health goals. Whether you're aiming to reduce stress, increase productivity, or simply enjoy life more fully, starting your day with exercise can set the foundation for a healthier, happier lifestyle. So why wait? Get moving first thing in the morning and watch as it transforms every aspect of your life.

docs/examples/m_decompose/python/python_decompose_result.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
{
1919
"constraint": "The post should include an introduction paragraph",
2020
"val_strategy": "code",
21-
"val_fn": "def validate_input(input: str) -> bool:\n \"\"\"\n Validates that the input contains an introduction paragraph.\n \n An introduction paragraph is defined as a block of text that appears at the beginning of a document and provides context or overview of the content to follow.\n \n Args:\n input (str): The input to validate\n \n Returns:\n bool: True if the input contains an introduction paragraph, False otherwise\n \"\"\"\n try:\n # Splitting the input into sentences for analysis\n sentences = re.split('[.!?]', input)\n \n # An introduction paragraph is typically the first sentence or a group of closely related sentences at the start\n return any(sentence.strip() and not sentence.lower().startswith('rephrased from') for sentence in sentences[:3])\n except Exception:\n return False",
21+
"val_fn": "import re\n\ndef validate_input(input: str) -> bool:\n \"\"\"\n Validates that the input contains an introduction paragraph.\n \n An introduction paragraph is defined as a block of text that starts with the first sentence and ends with a period, question mark, or exclamation point.\n \n Args:\n input (str): The input to validate\n \n Returns:\n bool: True if the input contains an introduction paragraph, False otherwise\n \"\"\"\n try:\n # Check if the input is not None or empty string\n if not input or input.strip() == \"\":\n return False\n \n # Split the input into sentences using regular expressions\n sentences = re.split('[.!?]', input)\n \n # The first sentence should be the introduction\n if len(sentences) > 1 and sentences[0].strip():\n return True\n else:\n return False\n except Exception:\n return False",
2222
"val_fn_name": "val_fn_2"
2323
},
2424
{
@@ -49,7 +49,7 @@
4949
"constraint": "The post should include an introduction paragraph",
5050
"val_strategy": "code",
5151
"val_fn_name": "val_fn_2",
52-
"val_fn": "def validate_input(input: str) -> bool:\n \"\"\"\n Validates that the input contains an introduction paragraph.\n \n An introduction paragraph is defined as a block of text that appears at the beginning of a document and provides context or overview of the content to follow.\n \n Args:\n input (str): The input to validate\n \n Returns:\n bool: True if the input contains an introduction paragraph, False otherwise\n \"\"\"\n try:\n # Splitting the input into sentences for analysis\n sentences = re.split('[.!?]', input)\n \n # An introduction paragraph is typically the first sentence or a group of closely related sentences at the start\n return any(sentence.strip() and not sentence.lower().startswith('rephrased from') for sentence in sentences[:3])\n except Exception:\n return False"
52+
"val_fn": "import re\n\ndef validate_input(input: str) -> bool:\n \"\"\"\n Validates that the input contains an introduction paragraph.\n \n An introduction paragraph is defined as a block of text that starts with the first sentence and ends with a period, question mark, or exclamation point.\n \n Args:\n input (str): The input to validate\n \n Returns:\n bool: True if the input contains an introduction paragraph, False otherwise\n \"\"\"\n try:\n # Check if the input is not None or empty string\n if not input or input.strip() == \"\":\n return False\n \n # Split the input into sentences using regular expressions\n sentences = re.split('[.!?]', input)\n \n # The first sentence should be the introduction\n if len(sentences) > 1 and sentences[0].strip():\n return True\n else:\n return False\n except Exception:\n return False"
5353
},
5454
{
5555
"constraint": "Three main benefits of morning exercise with explanations are required",
@@ -101,7 +101,7 @@
101101
"constraint": "The post should include an introduction paragraph",
102102
"val_strategy": "code",
103103
"val_fn_name": "val_fn_2",
104-
"val_fn": "def validate_input(input: str) -> bool:\n \"\"\"\n Validates that the input contains an introduction paragraph.\n \n An introduction paragraph is defined as a block of text that appears at the beginning of a document and provides context or overview of the content to follow.\n \n Args:\n input (str): The input to validate\n \n Returns:\n bool: True if the input contains an introduction paragraph, False otherwise\n \"\"\"\n try:\n # Splitting the input into sentences for analysis\n sentences = re.split('[.!?]', input)\n \n # An introduction paragraph is typically the first sentence or a group of closely related sentences at the start\n return any(sentence.strip() and not sentence.lower().startswith('rephrased from') for sentence in sentences[:3])\n except Exception:\n return False"
104+
"val_fn": "import re\n\ndef validate_input(input: str) -> bool:\n \"\"\"\n Validates that the input contains an introduction paragraph.\n \n An introduction paragraph is defined as a block of text that starts with the first sentence and ends with a period, question mark, or exclamation point.\n \n Args:\n input (str): The input to validate\n \n Returns:\n bool: True if the input contains an introduction paragraph, False otherwise\n \"\"\"\n try:\n # Check if the input is not None or empty string\n if not input or input.strip() == \"\":\n return False\n \n # Split the input into sentences using regular expressions\n sentences = re.split('[.!?]', input)\n \n # The first sentence should be the introduction\n if len(sentences) > 1 and sentences[0].strip():\n return True\n else:\n return False\n except Exception:\n return False"
105105
},
106106
{
107107
"constraint": "Three main benefits of morning exercise with explanations are required",
@@ -137,7 +137,7 @@
137137
"constraint": "The post should include an introduction paragraph",
138138
"val_strategy": "code",
139139
"val_fn_name": "val_fn_2",
140-
"val_fn": "def validate_input(input: str) -> bool:\n \"\"\"\n Validates that the input contains an introduction paragraph.\n \n An introduction paragraph is defined as a block of text that appears at the beginning of a document and provides context or overview of the content to follow.\n \n Args:\n input (str): The input to validate\n \n Returns:\n bool: True if the input contains an introduction paragraph, False otherwise\n \"\"\"\n try:\n # Splitting the input into sentences for analysis\n sentences = re.split('[.!?]', input)\n \n # An introduction paragraph is typically the first sentence or a group of closely related sentences at the start\n return any(sentence.strip() and not sentence.lower().startswith('rephrased from') for sentence in sentences[:3])\n except Exception:\n return False"
140+
"val_fn": "import re\n\ndef validate_input(input: str) -> bool:\n \"\"\"\n Validates that the input contains an introduction paragraph.\n \n An introduction paragraph is defined as a block of text that starts with the first sentence and ends with a period, question mark, or exclamation point.\n \n Args:\n input (str): The input to validate\n \n Returns:\n bool: True if the input contains an introduction paragraph, False otherwise\n \"\"\"\n try:\n # Check if the input is not None or empty string\n if not input or input.strip() == \"\":\n return False\n \n # Split the input into sentences using regular expressions\n sentences = re.split('[.!?]', input)\n \n # The first sentence should be the introduction\n if len(sentences) > 1 and sentences[0].strip():\n return True\n else:\n return False\n except Exception:\n return False"
141141
},
142142
{
143143
"constraint": "Three main benefits of morning exercise with explanations are required",
@@ -174,7 +174,7 @@
174174
"constraint": "The post should include an introduction paragraph",
175175
"val_strategy": "code",
176176
"val_fn_name": "val_fn_2",
177-
"val_fn": "def validate_input(input: str) -> bool:\n \"\"\"\n Validates that the input contains an introduction paragraph.\n \n An introduction paragraph is defined as a block of text that appears at the beginning of a document and provides context or overview of the content to follow.\n \n Args:\n input (str): The input to validate\n \n Returns:\n bool: True if the input contains an introduction paragraph, False otherwise\n \"\"\"\n try:\n # Splitting the input into sentences for analysis\n sentences = re.split('[.!?]', input)\n \n # An introduction paragraph is typically the first sentence or a group of closely related sentences at the start\n return any(sentence.strip() and not sentence.lower().startswith('rephrased from') for sentence in sentences[:3])\n except Exception:\n return False"
177+
"val_fn": "import re\n\ndef validate_input(input: str) -> bool:\n \"\"\"\n Validates that the input contains an introduction paragraph.\n \n An introduction paragraph is defined as a block of text that starts with the first sentence and ends with a period, question mark, or exclamation point.\n \n Args:\n input (str): The input to validate\n \n Returns:\n bool: True if the input contains an introduction paragraph, False otherwise\n \"\"\"\n try:\n # Check if the input is not None or empty string\n if not input or input.strip() == \"\":\n return False\n \n # Split the input into sentences using regular expressions\n sentences = re.split('[.!?]', input)\n \n # The first sentence should be the introduction\n if len(sentences) > 1 and sentences[0].strip():\n return True\n else:\n return False\n except Exception:\n return False"
178178
},
179179
{
180180
"constraint": "Three main benefits of morning exercise with explanations are required",
Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
import re
2+
3+
14
def validate_input(input: str) -> bool:
25
"""
36
Validates that the input contains an introduction paragraph.
47
5-
An introduction paragraph is defined as a block of text that appears at the beginning of a document and provides context or overview of the content to follow.
8+
An introduction paragraph is defined as a block of text that starts with the first sentence and ends with a period, question mark, or exclamation point.
69
710
Args:
811
input (str): The input to validate
@@ -11,13 +14,17 @@ def validate_input(input: str) -> bool:
1114
bool: True if the input contains an introduction paragraph, False otherwise
1215
"""
1316
try:
14-
# Splitting the input into sentences for analysis
17+
# Check if the input is not None or empty string
18+
if not input or input.strip() == "":
19+
return False
20+
21+
# Split the input into sentences using regular expressions
1522
sentences = re.split("[.!?]", input)
1623

17-
# An introduction paragraph is typically the first sentence or a group of closely related sentences at the start
18-
return any(
19-
sentence.strip() and not sentence.lower().startswith("rephrased from")
20-
for sentence in sentences[:3]
21-
)
24+
# The first sentence should be the introduction
25+
if len(sentences) > 1 and sentences[0].strip():
26+
return True
27+
else:
28+
return False
2229
except Exception:
2330
return False

0 commit comments

Comments
 (0)