MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / gen_layout_parallel

Function gen_layout_parallel

utils/wei_utils.py:544–583  ·  view source on GitHub ↗
(agent, prompt, num_retries, existing_code='', slide_width=0, slide_height=0, tmp_name='tmp')

Source from the content-addressed store, hash-verified

542 return log
543
544def 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'''
549poster = create_poster(width_inch={slide_width}, height_inch={slide_height})
550slide = add_blank_slide(poster)
551save_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
585def compute_bullet_length(textbox_content):
586 total = 0

Callers 2

layout_process_sectionFunction · 0.85
layout_process_sectionFunction · 0.85

Calls 5

match_responseFunction · 0.85
run_codeFunction · 0.85
account_tokenFunction · 0.70
resetMethod · 0.45
stepMethod · 0.45

Tested by

no test coverage detected