MCPcopy
hub / github.com/stitionai/devika / parse_response

Method parse_response

src/agents/planner/planner.py:19–66  ·  view source on GitHub ↗
(self, response: str)

Source from the content-addressed store, hash-verified

17 return True
18
19 def parse_response(self, response: str):
20 result = {
21 "project": "",
22 "reply": "",
23 "focus": "",
24 "plans": {},
25 "summary": ""
26 }
27
28 current_section = None
29 current_step = None
30
31 for line in response.split("\n"):
32 line = line.strip()
33
34 if line.startswith("Project Name:"):
35 current_section = "project"
36 result["project"] = line.split(":", 1)[1].strip()
37 elif line.startswith("Your Reply to the Human Prompter:"):
38 current_section = "reply"
39 result["reply"] = line.split(":", 1)[1].strip()
40 elif line.startswith("Current Focus:"):
41 current_section = "focus"
42 result["focus"] = line.split(":", 1)[1].strip()
43 elif line.startswith("Plan:"):
44 current_section = "plans"
45 elif line.startswith("Summary:"):
46 current_section = "summary"
47 result["summary"] = line.split(":", 1)[1].strip()
48 elif current_section == "reply":
49 result["reply"] += " " + line
50 elif current_section == "focus":
51 result["focus"] += " " + line
52 elif current_section == "plans":
53 if line.startswith("- [ ] Step"):
54 current_step = line.split(":")[0].strip().split(" ")[-1]
55 result["plans"][int(current_step)] = line.split(":", 1)[1].strip()
56 elif current_step:
57 result["plans"][int(current_step)] += " " + line
58 elif current_section == "summary":
59 result["summary"] += " " + line.replace("```", "")
60
61 result["project"] = result["project"].strip()
62 result["reply"] = result["reply"].strip()
63 result["focus"] = result["focus"].strip()
64 result["summary"] = result["summary"].strip()
65
66 return result
67
68 def execute(self, prompt: str, project_name: str) -> str:
69 prompt = self.render(prompt)

Callers 2

make_decisionMethod · 0.80
executeMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected