MCPcopy Create free account
hub / github.com/OpenBMB/AgentCPM-GUI / _parse_answer_

Method _parse_answer_

eval/utils/evaluator.py:245–300  ·  view source on GitHub ↗
(self, gt)

Source from the content-addressed store, hash-verified

243
244
245 def _parse_answer_(self, gt):
246 gt_cand_nodes=None
247 gt_action_text=None
248 gt_action_type=None
249 gt_action_yx=None
250 gt_action_direction=None
251 gt_action_button=None
252 gt_duration=None
253 if gt['result_action_type'] == self._aitz_action_type_.TYPE:
254 gt_action_type = "type"
255 gt_action_text = gt['result_action_text']
256 elif gt['result_action_type'] == self._aitz_action_type_.DUAL_POINT: # Might be swipe or click
257 normalized_start_yx = gt['result_touch_yx']
258 normalized_start_yx = json.loads(normalized_start_yx)
259 normalized_end_yx = gt['result_lift_yx']
260 normalized_end_yx =json.loads(normalized_end_yx)
261
262 if is_tap_action(normalized_start_yx, normalized_end_yx):
263 gt_cand_nodes = json.loads(gt['ui_positions'])
264 gt_action_type = "click"
265 gt_action_yx = {"y": normalized_start_yx[0], "x": normalized_start_yx[1]}
266 else:
267 point1 = {"y": normalized_start_yx[0], "x": normalized_start_yx[1]}
268 point2 = {"y": normalized_end_yx[0], "x": normalized_end_yx[1]}
269 gt_action_type = "scroll"
270 gt_action_direction = _get_direction(point1, point2)
271 elif gt['result_action_type'] == self._aitz_action_type_.LONG_POINT:
272 normalized_start_yx = gt['result_touch_yx']
273 normalized_start_yx = json.loads(normalized_start_yx)
274 normalized_end_yx = gt['result_lift_yx']
275 normalized_end_yx =json.loads(normalized_end_yx)
276
277 gt_cand_nodes = json.loads(gt['ui_positions'])
278 gt_action_type = "long_point"
279 gt_action_yx = {"y": normalized_start_yx[0], "x": normalized_start_yx[1]}
280 gt_duration = gt['duration']
281 elif gt['result_action_type'] == self._aitz_action_type_.PRESS_BACK:
282 gt_action_type = "press"
283 gt_action_button = "back"
284 elif gt['result_action_type'] == self._aitz_action_type_.PRESS_HOME:
285 gt_action_type = "press"
286 gt_action_button = "home"
287 elif gt['result_action_type'] == self._aitz_action_type_.PRESS_ENTER:
288 gt_action_type = "press"
289 gt_action_button = "enter"
290 elif gt['result_action_type'] == self._aitz_action_type_.STATUS_TASK_COMPLETE or gt['result_action_type'] == self._aitz_action_type_.STATUS_TASK_IMPOSSIBLE:
291 gt_action_type = "stop"
292 gt_action_text = gt['result_action_text']
293 elif gt['result_action_type'] == self._aitz_action_type_.NO_ACTION:
294 gt_action_type = "stop"
295 gt_duration = gt['duration']
296 else:
297 raise ValueError("Unknow action type.")
298
299 return gt_action_type, gt_action_yx, gt_cand_nodes, \
300 gt_action_text, gt_action_button, gt_action_direction, gt_duration
301
302 def __call__(self, gt, pred, annotate_image=False):

Callers 1

__call__Method · 0.95

Calls 2

_get_directionFunction · 0.85
is_tap_actionFunction · 0.70

Tested by

no test coverage detected