(agent, prompt, num_retries, existing_code='', slide_width=0, slide_height=0, tmp_name='tmp')
| 542 | return log |
| 543 | |
| 544 | def gen_layout_parallel(agent, prompt, num_retries, existing_code='', slide_width=0, slide_height=0, tmp_name='tmp'): |
| 545 | if existing_code == '': |
| 546 | existing_code = utils_functions |
| 547 | |
| 548 | existing_code += f''' |
| 549 | poster = create_poster(width_inch={slide_width}, height_inch={slide_height}) |
| 550 | slide = add_blank_slide(poster) |
| 551 | save_presentation(poster, file_name="poster_{tmp_name}.pptx") |
| 552 | ''' |
| 553 | agent.reset() |
| 554 | log = [] |
| 555 | cumulative_input_token, cumulative_output_token = 0, 0 |
| 556 | for attempt in range(num_retries + 1): |
| 557 | response = agent.step(prompt) |
| 558 | input_token, output_token = account_token(response) |
| 559 | cumulative_input_token += input_token |
| 560 | cumulative_output_token += output_token |
| 561 | new_code = match_response(response) |
| 562 | all_code = existing_code + '\n' + new_code |
| 563 | |
| 564 | output, error = run_code(all_code) |
| 565 | log.append({ |
| 566 | "code": new_code, |
| 567 | "output": output, |
| 568 | "error": error, |
| 569 | "concatenated_code": all_code, |
| 570 | 'num_tokens': (input_token, output_token), |
| 571 | 'cumulative_tokens': (cumulative_input_token, cumulative_output_token) |
| 572 | }) |
| 573 | if output is None or output == '': |
| 574 | prompt = 'No object name printed.' |
| 575 | continue |
| 576 | |
| 577 | if error is None: |
| 578 | return log |
| 579 | |
| 580 | if attempt < num_retries: |
| 581 | # print(f"Retrying... Attempt {attempt + 1} of {num_retries}", flush=True) |
| 582 | prompt = error |
| 583 | return log |
| 584 | |
| 585 | def compute_bullet_length(textbox_content): |
| 586 | total = 0 |
no test coverage detected