MCPcopy Create free account
hub / github.com/THUDM/AgentTuning / post_process

Function post_process

eval_heldout/science-world/eval_utils.py:538–575  ·  view source on GitHub ↗
(response_next_actions)

Source from the content-addressed store, hash-verified

536 response_next_actions = local_llm.generate(prompt_to_next_actions)
537
538 def post_process(response_next_actions):
539 logger.info("-"*30 + "response_next_actions" + "-"*30)
540 logger.info("\n"+response_next_actions)
541 logger.info("-"*35 + "-"*35)
542 action_list = response_next_actions.split("\n")[:5] # only the take the first 10
543 logger.info(f"action_list={action_list}")
544 real_action_list = []
545 guess_obs_list = []
546 for action in action_list:
547 if "repeat" in action.lower():
548
549 if "wait" in real_action_list[-1].lower():
550 todos = real_action_list[-3:]
551 todo_obs = guess_obs_list[-3:]
552 else:
553 todos = real_action_list[-2:]
554 todo_obs = guess_obs_list[-3:]
555
556 real_action_list += todos*5
557 guess_obs_list += todo_obs*5
558 if "until" in action.lower():
559 break
560 continue
561 if ":" not in action or "Action" not in action or "(" not in action or ")" not in action:
562 continue
563 start_ind = action.index(":")
564 end_ind = action.index(")")
565 if "-->" in action:
566 guess_obs = action[action.index("-->")+3:].strip().replace("You ", "").replace(" the ", " ").replace(".", "").strip()
567 else:
568 guess_obs = "None"
569 action = action[start_ind+1: end_ind+1].strip()
570 action = recover_action(action)
571 if action:
572 real_action_list.append(action)
573 guess_obs_list.append(guess_obs)
574 logger.info(f"real_action_list={real_action_list}")
575 return real_action_list, guess_obs_list
576 real_action_list, guess_obs_list = post_process(response_next_actions)
577 except Exception as e:
578 logger.info("OpenAI error:" + str(e))

Callers 1

Calls 2

recover_actionFunction · 0.90
indexMethod · 0.45

Tested by

no test coverage detected