Repository: emcie-co/parlant
File: server/src/emcie/server/engines/alpha/coherence_checker.py (Python)

Code before:
                proposed_guideline_id=json_contradiction["guideline_under_test_id"],
                severity=json_contradiction["severity_level"],
                rationale=json_contradiction["rationale"],
                creation_utc=datetime.now(timezone.utc),
            )
            for json_contradiction in json_content
        ]

        return contradictions


class HierarchicalContradictionEvaluator(ContradictionEvaluatorBase):
    def __init__(self) -> None:
        super().__init__(ContradictionType.HIERARCHICAL)

    def _format_contradiction_type_definition(self) -> str:
        return """
Hierarchical Coherence Contradiction arises when there are multiple layers of guidelines, with one being more specific or detailed than the other.
This type of Contradiction occurs when the application of a general guideline is contradicted by a more specific guideline under certain conditions, leading to inconsistencies in decision-making.
"""  # noqa

    def _format_contradiction_type_examples(self) -> str:
        return f"""
#### Example #1:
- **Compared Guideline**: {{"id": 3, "guideline": "When a customer orders any item, Then prioritize shipping based on customer loyalty level."}}
- **Guideline**: {{"id": 4, "guideline": "When a customer orders a high-demand item, Then ship immediately, regardless of loyalty level."}}
- **Expected Result**:
     ```json
     {{
         "{self.contradiction_response_outcome_key}": [
             {{
                 "compared_guideline_id": "3",
                 "guideline_under_test_id": "4",
                 "severity_level": 9,
                 "rationale": "Shipping high-demand items immediately contradicts the policy of prioritizing shipments based on loyalty."
             }}
         ]
     }}
     ```

#### Example #2:
- **Compared Guideline**: {{"id": 1, "guideline": "When an employee qualifies for any reward, Then distribute rewards based on standard performance metrics."}}
- **Guideline**: {{"id": 2, "guideline": "When an employee excels in a critical project, Then offer additional rewards beyond standard metrics."}}
- **Expected Result**:
     ```json
     {{
        "{self.contradiction_response_outcome_key}": [
             {{
                 "compared_guideline_id": "1",
                 "guideline_under_test_id": "2",
                 "severity_level": 8,

Review comment (suggestion):
Also here `**Guideline**` should be Guideline Under Test (and in the following examples (etc.) in the prompt

Code after:
                proposed_guideline_id=json_contradiction["guideline_under_test_id"],
                severity=json_contradiction["severity_level"],
                rationale=json_contradiction["rationale"],
                creation_utc=datetime.now(timezone.utc),
            )
            for json_contradiction in json_content
        ]

        return contradictions


class HierarchicalContradictionEvaluator(ContradictionEvaluatorBase):
    def __init__(self) -> None:
        super().__init__(ContradictionType.HIERARCHICAL)

    def _format_contradiction_type_definition(self) -> str:
        return """
Hierarchical Coherence Contradiction arises when there are multiple layers of guidelines, with one being more specific or detailed than the other.
This type of Contradiction occurs when the application of a general guideline is contradicted by a more specific guideline under certain conditions, leading to inconsistencies in decision-making.
"""  # noqa

    def _format_contradiction_type_examples(self) -> str:
        return f"""
#### Example #1:
- **Compared Guideline**: {{"id": 3, "guideline": "When a customer orders any item, Then prioritize shipping based on customer loyalty level."}}
- **Guideline Under Test**: {{"id": 4, "guideline": "When a customer orders a high-demand item, Then ship immediately, regardless of loyalty level."}}
- **Expected Result**:
     ```json
     {{
         "{self.contradiction_response_outcome_key}": [
             {{
                 "compared_guideline_id": "3",
                 "guideline_under_test_id": "4",
                 "severity_level": 9,
                 "rationale": "Shipping high-demand items immediately contradicts the policy of prioritizing shipments based on loyalty."
             }}
         ]
     }}
     ```

#### Example #2:
- **Compared Guideline**: {{"id": 1, "guideline": "When an employee qualifies for any reward, Then distribute rewards based on standard performance metrics."}}
- **Guideline Under Test**: {{"id": 2, "guideline": "When an employee excels in a critical project, Then offer additional rewards beyond standard metrics."}}
- **Expected Result**:
     ```json
     {{
        "{self.contradiction_response_outcome_key}": [
             {{
                 "compared_guideline_id": "1",
                 "guideline_under_test_id": "2",
                 "severity_level": 8,