@@ -285,9 +285,9 @@ def _action_selection_prompt(
285285 The text prompt for action selection that will be sent to gpt4v.
286286 """
287287 if history :
288- history = '\n ' .join (history )
288+ history = '\n ' .join (history ) # pyrefly: ignore[bad-assignment]
289289 else :
290- history = 'You just started, no action has been performed yet.'
290+ history = 'You just started, no action has been performed yet.' # pyrefly: ignore[bad-assignment]
291291
292292 extra_guidelines = ''
293293 if additional_guidelines :
@@ -392,7 +392,7 @@ def step(self, goal: str) -> base_agent.AgentInteractionResult:
392392 before_ui_elements_list = _generate_ui_elements_description_list (
393393 before_ui_elements , logical_screen_size
394394 )
395- step_data ['raw_screenshot' ] = state .pixels .copy ()
395+ step_data ['raw_screenshot' ] = state .pixels .copy () # pyrefly: ignore[bad-assignment]
396396 before_screenshot = state .pixels .copy ()
397397 for index , ui_element in enumerate (before_ui_elements ):
398398 if m3a_utils .validate_ui_element (ui_element , logical_screen_size ):
@@ -404,7 +404,7 @@ def step(self, goal: str) -> base_agent.AgentInteractionResult:
404404 physical_frame_boundary ,
405405 orientation ,
406406 )
407- step_data ['before_screenshot_with_som' ] = before_screenshot .copy ()
407+ step_data ['before_screenshot_with_som' ] = before_screenshot .copy () # pyrefly: ignore[bad-assignment]
408408
409409 action_prompt = _action_selection_prompt (
410410 goal ,
@@ -415,10 +415,10 @@ def step(self, goal: str) -> base_agent.AgentInteractionResult:
415415 before_ui_elements_list ,
416416 self .additional_guidelines ,
417417 )
418- step_data ['action_prompt' ] = action_prompt
418+ step_data ['action_prompt' ] = action_prompt # pyrefly: ignore[bad-assignment]
419419 action_output , is_safe , raw_response = self .llm .predict_mm (
420420 action_prompt ,
421- [
421+ [ # pyrefly: ignore[bad-argument-type]
422422 step_data ['raw_screenshot' ],
423423 before_screenshot ,
424424 ],
@@ -431,7 +431,7 @@ def step(self, goal: str) -> base_agent.AgentInteractionResult:
431431
432432 if not raw_response :
433433 raise RuntimeError ('Error calling LLM in action selection phase.' )
434- step_data ['action_output' ] = action_output
434+ step_data ['action_output' ] = action_output # pyrefly: ignore[bad-assignment]
435435 step_data ['action_raw_response' ] = raw_response
436436
437437 reason , action = m3a_utils .parse_reason_action_output (action_output )
@@ -441,6 +441,7 @@ def step(self, goal: str) -> base_agent.AgentInteractionResult:
441441 if (not reason ) or (not action ):
442442 logging .info ('Action prompt output is not in the correct format.' )
443443 step_data ['summary' ] = (
444+ # pyrefly: ignore[bad-assignment]
444445 'Output for action selection is not in the correct format, so no'
445446 ' action is performed.'
446447 )
@@ -453,17 +454,18 @@ def step(self, goal: str) -> base_agent.AgentInteractionResult:
453454
454455 logging .info ('Action: %s' , action )
455456 logging .info ('Reason: %s' , reason )
456- step_data ['action_reason' ] = reason
457+ step_data ['action_reason' ] = reason # pyrefly: ignore[bad-assignment]
457458
458459 try :
459460 converted_action = json_action .JSONAction (
460- ** agent_utils .extract_json (action ),
461+ ** agent_utils .extract_json (action ), # pyrefly: ignore[bad-unpacking]
461462 )
462- step_data ['action_output_json' ] = converted_action
463+ step_data ['action_output_json' ] = converted_action # pyrefly: ignore[bad-assignment]
463464 except Exception as e : # pylint: disable=broad-exception-caught
464465 logging .info ('Failed to convert the output to a valid action.' )
465466 logging .info (str (e ))
466467 step_data ['summary' ] = (
468+ # pyrefly: ignore[bad-assignment]
467469 'Can not parse the output to a valid action. Please make sure to pick'
468470 ' the action from the list with required parameters (if any) in the'
469471 ' correct JSON format!'
@@ -482,14 +484,15 @@ def step(self, goal: str) -> base_agent.AgentInteractionResult:
482484 in ['click' , 'long_press' , 'input_text' , 'scroll' ]
483485 and action_index is not None
484486 ):
485- if action_index >= num_ui_elements :
487+ if action_index >= num_ui_elements : # pyrefly: ignore[unsupported-operation]
486488 logging .info (
487489 'Index out of range, prediction index is %s, but the'
488490 ' UI element list only has %d elements.' ,
489491 action_index ,
490492 num_ui_elements ,
491493 )
492494 step_data ['summary' ] = (
495+ # pyrefly: ignore[bad-assignment]
493496 'The parameter index is out of range. Remember the index must be in'
494497 ' the UI element list!'
495498 )
@@ -498,8 +501,8 @@ def step(self, goal: str) -> base_agent.AgentInteractionResult:
498501
499502 # Add mark to the target element.
500503 m3a_utils .add_ui_element_mark (
501- step_data ['raw_screenshot' ],
502- before_ui_elements [action_index ],
504+ step_data ['raw_screenshot' ], # pyrefly: ignore[bad-argument-type]
505+ before_ui_elements [action_index ], # pyrefly: ignore[bad-index]
503506 action_index ,
504507 logical_screen_size ,
505508 physical_frame_boundary ,
@@ -509,7 +512,7 @@ def step(self, goal: str) -> base_agent.AgentInteractionResult:
509512 if converted_action .action_type == 'status' :
510513 if converted_action .goal_status == 'infeasible' :
511514 logging .info ('Agent stopped since it thinks mission impossible.' )
512- step_data ['summary' ] = 'Agent thinks the request has been completed.'
515+ step_data ['summary' ] = 'Agent thinks the request has been completed.' # pyrefly: ignore[bad-assignment]
513516 self .history .append (step_data )
514517 return base_agent .AgentInteractionResult (
515518 True ,
@@ -525,6 +528,7 @@ def step(self, goal: str) -> base_agent.AgentInteractionResult:
525528 logging .info ('Failed to execute action.' )
526529 logging .info (str (e ))
527530 step_data ['summary' ] = (
531+ # pyrefly: ignore[bad-assignment]
528532 'Can not execute the action, make sure to select the action with'
529533 ' the required parameters (if any) in the correct JSON format!'
530534 )
@@ -556,10 +560,10 @@ def step(self, goal: str) -> base_agent.AgentInteractionResult:
556560 )
557561
558562 m3a_utils .add_screenshot_label (
559- step_data ['before_screenshot_with_som' ], 'before'
563+ step_data ['before_screenshot_with_som' ], 'before' # pyrefly: ignore[bad-argument-type]
560564 )
561565 m3a_utils .add_screenshot_label (after_screenshot , 'after' )
562- step_data ['after_screenshot_with_som' ] = after_screenshot .copy ()
566+ step_data ['after_screenshot_with_som' ] = after_screenshot .copy () # pyrefly: ignore[bad-assignment]
563567
564568 summary_prompt = _summarize_prompt (
565569 action ,
@@ -587,7 +591,7 @@ def step(self, goal: str) -> base_agent.AgentInteractionResult:
587591 summary ,
588592 )
589593 step_data ['summary' ] = (
590- 'Some error occurred calling LLM during summarization phase: %s'
594+ 'Some error occurred calling LLM during summarization phase: %s' # pyrefly: ignore[bad-assignment]
591595 % summary
592596 )
593597 self .history .append (step_data )
@@ -596,8 +600,8 @@ def step(self, goal: str) -> base_agent.AgentInteractionResult:
596600 step_data ,
597601 )
598602
599- step_data ['summary_prompt' ] = summary_prompt
600- step_data ['summary' ] = f'Action selected: { action } . { summary } '
603+ step_data ['summary_prompt' ] = summary_prompt # pyrefly: ignore[bad-assignment]
604+ step_data ['summary' ] = f'Action selected: { action } . { summary } ' # pyrefly: ignore[bad-assignment]
601605 logging .info ('Summary: %s' , summary )
602606 step_data ['summary_raw_response' ] = raw_response
603607
0 commit comments