Text Control Filter

The text control filter is a method to filter the controls based on the control text. The agent's plan on the current step usually contains some keywords or phrases. This method filters the controls based on the matching between the control text and the keywords or phrases in the agent's plan.

Configuration

To activate the text control filtering, you need to add TEXT to the CONTROL_FILTER list in the config_dev.yaml file. Below is the detailed text control filter configuration in the config_dev.yaml file:

  • CONTROL_FILTER: A list of filtering methods that you want to apply to the controls. To activate the text control filtering, add TEXT to the list.
  • CONTROL_FILTER_TOP_K_PLAN: The number of agent's plan keywords or phrases to use for filtering the controls.

Reference

A class that provides methods for filtering control items based on plans.

control_filter(control_dicts, plans) staticmethod

Filters control items based on keywords.

Parameters:
  • control_dicts (Dict) –

    The dictionary of control items to be filtered.

  • plans (List[str]) –

    The list of plans to be used for filtering.

Returns:
  • Dict

    The filtered control items.

Source code in automator/ui_control/control_filter.py
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
@staticmethod
def control_filter(control_dicts: Dict, plans: List[str]) -> Dict:
    """
    Filters control items based on keywords.
    :param control_dicts: The dictionary of control items to be filtered.
    :param plans: The list of plans to be used for filtering.
    :return: The filtered control items.
    """
    filtered_control_dict = {}

    keywords = BasicControlFilter.plans_to_keywords(plans)
    for label, control_item in control_dicts.items():
        control_text = control_item.element_info.name.lower()
        if any(
            keyword in control_text or control_text in keyword
            for keyword in keywords
        ):
            filtered_control_dict[label] = control_item
    return filtered_control_dict