Initialize the configuration. Returns: Config: Configuration object
()
| 362 | |
| 363 | |
| 364 | def initialize_config() -> Config: |
| 365 | """ |
| 366 | Initialize the configuration. |
| 367 | |
| 368 | Returns: |
| 369 | Config: Configuration object |
| 370 | """ |
| 371 | try: |
| 372 | # First, extract and remove Gemini clients related environment variables |
| 373 | env_clients_overrides = extract_gemini_clients_env() |
| 374 | # Extract and remove Gemini models related environment variables |
| 375 | env_models_overrides = extract_gemini_models_env() |
| 376 | |
| 377 | # Then, initialize Config with pydantic_settings |
| 378 | config = Config() # type: ignore |
| 379 | |
| 380 | # Synthesize clients |
| 381 | config.gemini.clients = _merge_clients_with_env( |
| 382 | config.gemini.clients, env_clients_overrides |
| 383 | ) |
| 384 | |
| 385 | # Synthesize models |
| 386 | config.gemini.models = _merge_models_with_env(config.gemini.models, env_models_overrides) |
| 387 | |
| 388 | return config |
| 389 | except ValidationError as e: |
| 390 | logger.error(f"Configuration validation failed: {e!s}") |
| 391 | sys.exit(1) |
no test coverage detected