Main class for generating scientific figures using AI. Example usage: ```python from autofigure import AutoFigureAgent, Config config = Config(generation_api_key="your-api-key") agent = AutoFigureAgent(config) result = agent.generate( d
| 48 | |
| 49 | |
| 50 | class AutoFigureAgent: |
| 51 | """ |
| 52 | Main class for generating scientific figures using AI. |
| 53 | |
| 54 | Example usage: |
| 55 | ```python |
| 56 | from autofigure import AutoFigureAgent, Config |
| 57 | |
| 58 | config = Config(generation_api_key="your-api-key") |
| 59 | agent = AutoFigureAgent(config) |
| 60 | |
| 61 | result = agent.generate( |
| 62 | description="A flowchart showing the training pipeline", |
| 63 | max_iterations=5 |
| 64 | ) |
| 65 | |
| 66 | print(f"Generated: {result.svg_path}") |
| 67 | ``` |
| 68 | """ |
| 69 | |
| 70 | def __init__(self, config: Config): |
| 71 | """ |
| 72 | Initialize AutoFigureAgent. |
| 73 | |
| 74 | Args: |
| 75 | config: AutoFigure configuration |
| 76 | """ |
| 77 | self.config = config |
| 78 | self._extractor = None |
| 79 | self._enhancer = None |
| 80 | |
| 81 | # Validate configuration |
| 82 | errors = config.validate() |
| 83 | if errors: |
| 84 | print(f"[AutoFigureAgent] Configuration warnings: {errors}") |
| 85 | |
| 86 | # Update generator CONFIG from SDK config |
| 87 | update_config_from_sdk(config) |
| 88 | |
| 89 | @property |
| 90 | def extractor(self) -> MethodologyExtractor: |
| 91 | """Lazy-load methodology extractor.""" |
| 92 | if self._extractor is None: |
| 93 | self._extractor = MethodologyExtractor(self.config) |
| 94 | return self._extractor |
| 95 | |
| 96 | @property |
| 97 | def enhancer(self) -> ImageEnhancer: |
| 98 | """Lazy-load image enhancer.""" |
| 99 | if self._enhancer is None: |
| 100 | self._enhancer = ImageEnhancer(self.config) |
| 101 | return self._enhancer |
| 102 | |
| 103 | def generate( |
| 104 | self, |
| 105 | description: str, |
| 106 | max_iterations: Optional[int] = None, |
| 107 | output_format: str = "svg", |
nothing calls this directly
no outgoing calls
no test coverage detected