MCPcopy Create free account
hub / github.com/SalesforceAIResearch/perfcodegen / get_solutions

Method get_solutions

src/evaluate.py:56–74  ·  view source on GitHub ↗
(self, codegen = False, chat = False)

Source from the content-addressed store, hash-verified

54
55
56 def get_solutions(self, codegen = False, chat = False):
57 for index, prompt in enumerate(self.outputs):
58 if prompt not in self.dataset.prompt2instance:
59 print('Cannot find the prompt of instance #{} in dataset, skipped.'.format(index))
60 continue
61 instance = self.dataset.prompt2instance[prompt]
62 solutions = []
63 if not self.outputs[prompt][1]:
64 continue
65 if not isinstance(self.outputs[prompt][0], list):
66 print(self.outputs[prompt][0])
67 continue
68 for code in self.outputs[prompt][0]:
69 solution = sanitize(code, self.get_entrypoint(instance), codegen = codegen, global_code = True if self.dataset.name in ["NTU-NLP-sg/xCodeEval", "codeparrot/apps"] else False, chat = chat)
70 solution = self.process_solution(solution, instance)
71 if solution not in solutions:
72 solutions.append(solution)
73
74 self.solutions[prompt] = solutions
75
76
77 def save_solutions(self):

Callers

nothing calls this directly

Calls 3

get_entrypointMethod · 0.95
process_solutionMethod · 0.95
sanitizeFunction · 0.90

Tested by

no test coverage detected