MCPcopy
hub / github.com/TencentQQGYLab/AppAgent / parse_reflect_rsp

Function parse_reflect_rsp

scripts/model.py:190–211  ·  view source on GitHub ↗
(rsp)

Source from the content-addressed store, hash-verified

188
189
190def 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"]

Callers 1

self_explorer.pyFile · 0.90

Calls 1

print_with_colorFunction · 0.90

Tested by

no test coverage detected