(
agent,
edit_section_name,
feedback,
all_code,
file_name,
outline,
content,
images,
actor_prompt,
num_retries=1,
prompt_type='initial'
)
| 277 | return concatenated_code, output, error |
| 278 | |
| 279 | def edit_modular( |
| 280 | agent, |
| 281 | edit_section_name, |
| 282 | feedback, |
| 283 | all_code, |
| 284 | file_name, |
| 285 | outline, |
| 286 | content, |
| 287 | images, |
| 288 | actor_prompt, |
| 289 | num_retries=1, |
| 290 | prompt_type='initial' |
| 291 | ): |
| 292 | agent.reset() |
| 293 | log = [] |
| 294 | if prompt_type == 'initial': |
| 295 | msg = actor_prompt.format( |
| 296 | outline['meta'], |
| 297 | {edit_section_name: outline[edit_section_name]}, |
| 298 | content, |
| 299 | images, |
| 300 | documentation |
| 301 | ) |
| 302 | elif prompt_type == 'edit': |
| 303 | assert (edit_section_name == list(feedback.keys())[0]) |
| 304 | msg = actor_prompt.format( |
| 305 | edit_section_name, |
| 306 | all_code[edit_section_name], |
| 307 | feedback, |
| 308 | {edit_section_name: outline[edit_section_name]}, |
| 309 | content, |
| 310 | images, |
| 311 | documentation |
| 312 | ) |
| 313 | elif prompt_type == 'new': |
| 314 | assert (list(feedback.keys())[0] == 'all_good') |
| 315 | msg = actor_prompt.format( |
| 316 | {edit_section_name: outline[edit_section_name]}, |
| 317 | content, |
| 318 | images, |
| 319 | documentation |
| 320 | ) |
| 321 | |
| 322 | for attempt in range(num_retries + 1): |
| 323 | response = agent.step(msg) |
| 324 | new_code = match_response(response) |
| 325 | all_code_changed = all_code.copy() |
| 326 | all_code_changed[edit_section_name] = new_code |
| 327 | concatenated_code, output, error = run_modular(all_code_changed, file_name, False, False) |
| 328 | log.append({ |
| 329 | "code": new_code, |
| 330 | "output": output, |
| 331 | "error": error, |
| 332 | "concatenated_code": concatenated_code |
| 333 | }) |
| 334 | if error is None: |
| 335 | return log |
| 336 |
nothing calls this directly
no test coverage detected