Generate a scientific figure from a text description. Args: description: Text description of the figure to generate max_iterations: Maximum iterations for refinement (overrides config) output_format: Output format - 'svg' or 'mxgraphxml'
(
self,
description: str,
max_iterations: Optional[int] = None,
output_format: str = "svg",
quality_threshold: Optional[float] = None,
enable_enhancement: bool = False,
art_style: Optional[str] = None,
enhancement_input_type: Optional[str] = None,
enhancement_count: Optional[int] = None,
custom_references: Optional[List[str]] = None,
output_dir: Optional[str] = None,
topic: str = "paper",
)
| 101 | return self._enhancer |
| 102 | |
| 103 | def generate( |
| 104 | self, |
| 105 | description: str, |
| 106 | max_iterations: Optional[int] = None, |
| 107 | output_format: str = "svg", |
| 108 | quality_threshold: Optional[float] = None, |
| 109 | enable_enhancement: bool = False, |
| 110 | art_style: Optional[str] = None, |
| 111 | enhancement_input_type: Optional[str] = None, |
| 112 | enhancement_count: Optional[int] = None, |
| 113 | custom_references: Optional[List[str]] = None, |
| 114 | output_dir: Optional[str] = None, |
| 115 | topic: str = "paper", |
| 116 | ) -> GenerationResult: |
| 117 | """ |
| 118 | Generate a scientific figure from a text description. |
| 119 | |
| 120 | Args: |
| 121 | description: Text description of the figure to generate |
| 122 | max_iterations: Maximum iterations for refinement (overrides config) |
| 123 | output_format: Output format - 'svg' or 'mxgraphxml' |
| 124 | quality_threshold: Quality threshold to stop (overrides config) |
| 125 | enable_enhancement: Whether to enhance the final image |
| 126 | art_style: Art style for enhancement (overrides config) |
| 127 | enhancement_input_type: Enhancement input type - 'none', 'code', 'code2prompt' (overrides config) |
| 128 | enhancement_count: Number of enhanced image variants to generate (overrides config) |
| 129 | custom_references: Custom reference figure paths |
| 130 | output_dir: Output directory (overrides config) |
| 131 | topic: Content type ('paper', 'survey', 'blog', 'textbook') |
| 132 | |
| 133 | Returns: |
| 134 | GenerationResult with paths and metadata |
| 135 | """ |
| 136 | result = GenerationResult() |
| 137 | |
| 138 | # Validate output_format |
| 139 | valid_formats = ["svg", "mxgraphxml", "mxgraph"] |
| 140 | if output_format not in valid_formats: |
| 141 | result.success = False |
| 142 | result.error = f"Invalid output_format '{output_format}'. Must be 'svg' or 'mxgraphxml'" |
| 143 | return result |
| 144 | |
| 145 | # Normalize mxgraph to mxgraphxml |
| 146 | if output_format == "mxgraph": |
| 147 | output_format = "mxgraphxml" |
| 148 | |
| 149 | result.logs.append(f"Starting generation with format: {output_format}") |
| 150 | |
| 151 | # Override config settings if provided |
| 152 | if max_iterations is not None: |
| 153 | self.config.max_iterations = max_iterations |
| 154 | if quality_threshold is not None: |
| 155 | self.config.quality_threshold = quality_threshold |
| 156 | if output_dir is not None: |
| 157 | self.config.output_dir = output_dir |
| 158 | if custom_references is not None: |
| 159 | self.config.custom_references = custom_references |
| 160 |
no test coverage detected