@@ -590,73 +590,6 @@ def apply_cache_breakpoints(self, msg: Message, prepared_msg: dict) -> List[Mess
590590 return prepared_msg
591591
592592
593- def cua_response_to_text (action ):
594- """
595- Given a computer action (e.g., click, double_click, scroll, etc.),
596- convert it to a text description.
597- """
598- action_type = action .type
599-
600- try :
601- match action_type :
602-
603- case "click" :
604- x , y = action .x , action .y
605- button = action .button
606- print (f"Action: click at ({ x } , { y } ) with button '{ button } '" )
607- # Not handling things like middle click, etc.
608- if button != "left" and button != "right" :
609- button = "left"
610- return f"mouse_click({ x } , { y } , button='{ button } ')"
611-
612- case "scroll" :
613- x , y = action .x , action .y
614- scroll_x , scroll_y = action .scroll_x , action .scroll_y
615- print (
616- f"Action: scroll at ({ x } , { y } ) with offsets (scroll_x={ scroll_x } , scroll_y={ scroll_y } )"
617- )
618- return f"mouse_move({ x } , { y } )\n scroll({ scroll_x } , { scroll_y } )"
619-
620- case "keypress" :
621- keys = action .keys
622- for k in keys :
623- print (f"Action: keypress '{ k } '" )
624- # A simple mapping for common keys; expand as needed.
625- if k .lower () == "enter" :
626- return "keyboard_press('Enter')"
627- elif k .lower () == "space" :
628- return "keyboard_press(' ')"
629- else :
630- return f"keyboard_press('{ k } ')"
631-
632- case "type" :
633- text = action .text
634- print (f"Action: type text: { text } " )
635- return f"keyboard_type('{ text } ')"
636-
637- case "wait" :
638- print (f"Action: wait" )
639- return "noop()"
640-
641- case "screenshot" :
642- # Nothing to do as screenshot is taken at each turn
643- print (f"Action: screenshot" )
644-
645- # Handle other actions here
646-
647- case "drag" :
648- x1 , y1 = action .path [0 ].x , action .path [0 ].y
649- x2 , y2 = action .path [1 ].x , action .path [1 ].y
650- print (f"Action: drag from ({ x1 } , { y1 } ) to ({ x2 } , { y2 } )" )
651- return f"mouse_drag_and_drop({ x1 } , { y1 } , { x2 } , { y2 } )"
652-
653- case _:
654- print (f"Unrecognized action: { action } " )
655-
656- except Exception as e :
657- print (f"Error handling action { action } : { e } " )
658-
659-
660593# Factory classes to create the appropriate model based on the API endpoint.
661594@dataclass
662595class OpenAIResponseModelArgs (BaseModelArgs ):
0 commit comments