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

Function fill_content

utils/wei_utils.py:465–494  ·  view source on GitHub ↗
(agent, prompt, num_retries, existing_code='')

Source from the content-addressed store, hash-verified

463
464
465def fill_content(agent, prompt, num_retries, existing_code=''):
466 if existing_code == '':
467 existing_code = utils_functions
468 agent.reset()
469 log = []
470 cumulative_input_token, cumulative_output_token = 0, 0
471 for attempt in range(num_retries + 1):
472 response = agent.step(prompt)
473 input_token, output_token = account_token(response)
474 cumulative_input_token += input_token
475 cumulative_output_token += output_token
476 new_code = match_response(response)
477 all_code = existing_code + '\n' + new_code
478
479 output, error = run_code(all_code)
480 log.append({
481 "code": new_code,
482 "output": output,
483 "error": error,
484 "concatenated_code": all_code,
485 'cumulative_tokens': (cumulative_input_token, cumulative_output_token)
486 })
487
488 if error is None:
489 return log
490
491 if attempt < num_retries:
492 print(f"Retrying... Attempt {attempt + 1} of {num_retries}")
493 prompt = error
494 return log
495
496def apply_theme(agent, prompt, num_retries, existing_code=''):
497 return fill_content(agent, prompt, num_retries, existing_code)

Callers 5

fill_poster_contentFunction · 0.90
fill_poster_contentFunction · 0.90
apply_themeFunction · 0.85
edit_codeFunction · 0.85
stylizeFunction · 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