(rsp)
| 188 | |
| 189 | |
| 190 | def parse_reflect_rsp(rsp): |
| 191 | try: |
| 192 | decision = re.findall(r"Decision: (.*?)$", rsp, re.MULTILINE)[0] |
| 193 | think = re.findall(r"Thought: (.*?)$", rsp, re.MULTILINE)[0] |
| 194 | print_with_color("Decision:", "yellow") |
| 195 | print_with_color(decision, "magenta") |
| 196 | print_with_color("Thought:", "yellow") |
| 197 | print_with_color(think, "magenta") |
| 198 | if decision == "INEFFECTIVE": |
| 199 | return [decision, think] |
| 200 | elif decision == "BACK" or decision == "CONTINUE" or decision == "SUCCESS": |
| 201 | doc = re.findall(r"Documentation: (.*?)$", rsp, re.MULTILINE)[0] |
| 202 | print_with_color("Documentation:", "yellow") |
| 203 | print_with_color(doc, "magenta") |
| 204 | return [decision, think, doc] |
| 205 | else: |
| 206 | print_with_color(f"ERROR: Undefined decision {decision}!", "red") |
| 207 | return ["ERROR"] |
| 208 | except Exception as e: |
| 209 | print_with_color(f"ERROR: an exception occurs while parsing the model response: {e}", "red") |
| 210 | print_with_color(rsp, "red") |
| 211 | return ["ERROR"] |
no test coverage detected