(self)
| 248 | return text |
| 249 | |
| 250 | def gen_initial_code(self): |
| 251 | num_attempts = 0 |
| 252 | error_hist = list() |
| 253 | while True: |
| 254 | if num_attempts == 0: |
| 255 | err = str() |
| 256 | err_hist = str() |
| 257 | else: |
| 258 | err = f"The following was the previous command generated: {model_resp}. This was the error return {cmd_str}. You should make sure not to repeat this error and to solve the presented problem." |
| 259 | error_hist.append(err) |
| 260 | if len(error_hist) == 5: _ = error_hist.pop(0) |
| 261 | err = "\n".join(error_hist) |
| 262 | err_hist = "The following is a history of your previous errors\n" + err + "\nDO NOT REPEAT THESE." |
| 263 | model_resp = query_model( |
| 264 | openai_api_key=self.openai_api_key, |
| 265 | model_str=self.model, |
| 266 | system_prompt=self.system_prompt(), |
| 267 | prompt=f"{err_hist}\nYou should now use ```REPLACE to create initial code to solve the challenge. Now please enter the ```REPLACE command below:\n ", temp=1.0) |
| 268 | model_resp = self.clean_text(model_resp) |
| 269 | cmd_str, code_lines, prev_code_ret, should_execute_code, score = self.process_command(model_resp) |
| 270 | if not self.supress_print: print(f"@@@ INIT ATTEMPT: Command Exec // Attempt {num_attempts}: ", str(cmd_str).replace("\n", " | ")) |
| 271 | if not self.supress_print: print(f"$$$ Score: {score}") |
| 272 | if score is not None: break |
| 273 | num_attempts += 1 |
| 274 | return code_lines, prev_code_ret, score |
| 275 | |
| 276 | def solve(self): |
| 277 | num_attempts = 0 |
no test coverage detected