(raw_pred)
| 865 | |
| 866 | |
| 867 | def post_process_generation(raw_pred): |
| 868 | ans_match = re.match(r".*<extra_id_0>(.*)<extra_id_1>.*", raw_pred) |
| 869 | if ans_match is not None: |
| 870 | result = ans_match.group(1) |
| 871 | else: |
| 872 | result = raw_pred |
| 873 | |
| 874 | # remove extra <*>'s left in |
| 875 | result = result.replace("<", " <") |
| 876 | out = "" |
| 877 | for token in result.split(" "): |
| 878 | if (len(token.strip()) > 0): |
| 879 | if (token[0] != "<"): |
| 880 | out += token + " " |
| 881 | result = out |
| 882 | |
| 883 | return result.strip() |
| 884 | |
| 885 | |
| 886 | def gpt_select_valid(action, candidates, look, inventory, goal, logger, n=1, gpt_version="gpt-4", llm=None): |
no test coverage detected