Configuration API¶
The config module handles all configuration management for LayoutLens.
Config Class¶
- class layoutlens.config.Config(config_path: str | None = None)[source]¶
Bases:
objectMain configuration class for LayoutLens framework.
This class manages all configuration aspects including: - LLM provider settings - Viewport configurations - Screenshot options - Test execution parameters - Output and reporting settings
- DEFAULT_VIEWPORTS = [ViewportConfig(name='mobile_portrait', width=375, height=667, device_scale_factor=2.0, is_mobile=True, has_touch=True, user_agent=None), ViewportConfig(name='tablet_portrait', width=768, height=1024, device_scale_factor=2.0, is_mobile=True, has_touch=True, user_agent=None), ViewportConfig(name='desktop', width=1440, height=900, device_scale_factor=1.0, is_mobile=False, has_touch=False, user_agent=None), ViewportConfig(name='desktop_large', width=1920, height=1080, device_scale_factor=1.0, is_mobile=False, has_touch=False, user_agent=None)]¶
- __init__(config_path: str | None = None)[source]¶
Initialize configuration.
- Parameters:
config_path (str, optional) – Path to YAML configuration file
- load_from_file(config_path: str) None[source]¶
Load configuration from YAML file.
- Parameters:
config_path (str) – Path to YAML configuration file
- save_to_file(config_path: str) None[source]¶
Save current configuration to YAML file.
- Parameters:
config_path (str) – Path where to save the configuration file
- get_output_path(subdir: str) Path[source]¶
Get path for output subdirectory.
- Parameters:
subdir (str) – Subdirectory name (screenshots, results, reports)
- Returns:
Full path to the subdirectory
- Return type:
Path
- get_viewport_by_name(name: str) ViewportConfig | None[source]¶
Get viewport configuration by name.
- Parameters:
name (str) – Viewport name
- Returns:
Viewport configuration if found
- Return type:
ViewportConfig, optional
- add_viewport(viewport: ViewportConfig) None[source]¶
Add a new viewport configuration.
- Parameters:
viewport (ViewportConfig) – Viewport configuration to add
Configuration Data Classes¶
- class layoutlens.config.ViewportConfig(name: str, width: int, height: int, device_scale_factor: float = 1.0, is_mobile: bool = False, has_touch: bool = False, user_agent: str | None = None)[source]¶
Bases:
objectViewport configuration for testing.
- class layoutlens.config.LLMConfig(provider: str = 'openai', model: str = 'gpt-4o-mini', api_key: str | None = None, api_key_env: str = 'OPENAI_API_KEY', max_retries: int = 3, timeout: int = 60, temperature: float = 0.1, custom_params: dict[str, ~typing.Any] = <factory>)[source]¶
Bases:
objectConfiguration for Language Model providers.
- class layoutlens.config.TestConfig(auto_generate_queries: bool = True, focus_areas: list[str] = <factory>, parallel_execution: bool = False, max_workers: int = 4, continue_on_error: bool = True, save_screenshots: bool = True, save_detailed_results: bool = True)[source]¶
Bases:
objectConfiguration for test execution.
- class layoutlens.config.OutputConfig(base_dir: str = 'layoutlens_output', screenshots_dir: str = 'screenshots', results_dir: str = 'results', reports_dir: str = 'reports', format: str = 'json', include_metadata: bool = True, compress_results: bool = False)[source]¶
Bases:
objectConfiguration for output and reporting.