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

Code before:
    about the user and the context of the interaction: ###
    {context_values}
    ###
    """

        prompt += f"""
    - Predicate List: ###
    {predicates}
    ###

2. **Process**:
   a. Examine the provided interaction events to discern 
   the latest state of interaction between the user and the assistant.
   b. Determine the applicability of each predicate based on the most recent interaction state.
     Note: There are exactly {len(guidelines)} predicates.
   c. Assign a relevance score to each predicate, from 1 to 10, where 10 denotes high relevance.

3. **Output**:
   - Create a JSON object summarizing relevance for each predicate, formatted as follows:

    ```json
    {{
        "checks": [
            {{
                "predicate_number": "1",
                "rationale": "<EXPLANATION WHY THE PREDICATE IS 
                RELEVANT OR IRRELEVANT FOR THE CURRENT STATE OF THE INTERACTION>",
                "applies_score": <RELEVANCE SCORE>,
            }},
            ...
            {{
                "predicate_number": "N",
                "rationale": "<EXPLANATION WHY THE PREDICATE IS 
                RELEVANT OR IRRELEVANT FOR THE CURRENT STATE OF THE INTERACTION>",
                "applies_score": <RELEVANCE SCORE>
            }}
        ]
    }}
    ```

### Examples of Predicate Evaluations:

    #### Example #1:
    - Interaction Events: ###
    [{{"id": "MZC1H9iyYe", "type": "<message>", "source": "user", 
    "data": {{"message": "Can I purchase a subscription to your software?"}},
    {{"id": "F2oFNx_Ld8", "type": "<message>", "source": "assistant", 
    "data": {{"message": "Absolutely, I can assist you with that right now."}},
    {{"id": "dfI1jYAjqe", "type": "<message>", "source": "user",
    "data": {{"message": "Please proceed with the subscription for the Pro plan."}},
    {{"id": "2ZWfAC4xLf", "type": "<message>", "source": "assistant",

Review comment (suggestion):
I think the line break in the middle of the string here, in the example for the LLM, can easily mislead it and generate faulty JSON.
Remove it. If the line becomes too line as a result, add a `# noqa` comment after it.

Code after:
    {context_values}
    ###
    """

        prompt += f"""
    - Predicate List: ###
    {predicates}
    ###

2. **Process**:
   a. Examine the provided interaction events to discern 
   the latest state of interaction between the user and the assistant.
   b. Determine the applicability of each predicate based on the most recent interaction state.
      Note: There are exactly {len(guidelines)} predicates.
   c. Assign a relevance score to each predicate, from 1 to 10, where 10 denotes high relevance.

3. **Output**:
   - Create a JSON object summarizing relevance for each predicate, formatted as follows:

    ```json
    {{
        "checks": [
            {{
                "predicate_number": "1",
                "rationale": "<EXPLANATION WHY THE PREDICATE IS RELEVANT OR IRRELEVANT FOR THE CURRENT STATE OF THE INTERACTION>",
                "applies_score": <RELEVANCE SCORE>,
            }},
            ...
            {{
                "predicate_number": "N",
                "rationale": "<EXPLANATION WHY THE PREDICATE IS RELEVANT OR IRRELEVANT FOR THE CURRENT STATE OF THE INTERACTION>",
                "applies_score": <RELEVANCE SCORE>
            }}
        ]
    }}
    ```

### Examples of Predicate Evaluations:

    #### Example #1:
    - Interaction Events: ###
    [{{"id": "MZC1H9iyYe", "type": "<message>", "source": "user", 
    "data": {{"message": "Can I purchase a subscription to your software?"}},
    {{"id": "F2oFNx_Ld8", "type": "<message>", "source": "assistant", 
    "data": {{"message": "Absolutely, I can assist you with that right now."}},
    {{"id": "dfI1jYAjqe", "type": "<message>", "source": "user",
    "data": {{"message": "Please proceed with the subscription for the Pro plan."}},
    {{"id": "2ZWfAC4xLf", "type": "<message>", "source": "assistant",
    "data": {{"message": "Your subscription has been successfully activated. 
    Is there anything else I can help you with?"}},
    {{"id": "78oTChjBfM", "type": "<message>", "source": "user",