MCPcopy Create free account
hub / github.com/ResearAI/AutoFigure / get_initial_prompt_template

Function get_initial_prompt_template

autofigure/generator.py:266–300  ·  view source on GitHub ↗
(topic: str, content: str, output_format: str = None)

Source from the content-addressed store, hash-verified

264 return reference_figures
265
266def get_initial_prompt_template(topic: str, content: str, output_format: str = None) -> str:
267 if topic not in CONFIG['SUPPORTED_TOPICS']:
268 raise ValueError(f"Unsupported topic: {topic}. Supported topics are: {CONFIG['SUPPORTED_TOPICS']}")
269
270 output_format = output_format or CONFIG.get('OUTPUT_FORMAT', 'svg')
271
272 common_placeholder_spec = """
273**Placeholder Specification:**
274 * To prepare for final illustration, an icon needs a placeholder.
275 * **Function**: The placeholder's role is to reserve space and provide a clear directive for the illustrator.
276 * **Recommended Implementation**: A clean, professional way to do this is with a gray, rounded-corner rectangle (`<rect rx="8" ry="8" style="fill:#cccccc; stroke:#666666; stroke-width:1;" />`).
277 * **Content (CRITICAL)**: Each placeholder MUST contain two pieces of text:
278 * **Exterior Label**: A concise name for the component, placed **outside** the box (e.g., above it).
279 * **Interior Description**: A detailed English phrase describing the desired icon using the format `[icon]: <description>`, placed **inside** the box (e.g., `[icon]: An icon showing a robot meticulously reviewing a paper`). This description MUST NOT appear in the final illustration but is a crucial instruction and it must be detailed and concrete.
280"""
281
282 # Select appropriate prompt template based on output format
283 if output_format == 'mxgraphxml':
284 if topic == 'paper':
285 return _get_paper_mxgraphxml_prompt_template(content, common_placeholder_spec)
286 elif topic == 'survey':
287 return _get_survey_mxgraphxml_prompt_template(content, common_placeholder_spec)
288 elif topic == 'blog':
289 return _get_blog_mxgraphxml_prompt_template(content, common_placeholder_spec)
290 elif topic == 'textbook':
291 return _get_textbook_mxgraphxml_prompt_template(content, common_placeholder_spec)
292 else: # default to svg
293 if topic == 'paper':
294 return _get_paper_prompt_template(content, common_placeholder_spec)
295 elif topic == 'survey':
296 return _get_survey_prompt_template(content, common_placeholder_spec)
297 elif topic == 'blog':
298 return _get_blog_prompt_template(content, common_placeholder_spec)
299 elif topic == 'textbook':
300 return _get_textbook_prompt_template(content, common_placeholder_spec)
301
302def extract_layout_type(svg_code: str) -> Optional[str]:
303 try:

Callers 2

generate_initial_codeFunction · 0.85
improve_codeFunction · 0.85

Tested by

no test coverage detected