From c777e3d8910e350c02ffd122d070452b24604fe8 Mon Sep 17 00:00:00 2001 From: LawyZheng Date: Wed, 20 Nov 2024 10:32:24 +0800 Subject: [PATCH] limit auto completion trigger (#1223) --- skyvern/webeye/actions/handler.py | 53 ++++++++++++++++--------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/skyvern/webeye/actions/handler.py b/skyvern/webeye/actions/handler.py index 02138fdb..800c28f1 100644 --- a/skyvern/webeye/actions/handler.py +++ b/skyvern/webeye/actions/handler.py @@ -551,34 +551,35 @@ async def handle_input_text_action( if len(text) == 0: return [ActionSuccess()] - # parse the input context to help executing input action - prompt = prompt_engine.load_prompt( - "parse-input-or-select-context", - element_id=action.element_id, - action_reasoning=action.reasoning, - elements=dom.scraped_page.build_element_tree(ElementTreeFormat.HTML), - ) + if not await skyvern_element.is_raw_input(): + # parse the input context to help executing input action + prompt = prompt_engine.load_prompt( + "parse-input-or-select-context", + element_id=action.element_id, + action_reasoning=action.reasoning, + elements=dom.scraped_page.build_element_tree(ElementTreeFormat.HTML), + ) - json_response = await app.SECONDARY_LLM_API_HANDLER(prompt=prompt, step=step) - input_or_select_context = InputOrSelectContext.model_validate(json_response) - LOG.info( - "Parsed input/select context", - context=input_or_select_context, - task_id=task.task_id, - step_id=step.step_id, - ) + json_response = await app.SECONDARY_LLM_API_HANDLER(prompt=prompt, step=step) + input_or_select_context = InputOrSelectContext.model_validate(json_response) + LOG.info( + "Parsed input/select context", + context=input_or_select_context, + task_id=task.task_id, + step_id=step.step_id, + ) - if await skyvern_element.is_auto_completion_input() or input_or_select_context.is_location_input: - if result := await input_or_auto_complete_input( - input_or_select_context=input_or_select_context, - page=page, - dom=dom, - text=text, - skyvern_element=skyvern_element, - step=step, - task=task, - ): - return [result] + if await skyvern_element.is_auto_completion_input() or input_or_select_context.is_location_input: + if result := await input_or_auto_complete_input( + input_or_select_context=input_or_select_context, + page=page, + dom=dom, + text=text, + skyvern_element=skyvern_element, + step=step, + task=task, + ): + return [result] await incremental_scraped.start_listen_dom_increment()