Skip to content

Commit 174bdab

Browse files
authoredFeb 27, 2025
Python: Introduce feature decorator to allow for experimental and release candidate decorator usage (microsoft#10691)
### Motivation and Context <!-- 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. --> This change is required to improve the flexibility and maintainability of our feature annotation system. Previously, separate decorators (e.g., `experimental_function` and `experimental_class`) were used to mark experimental features, resulting in code duplication and limiting our ability to handle additional feature stages. As our SDK evolves, we need a unified approach that can support multiple stages—such as experimental, release candidate, and future states—while also allowing version information for release candidate features to be centrally managed. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> This PR refactors our feature decorators by introducing a unified `stage` decorator that updates the docstring and attaches metadata for both functions and classes. Two convenience decorators, `experimental` and `release_candidate`, are built on top of `stage`: - The `experimental` decorator marks features as experimental and sets an `is_experimental` attribute. - The `release_candidate` decorator supports multiple usage patterns (with or without parentheses and with an optional version parameter) to mark features as release candidate and sets an `is_release_candidate` attribute. This unified approach reduces duplication, simplifies the codebase, and lays the groundwork for easily extending feature stages in the future. This decorator supports the following usage patterns: - `@experimental` (for both classes and functions) - `@release_candidate` (no parentheses) - `@release_candidate()` (empty parentheses) - `@release_candidate("1.21.3-rc1")` (positional version) - `@release_candidate(version="1.21.3-rc1")` (keyword version) ### 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 😄
1 parent 60df17d commit 174bdab

File tree

222 files changed

+778
-554
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

222 files changed

+778
-554
lines changed
 

‎python/samples/demos/document_generator/custom_selection_strategy.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
)
1313
from semantic_kernel.connectors.ai.open_ai.services.open_ai_chat_completion import OpenAIChatCompletion
1414
from semantic_kernel.contents.chat_history import ChatHistory
15-
from semantic_kernel.utils.experimental_decorator import experimental_class
15+
from semantic_kernel.utils.feature_stage_decorator import experimental
1616

1717
if TYPE_CHECKING:
1818
from semantic_kernel.agents import Agent
@@ -21,7 +21,7 @@
2121
NEWLINE = "\n"
2222

2323

24-
@experimental_class
24+
@experimental
2525
class CustomSelectionStrategy(SelectionStrategy):
2626
"""A selection strategy that selects the next agent intelligently."""
2727

‎python/semantic_kernel/__init__.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33
from semantic_kernel.kernel import Kernel
44

55
__version__ = "1.21.3"
6-
__all__ = ["Kernel", "__version__"]
6+
7+
DEFAULT_RC_VERSION = f"{__version__}-rc1"
8+
9+
__all__ = ["DEFAULT_RC_VERSION", "Kernel", "__version__"]

0 commit comments

Comments
 (0)
Please sign in to comment.