MCPcopy
hub / github.com/Codium-ai/AlphaCodium / try_fix_yaml

Function try_fix_yaml

alpha_codium/gen/utils.py:133–148  ·  view source on GitHub ↗
(response_text: str, keys_fix_yaml: List[str] = [])

Source from the content-addressed store, hash-verified

131
132
133def try_fix_yaml(response_text: str, keys_fix_yaml: List[str] = []) -> dict:
134 response_text_lines = response_text.split('\n')
135
136 keys = keys_fix_yaml
137 response_text_lines_copy = response_text_lines.copy()
138 for i in range(0, len(response_text_lines_copy)):
139 for key in keys:
140 if response_text_lines_copy[i].strip().startswith(key) and not '|' in response_text_lines_copy[i]:
141 response_text_lines_copy[i] = response_text_lines_copy[i].replace(f'{key}',
142 f'{key} |-\n ')
143 try:
144 data = yaml.safe_load('\n'.join(response_text_lines_copy))
145 get_logger().info(f"Successfully parsed AI prediction after adding |-\n")
146 return data
147 except:
148 raise "yaml parsing error"

Callers 1

load_yamlFunction · 0.85

Calls 1

get_loggerFunction · 0.90

Tested by

no test coverage detected