(self, rd, history, times = None, indicators = None)
| 277 | |
| 278 | |
| 279 | def get_time_simple_execution_feedback(self, rd, history, times = None, indicators = None): |
| 280 | if indicators == None: |
| 281 | raise ValueError("Missing indicators.") |
| 282 | prompts = {} |
| 283 | if rd == 0: |
| 284 | for prompt in history: |
| 285 | if prompt not in indicators: |
| 286 | continue |
| 287 | prompts[prompt] = [] |
| 288 | for i, h in enumerate(history[prompt]): |
| 289 | if indicators[prompt][i]: |
| 290 | message = self.apply_template("time_simple_execution_feedback", rd, {}) |
| 291 | prompts[prompt].append(self.build_chat_message(message, h)) |
| 292 | else: |
| 293 | prompts[prompt].append(None) |
| 294 | elif rd == 1: |
| 295 | if times == None: |
| 296 | raise ValueError("Missing required data times.") |
| 297 | for prompt in history: |
| 298 | if prompt not in indicators: |
| 299 | continue |
| 300 | prompts[prompt] = [] |
| 301 | for i, h in enumerate(history[prompt]): |
| 302 | if indicators[prompt][i] and times[prompt][i] != None: |
| 303 | if times[prompt][i][0] > times[prompt][i][1]: |
| 304 | message = self.apply_template("time_simple_execution_feedback", rd, {"ori_time": str(times[prompt][i][0]), "opt_time": str(times[prompt][i][1])}, condition = "positive") |
| 305 | else: |
| 306 | message = self.apply_template("time_simple_execution_feedback", rd, {"ori_time": str(times[prompt][i][0]), "opt_time": str(times[prompt][i][1])}, condition = "negative") |
| 307 | prompts[prompt].append(self.build_chat_message(message, h)) |
| 308 | else: |
| 309 | prompts[prompt].append(None) |
| 310 | |
| 311 | return prompts |
| 312 | |
| 313 | def get_time_execution_feedback_with_testcase(self, rd, history, testcases = None, indicators = None): |
| 314 | if indicators == None: |
no test coverage detected