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

Function process_leaf_section

PosterAgent/deoverflow_parallel.py:26–158  ·  view source on GitHub ↗

Handles the logic for a single leaf_section within a section_name. Returns a dictionary of updated logs and tokens.

(
    leaf_section,
    section_name,
    outline,
    content,
    style_logs,
    critic_logs,
    actor_logs,
    img_logs,
    slide_width,
    slide_height,
    name_to_hierarchy,
    critic_template,
    actor_template,
    critic_agent,
    actor_agent,
    neg_img,
    pos_img,
    MAX_ATTEMPTS,
    documentation,
    total_input_token,
    total_output_token,
)

Source from the content-addressed store, hash-verified

24MAX_ATTEMPTS = 5
25
26def process_leaf_section(
27 leaf_section,
28 section_name,
29 outline,
30 content,
31 style_logs,
32 critic_logs,
33 actor_logs,
34 img_logs,
35 slide_width,
36 slide_height,
37 name_to_hierarchy,
38 critic_template,
39 actor_template,
40 critic_agent,
41 actor_agent,
42 neg_img,
43 pos_img,
44 MAX_ATTEMPTS,
45 documentation,
46 total_input_token,
47 total_output_token,
48):
49 """
50 Handles the logic for a single leaf_section within a section_name.
51
52 Returns a dictionary of updated logs and tokens.
53 """
54 section_code = style_logs[section_name][-1]['code'] # current code for this section
55 log = []
56 leaf_name = None
57 if leaf_section in outline:
58 leaf_name = outline[leaf_section]['name']
59 else:
60 leaf_name = outline[section_name]['subsections'][leaf_section]['name']
61
62 num_rounds = 0
63 while True:
64 print(f"Section: {section_name}, Leaf Section: {leaf_section}, Round: {num_rounds}")
65 num_rounds += 1
66 if num_rounds > MAX_ATTEMPTS:
67 break
68
69 poster = create_poster(slide_width, slide_height)
70 add_blank_slide(poster)
71 empty_poster_path = f'tmp/empty_poster_{section_name}_{leaf_section}.pptx'
72 save_presentation(poster, file_name=empty_poster_path)
73
74 curr_location, zoomed_in_img, zoomed_in_img_path = get_snapshot_from_section(
75 leaf_section,
76 section_name,
77 name_to_hierarchy,
78 leaf_name,
79 section_code,
80 empty_poster_path
81 )
82
83 if leaf_section not in img_logs:

Callers 1

process_sectionFunction · 0.70

Calls 10

get_json_from_responseFunction · 0.90
edit_codeFunction · 0.85
create_posterFunction · 0.50
add_blank_slideFunction · 0.50
save_presentationFunction · 0.50
account_tokenFunction · 0.50
make_user_messageMethod · 0.45
resetMethod · 0.45
stepMethod · 0.45

Tested by

no test coverage detected