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

Function _process_section

PosterAgent/gen_poster_content.py:257–424  ·  view source on GitHub ↗

Returns: (i, result_json, t_in, t_out, v_in, v_out)

(i)

Source from the content-addressed store, hash-verified

255
256 # ----------------------- Worker (defined INSIDE main fn) -----------------------
257 def _process_section(i):
258 """
259 Returns:
260 (i, result_json, t_in, t_out, v_in, v_out)
261 """
262 local_t_in = local_t_out = 0
263 local_v_in = local_v_out = 0
264
265 arrangement = panels[i]
266 num_textboxes = 2 if arrangement.get('gp', 0) > 0 else 1
267
268 local_tmp_dir = tempfile.mkdtemp(prefix=f"sec_{i}_", dir=tmp_dir)
269
270 jinja_args = {
271 'summary_of_section': raw_content['sections'][i]['content'],
272 'number_of_textboxes': num_textboxes,
273 'section_title': raw_content['sections'][i]['title'],
274 'bullet_font_size': args.bullet_font_size,
275 'section_title_font_size': args.section_title_font_size,
276 }
277
278 target_textboxes = textboxes_by_panel[i][1:] # skip first (section title)
279 total_expected_length = sum(tb['num_chars'] for tb in target_textboxes)
280
281 # Create fresh models & agents per thread for safety
282 if args.model_name_t.startswith('vllm_qwen'):
283 actor_model = ModelFactory.create(
284 model_platform=actor_config['model_platform'],
285 model_type=actor_config['model_type'],
286 model_config_dict=actor_config['model_config'],
287 url=actor_config['url'],
288 )
289 else:
290 actor_model = ModelFactory.create(
291 model_platform=actor_config['model_platform'],
292 model_type=actor_config['model_type'],
293 model_config_dict=actor_config['model_config']
294 )
295 if args.model_name_v.startswith('vllm_qwen'):
296 critic_model = ModelFactory.create(
297 model_platform=critic_config['model_platform'],
298 model_type=critic_config['model_type'],
299 model_config_dict=critic_config['model_config'],
300 url=critic_config['url'],
301 )
302 else:
303 critic_model = ModelFactory.create(
304 model_platform=critic_config['model_platform'],
305 model_type=critic_config['model_type'],
306 model_config_dict=critic_config['model_config']
307 )
308
309 actor_agent = ChatAgent(system_message=content_config['system_prompt'], model=actor_model, message_window_size=30)
310 critic_agent = ChatAgent(system_message=critic_content_config['system_prompt'], model=critic_model, message_window_size=10)
311
312 prompt = template.render(**jinja_args)
313 actor_agent.reset()
314 response = actor_agent.step(prompt)

Callers

nothing calls this directly

Calls 9

resetMethod · 0.95
stepMethod · 0.95
ChatAgentClass · 0.90
get_json_from_responseFunction · 0.90
compute_bullet_lengthFunction · 0.85
render_textboxFunction · 0.70
account_tokenFunction · 0.50
createMethod · 0.45
make_user_messageMethod · 0.45

Tested by

no test coverage detected