Skip to content

Commit

Permalink
New argument (significant change): `select_turns_and_candidates_for_p…
Browse files Browse the repository at this point in the history
…rompts` now removes click, change, submit and textinput turns without a proper element
  • Loading branch information
xhluca committed Apr 18, 2024
1 parent 2c60c82 commit c42ff0e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions weblinx/processing/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ def select_turns_and_candidates_for_prompts(
demos,
candidates=None,
num_candidates=20,
remove_turns_without_elements=True,
):
"""
This will select the turns that will be used for building the prompts. It first filters
Expand All @@ -635,6 +636,9 @@ def select_turns_and_candidates_for_prompts(
num_candidates : int, optional
The number of candidates to select for each turn. Defaults to 20.
remove_turns_without_elements : bool, optional
Whether to remove turns that do not have elements. Defaults to True.
Returns
-------
list
Expand Down Expand Up @@ -663,6 +667,14 @@ def select_turns_and_candidates_for_prompts(
turn.type == "chat" and turn.get("speaker") != "navigator"
),
)
# Remove click and textinput turns where element is None
if remove_turns_without_elements:
turns = filter_turns(
turns,
lambda turn: not (
turn.intent in ("click", "change", "textinput", "submit") and turn.element is None
),
)

for i, turn in enumerate(turns):
if candidates is None:
Expand Down

0 comments on commit c42ff0e

Please sign in to comment.