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

Code before:
        context_values = context_variables_to_json(context_variables)
        predicates = "\n".join(f"{i}) {g.predicate}" for i, g in enumerate(guidelines, start=1))
        prompt = """
### Definition of Predicate Relevance Evaluation:
This process involves assessing the relevance of predefined predicates 
to the last known state of an interaction between an AI assistant and a user.

**Objective**: Determine the applicability of each predicate to the latest 
state based on a stream of events.

**Task Description**:
1. **Input**:
"""

        if interaction_history:
            prompt += f"""\
    The following is a list of events describing a back-and-forth
    interaction between you, an AI assistant, and a user: ###
    {json_events}
    ###
    """
        else:
            prompt += """\
    You, an AI assistant, 
    are currently engaged in the initial phase of an online session with a user.
    The interaction has just commenced, 
    and the user hasn't said anything yet nor chosen to engage with you.
    """

        if context_variables:
            prompt += f"""
    The following is additional information available 
    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:

Review comment (suggestion):
Same comment here on the problem with "Interaction has commenced." Copy from your latest version of the guideline filter changes.
Later, like I said before, we will need to merge all of these nuances into a unified PromptBuilder or something.

Code after:
        context_values = context_variables_to_json(context_variables)
        predicates = "\n".join(f"{i}) {g.predicate}" for i, g in enumerate(guidelines, start=1))
        prompt = """
### Definition of Predicate Relevance Evaluation:
This process involves assessing the relevance of predefined predicates 
to the last known state of an interaction between an AI assistant and a user.

**Objective**: Determine the applicability of each predicate to the latest 
state based on a stream of events.

**Task Description**:
1. **Input**:
"""

        if interaction_history:
            prompt += f"""\
    The following is a list of events describing a back-and-forth
    interaction between you, an AI assistant, and a user: ###
    {json_events}
    ###
    """
        else:
            prompt += """\
    You, an AI assistant, are now present in an online interaction session with a user.
    The session has just started, 
    and the user hasn't said anything yet nor chosen to engage with you.
    """

        if context_variables:
            prompt += f"""
    The following is additional information available 
    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: