Files
semantic-kernel/python/semantic_kernel
Evan Mattson 2c20c5e26f Python: lazy-loading mechanism for agent dependencies (#11180)
### Motivation and Context

Consolidated agent imports initially caused issues by eagerly loading
all submodules, which forced users to install every optional dependency
-- even if only one agent was needed. This PR introduces a lazy-loading
mechanism via `__getattr__` in the top-level `__init__.py` to defer
imports until actually accessed. Additionally, a corresponding`
__init__.pyi` type stub file is provided to restore full IDE
autocompletion and type hints without compromising runtime behavior.

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

### Description

Lazy load agent dependencies.

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [X] The code builds clean without any errors or warnings
- [X] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [X] All unit tests pass, and I have added new tests where possible
- [X] I didn't break anyone 😄
2025-03-25 16:54:52 +09:00
..
2024-10-10 22:33:42 +00:00
2024-03-28 15:10:28 +00:00