INNER CODE UNIT · Python
generate_pairs_from_rule
valqore/valqore · blog/01-fine-tuning/data_generation_example.py:8
def generate_pairs_from_rule(rule: dict) -> list[dict]:
"""Generate multiple training pairs from a single rule definition."""
pairs = []
# Type A: Rule explanation
pairs.append({
"messages": [
{"role": "system", "content": "You are a cloud infrastructure governance assistant."},
{"role": "user", "content": f"Explain rule {rule['id']} and its severity."},
{"role": "assistant", "content": f"{rule['id']}: {rule['name']} (Severity: {rule['severity']}). {rule['description']} Remediation: {rule['remediation']}"},
]
})
# Type B: Failure scenario
pairs.append({
"messages": [
{"role": "system", "content": "You are a cloud infrastructure governance assistant."},
{"role": "user", "content": f"My deployment is failing rule {rule['id']}. Why?"},