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

Function gen_layout

utils/wei_utils.py:505–542  ·  view source on GitHub ↗
(agent, prompt, num_retries, name_to_hierarchy, visual_identifier='', existing_code='')

Source from the content-addressed store, hash-verified

503 return fill_content(agent, prompt, num_retries, existing_code)
504
505def gen_layout(agent, prompt, num_retries, name_to_hierarchy, visual_identifier='', existing_code=''):
506 if existing_code == '':
507 existing_code = utils_functions
508 agent.reset()
509 log = []
510 cumulative_input_token, cumulative_output_token = 0, 0
511 for attempt in range(num_retries + 1):
512 response = agent.step(prompt)
513 input_token, output_token = account_token(response)
514 cumulative_input_token += input_token
515 cumulative_output_token += output_token
516 new_code = match_response(response)
517 all_code = existing_code + '\n' + new_code
518
519 # Save visualizations
520 all_code += f'''
521name_to_hierarchy = {name_to_hierarchy}
522identifier = "{visual_identifier}"
523get_visual_cues(name_to_hierarchy, identifier)
524'''
525
526 output, error = run_code(all_code)
527 log.append({
528 "code": new_code,
529 "output": output,
530 "error": error,
531 "concatenated_code": all_code,
532 'num_tokens': (input_token, output_token),
533 'cumulative_tokens': (cumulative_input_token, cumulative_output_token)
534 })
535
536 if error is None:
537 return log
538
539 if attempt < num_retries:
540 print(f"Retrying... Attempt {attempt + 1} of {num_retries}")
541 prompt = error
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 == '':

Callers 1

gen_outline_layoutFunction · 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