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

Method validate_response

src/agents/patcher/patcher.py:40–67  ·  view source on GitHub ↗
(self, response: str)

Source from the content-addressed store, hash-verified

38 )
39
40 def validate_response(self, response: str) -> Union[List[Dict[str, str]], bool]:
41 response = response.strip()
42
43 response = response.split("~~~", 1)[1]
44 response = response[:response.rfind("~~~")]
45 response = response.strip()
46
47 result = []
48 current_file = None
49 current_code = []
50 code_block = False
51
52 for line in response.split("\n"):
53 if line.startswith("File: "):
54 if current_file and current_code:
55 result.append({"file": current_file, "code": "\n".join(current_code)})
56 current_file = line.split("`")[1].strip()
57 current_code = []
58 code_block = False
59 elif line.startswith("```"):
60 code_block = not code_block
61 else:
62 current_code.append(line)
63
64 if current_file and current_code:
65 result.append({"file": current_file, "code": "\n".join(current_code)})
66
67 return result
68
69 def save_code_to_project(self, response: List[Dict[str, str]], project_name: str):
70 file_path_dir = None

Callers 1

executeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected