nvidia-nat 1.3.0a20250910__py3-none-any.whl → 1.4.0a20251112__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. nat/agent/base.py +13 -8
  2. nat/agent/prompt_optimizer/prompt.py +68 -0
  3. nat/agent/prompt_optimizer/register.py +149 -0
  4. nat/agent/react_agent/agent.py +6 -5
  5. nat/agent/react_agent/register.py +49 -39
  6. nat/agent/reasoning_agent/reasoning_agent.py +17 -15
  7. nat/agent/register.py +2 -0
  8. nat/agent/responses_api_agent/__init__.py +14 -0
  9. nat/agent/responses_api_agent/register.py +126 -0
  10. nat/agent/rewoo_agent/agent.py +304 -117
  11. nat/agent/rewoo_agent/prompt.py +19 -22
  12. nat/agent/rewoo_agent/register.py +51 -38
  13. nat/agent/tool_calling_agent/agent.py +75 -17
  14. nat/agent/tool_calling_agent/register.py +46 -23
  15. nat/authentication/api_key/api_key_auth_provider.py +6 -11
  16. nat/authentication/api_key/api_key_auth_provider_config.py +8 -5
  17. nat/authentication/credential_validator/__init__.py +14 -0
  18. nat/authentication/credential_validator/bearer_token_validator.py +557 -0
  19. nat/authentication/http_basic_auth/http_basic_auth_provider.py +1 -1
  20. nat/authentication/interfaces.py +5 -2
  21. nat/authentication/oauth2/oauth2_auth_code_flow_provider.py +69 -36
  22. nat/authentication/oauth2/oauth2_auth_code_flow_provider_config.py +2 -1
  23. nat/authentication/oauth2/oauth2_resource_server_config.py +125 -0
  24. nat/builder/builder.py +55 -23
  25. nat/builder/component_utils.py +9 -5
  26. nat/builder/context.py +54 -15
  27. nat/builder/eval_builder.py +14 -9
  28. nat/builder/framework_enum.py +1 -0
  29. nat/builder/front_end.py +1 -1
  30. nat/builder/function.py +370 -0
  31. nat/builder/function_info.py +1 -1
  32. nat/builder/intermediate_step_manager.py +38 -2
  33. nat/builder/workflow.py +5 -0
  34. nat/builder/workflow_builder.py +306 -54
  35. nat/cli/cli_utils/config_override.py +1 -1
  36. nat/cli/commands/info/info.py +16 -6
  37. nat/cli/commands/mcp/__init__.py +14 -0
  38. nat/cli/commands/mcp/mcp.py +986 -0
  39. nat/cli/commands/optimize.py +90 -0
  40. nat/cli/commands/start.py +1 -1
  41. nat/cli/commands/workflow/templates/config.yml.j2 +14 -13
  42. nat/cli/commands/workflow/templates/register.py.j2 +2 -2
  43. nat/cli/commands/workflow/templates/workflow.py.j2 +35 -21
  44. nat/cli/commands/workflow/workflow_commands.py +60 -18
  45. nat/cli/entrypoint.py +15 -11
  46. nat/cli/main.py +3 -0
  47. nat/cli/register_workflow.py +38 -4
  48. nat/cli/type_registry.py +72 -1
  49. nat/control_flow/__init__.py +0 -0
  50. nat/control_flow/register.py +20 -0
  51. nat/control_flow/router_agent/__init__.py +0 -0
  52. nat/control_flow/router_agent/agent.py +329 -0
  53. nat/control_flow/router_agent/prompt.py +48 -0
  54. nat/control_flow/router_agent/register.py +91 -0
  55. nat/control_flow/sequential_executor.py +166 -0
  56. nat/data_models/agent.py +34 -0
  57. nat/data_models/api_server.py +199 -69
  58. nat/data_models/authentication.py +23 -9
  59. nat/data_models/common.py +47 -0
  60. nat/data_models/component.py +2 -0
  61. nat/data_models/component_ref.py +11 -0
  62. nat/data_models/config.py +41 -17
  63. nat/data_models/dataset_handler.py +4 -3
  64. nat/data_models/function.py +34 -0
  65. nat/data_models/function_dependencies.py +8 -0
  66. nat/data_models/intermediate_step.py +9 -1
  67. nat/data_models/llm.py +15 -1
  68. nat/data_models/openai_mcp.py +46 -0
  69. nat/data_models/optimizable.py +208 -0
  70. nat/data_models/optimizer.py +161 -0
  71. nat/data_models/span.py +41 -3
  72. nat/data_models/thinking_mixin.py +2 -2
  73. nat/embedder/azure_openai_embedder.py +2 -1
  74. nat/embedder/nim_embedder.py +3 -2
  75. nat/embedder/openai_embedder.py +3 -2
  76. nat/eval/config.py +1 -1
  77. nat/eval/dataset_handler/dataset_downloader.py +3 -2
  78. nat/eval/dataset_handler/dataset_filter.py +34 -2
  79. nat/eval/evaluate.py +10 -3
  80. nat/eval/evaluator/base_evaluator.py +1 -1
  81. nat/eval/rag_evaluator/evaluate.py +7 -4
  82. nat/eval/register.py +4 -0
  83. nat/eval/runtime_evaluator/__init__.py +14 -0
  84. nat/eval/runtime_evaluator/evaluate.py +123 -0
  85. nat/eval/runtime_evaluator/register.py +100 -0
  86. nat/eval/swe_bench_evaluator/evaluate.py +1 -1
  87. nat/eval/trajectory_evaluator/register.py +1 -1
  88. nat/eval/tunable_rag_evaluator/evaluate.py +1 -1
  89. nat/eval/usage_stats.py +2 -0
  90. nat/eval/utils/output_uploader.py +3 -2
  91. nat/eval/utils/weave_eval.py +17 -3
  92. nat/experimental/decorators/experimental_warning_decorator.py +27 -7
  93. nat/experimental/test_time_compute/functions/execute_score_select_function.py +1 -1
  94. nat/experimental/test_time_compute/functions/plan_select_execute_function.py +7 -3
  95. nat/experimental/test_time_compute/functions/ttc_tool_orchestration_function.py +1 -1
  96. nat/experimental/test_time_compute/functions/ttc_tool_wrapper_function.py +3 -3
  97. nat/experimental/test_time_compute/models/strategy_base.py +2 -2
  98. nat/experimental/test_time_compute/selection/llm_based_output_merging_selector.py +1 -1
  99. nat/front_ends/console/authentication_flow_handler.py +82 -30
  100. nat/front_ends/console/console_front_end_plugin.py +19 -7
  101. nat/front_ends/fastapi/auth_flow_handlers/http_flow_handler.py +1 -1
  102. nat/front_ends/fastapi/auth_flow_handlers/websocket_flow_handler.py +52 -17
  103. nat/front_ends/fastapi/dask_client_mixin.py +65 -0
  104. nat/front_ends/fastapi/fastapi_front_end_config.py +25 -3
  105. nat/front_ends/fastapi/fastapi_front_end_plugin.py +140 -3
  106. nat/front_ends/fastapi/fastapi_front_end_plugin_worker.py +445 -265
  107. nat/front_ends/fastapi/job_store.py +518 -99
  108. nat/front_ends/fastapi/main.py +11 -19
  109. nat/front_ends/fastapi/message_handler.py +69 -44
  110. nat/front_ends/fastapi/message_validator.py +8 -7
  111. nat/front_ends/fastapi/utils.py +57 -0
  112. nat/front_ends/mcp/introspection_token_verifier.py +73 -0
  113. nat/front_ends/mcp/mcp_front_end_config.py +71 -3
  114. nat/front_ends/mcp/mcp_front_end_plugin.py +85 -21
  115. nat/front_ends/mcp/mcp_front_end_plugin_worker.py +248 -29
  116. nat/front_ends/mcp/memory_profiler.py +320 -0
  117. nat/front_ends/mcp/tool_converter.py +78 -25
  118. nat/front_ends/simple_base/simple_front_end_plugin_base.py +3 -1
  119. nat/llm/aws_bedrock_llm.py +21 -8
  120. nat/llm/azure_openai_llm.py +14 -5
  121. nat/llm/litellm_llm.py +80 -0
  122. nat/llm/nim_llm.py +23 -9
  123. nat/llm/openai_llm.py +19 -7
  124. nat/llm/register.py +4 -0
  125. nat/llm/utils/thinking.py +1 -1
  126. nat/observability/exporter/base_exporter.py +1 -1
  127. nat/observability/exporter/processing_exporter.py +29 -55
  128. nat/observability/exporter/span_exporter.py +43 -15
  129. nat/observability/exporter_manager.py +2 -2
  130. nat/observability/mixin/redaction_config_mixin.py +5 -4
  131. nat/observability/mixin/tagging_config_mixin.py +26 -14
  132. nat/observability/mixin/type_introspection_mixin.py +420 -107
  133. nat/observability/processor/batching_processor.py +1 -1
  134. nat/observability/processor/processor.py +3 -0
  135. nat/observability/processor/redaction/__init__.py +24 -0
  136. nat/observability/processor/redaction/contextual_redaction_processor.py +125 -0
  137. nat/observability/processor/redaction/contextual_span_redaction_processor.py +66 -0
  138. nat/observability/processor/redaction/redaction_processor.py +177 -0
  139. nat/observability/processor/redaction/span_header_redaction_processor.py +92 -0
  140. nat/observability/processor/span_tagging_processor.py +21 -14
  141. nat/observability/register.py +16 -0
  142. nat/profiler/callbacks/langchain_callback_handler.py +32 -7
  143. nat/profiler/callbacks/llama_index_callback_handler.py +36 -2
  144. nat/profiler/callbacks/token_usage_base_model.py +2 -0
  145. nat/profiler/decorators/framework_wrapper.py +61 -9
  146. nat/profiler/decorators/function_tracking.py +35 -3
  147. nat/profiler/forecasting/models/linear_model.py +1 -1
  148. nat/profiler/forecasting/models/random_forest_regressor.py +1 -1
  149. nat/profiler/inference_optimization/bottleneck_analysis/nested_stack_analysis.py +1 -1
  150. nat/profiler/inference_optimization/experimental/prefix_span_analysis.py +1 -1
  151. nat/profiler/parameter_optimization/__init__.py +0 -0
  152. nat/profiler/parameter_optimization/optimizable_utils.py +93 -0
  153. nat/profiler/parameter_optimization/optimizer_runtime.py +67 -0
  154. nat/profiler/parameter_optimization/parameter_optimizer.py +189 -0
  155. nat/profiler/parameter_optimization/parameter_selection.py +107 -0
  156. nat/profiler/parameter_optimization/pareto_visualizer.py +460 -0
  157. nat/profiler/parameter_optimization/prompt_optimizer.py +384 -0
  158. nat/profiler/parameter_optimization/update_helpers.py +66 -0
  159. nat/profiler/utils.py +3 -1
  160. nat/registry_handlers/pypi/register_pypi.py +5 -3
  161. nat/registry_handlers/rest/register_rest.py +5 -3
  162. nat/retriever/milvus/retriever.py +1 -1
  163. nat/retriever/nemo_retriever/register.py +2 -1
  164. nat/runtime/loader.py +1 -1
  165. nat/runtime/runner.py +111 -6
  166. nat/runtime/session.py +49 -3
  167. nat/settings/global_settings.py +2 -2
  168. nat/tool/chat_completion.py +4 -1
  169. nat/tool/code_execution/code_sandbox.py +3 -6
  170. nat/tool/code_execution/local_sandbox/Dockerfile.sandbox +19 -32
  171. nat/tool/code_execution/local_sandbox/local_sandbox_server.py +6 -1
  172. nat/tool/code_execution/local_sandbox/sandbox.requirements.txt +2 -0
  173. nat/tool/code_execution/local_sandbox/start_local_sandbox.sh +10 -4
  174. nat/tool/datetime_tools.py +1 -1
  175. nat/tool/github_tools.py +450 -0
  176. nat/tool/memory_tools/add_memory_tool.py +3 -3
  177. nat/tool/memory_tools/delete_memory_tool.py +3 -4
  178. nat/tool/memory_tools/get_memory_tool.py +4 -4
  179. nat/tool/register.py +2 -7
  180. nat/tool/server_tools.py +15 -2
  181. nat/utils/__init__.py +76 -0
  182. nat/utils/callable_utils.py +70 -0
  183. nat/utils/data_models/schema_validator.py +1 -1
  184. nat/utils/decorators.py +210 -0
  185. nat/utils/exception_handlers/automatic_retries.py +278 -72
  186. nat/utils/io/yaml_tools.py +73 -3
  187. nat/utils/log_levels.py +25 -0
  188. nat/utils/responses_api.py +26 -0
  189. nat/utils/string_utils.py +16 -0
  190. nat/utils/type_converter.py +12 -3
  191. nat/utils/type_utils.py +6 -2
  192. nvidia_nat-1.4.0a20251112.dist-info/METADATA +197 -0
  193. {nvidia_nat-1.3.0a20250910.dist-info → nvidia_nat-1.4.0a20251112.dist-info}/RECORD +199 -165
  194. {nvidia_nat-1.3.0a20250910.dist-info → nvidia_nat-1.4.0a20251112.dist-info}/entry_points.txt +1 -0
  195. nat/cli/commands/info/list_mcp.py +0 -461
  196. nat/data_models/temperature_mixin.py +0 -43
  197. nat/data_models/top_p_mixin.py +0 -43
  198. nat/observability/processor/header_redaction_processor.py +0 -123
  199. nat/observability/processor/redaction_processor.py +0 -77
  200. nat/tool/code_execution/test_code_execution_sandbox.py +0 -414
  201. nat/tool/github_tools/create_github_commit.py +0 -133
  202. nat/tool/github_tools/create_github_issue.py +0 -87
  203. nat/tool/github_tools/create_github_pr.py +0 -106
  204. nat/tool/github_tools/get_github_file.py +0 -106
  205. nat/tool/github_tools/get_github_issue.py +0 -166
  206. nat/tool/github_tools/get_github_pr.py +0 -256
  207. nat/tool/github_tools/update_github_issue.py +0 -100
  208. nvidia_nat-1.3.0a20250910.dist-info/METADATA +0 -373
  209. /nat/{tool/github_tools → agent/prompt_optimizer}/__init__.py +0 -0
  210. {nvidia_nat-1.3.0a20250910.dist-info → nvidia_nat-1.4.0a20251112.dist-info}/WHEEL +0 -0
  211. {nvidia_nat-1.3.0a20250910.dist-info → nvidia_nat-1.4.0a20251112.dist-info}/licenses/LICENSE-3rd-party.txt +0 -0
  212. {nvidia_nat-1.3.0a20250910.dist-info → nvidia_nat-1.4.0a20251112.dist-info}/licenses/LICENSE.md +0 -0
  213. {nvidia_nat-1.3.0a20250910.dist-info → nvidia_nat-1.4.0a20251112.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,70 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ import inspect
17
+ from collections.abc import Callable
18
+ from typing import Any
19
+
20
+
21
+ async def ainvoke_any(func: Callable[..., Any], *args: Any, **kwargs: Any) -> Any:
22
+ """Execute any type of callable and return the result.
23
+
24
+ Handles synchronous functions, asynchronous functions, generators,
25
+ and async generators uniformly, returning the final result value.
26
+
27
+ Args:
28
+ func (Callable[..., Any]): The function to execute (sync/async function, generator, etc.)
29
+
30
+ Returns:
31
+ Any: The result of executing the callable
32
+ """
33
+ # Execute the function
34
+ result_value = func(*args, **kwargs)
35
+
36
+ # Handle different return types
37
+ if inspect.iscoroutine(result_value):
38
+ # Async function - await the coroutine
39
+ return await result_value
40
+
41
+ if inspect.isgenerator(result_value):
42
+ # Sync generator - consume until StopIteration and get return value
43
+ try:
44
+ while True:
45
+ next(result_value)
46
+ except StopIteration as e:
47
+ # Return the generator's return value, or None if not provided
48
+ return e.value
49
+
50
+ if inspect.isasyncgen(result_value):
51
+ # Async generator - consume all values and return the last one
52
+ last_value = None
53
+ async for value in result_value:
54
+ last_value = value
55
+ return last_value
56
+
57
+ # Direct value from sync function (most common case)
58
+ return result_value
59
+
60
+
61
+ def is_async_callable(func: Callable[..., Any]) -> bool:
62
+ """Check if a function is async (coroutine function or async generator function).
63
+
64
+ Args:
65
+ func (Callable[..., Any]): The function to check
66
+
67
+ Returns:
68
+ bool: True if the function is async, False otherwise
69
+ """
70
+ return inspect.iscoroutinefunction(func) or inspect.isasyncgenfunction(func)
@@ -52,7 +52,7 @@ def validate_yaml(ctx, param, value):
52
52
  if value is None:
53
53
  return None
54
54
 
55
- with open(value, 'r', encoding="utf-8") as f:
55
+ with open(value, encoding="utf-8") as f:
56
56
  yaml.safe_load(f)
57
57
 
58
58
  return value
@@ -0,0 +1,210 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ """Deprecation utilities.
16
+
17
+ This module provides helpers to standardize deprecation signaling across the
18
+ codebase:
19
+
20
+ - ``issue_deprecation_warning``: Builds and emits a single deprecation message
21
+ per function using the standard logging pipeline.
22
+ - ``deprecated``: A decorator that wraps sync/async functions and generators to
23
+ log a one-time deprecation message upon first use. It supports optional
24
+ metadata, a planned removal version, a suggested replacement, and an
25
+ optional feature name label.
26
+
27
+ Messages are emitted via ``logging.getLogger(__name__).warning`` (not
28
+ ``warnings.warn``) so they appear in normal application logs and respect global
29
+ logging configuration. Each unique function logs at most once per process.
30
+ """
31
+
32
+ import functools
33
+ import inspect
34
+ import logging
35
+ from collections.abc import AsyncGenerator
36
+ from collections.abc import Callable
37
+ from collections.abc import Generator
38
+ from typing import Any
39
+ from typing import TypeVar
40
+ from typing import overload
41
+
42
+ logger = logging.getLogger(__name__)
43
+
44
+ _warning_issued = set()
45
+
46
+ # Type variables for overloads
47
+ F = TypeVar('F', bound=Callable[..., Any])
48
+
49
+
50
+ def issue_deprecation_warning(function_name: str,
51
+ removal_version: str | None = None,
52
+ replacement: str | None = None,
53
+ reason: str | None = None,
54
+ feature_name: str | None = None,
55
+ metadata: dict[str, Any] | None = None) -> None:
56
+ """
57
+ Log a deprecation warning message for the function.
58
+
59
+ A warning is emitted only once per function. When a ``metadata`` dict
60
+ is supplied, it is appended to the log entry to provide extra context
61
+ (e.g., version, author, feature flag).
62
+
63
+ Args:
64
+ function_name: The name of the deprecated function
65
+ removal_version: The version when the function will be removed
66
+ replacement: What to use instead of this function
67
+ reason: Why the function is being deprecated
68
+ feature_name: Optional name of the feature that is deprecated
69
+ metadata: Optional dictionary of metadata to log with the warning
70
+ """
71
+ if function_name not in _warning_issued:
72
+ # Build the deprecation message
73
+ if feature_name:
74
+ warning_message = f"{feature_name} is deprecated"
75
+ else:
76
+ warning_message = f"Function {function_name} is deprecated"
77
+
78
+ if removal_version:
79
+ warning_message += f" and will be removed in version {removal_version}"
80
+ else:
81
+ warning_message += " and will be removed in a future release"
82
+
83
+ warning_message += "."
84
+
85
+ if reason:
86
+ warning_message += f" Reason: {reason}."
87
+
88
+ if replacement:
89
+ warning_message += f" Use '{replacement}' instead."
90
+
91
+ if metadata:
92
+ warning_message += f" | Metadata: {metadata}"
93
+
94
+ # Issue warning and save function name to avoid duplicate warnings
95
+ logger.warning(warning_message)
96
+ _warning_issued.add(function_name)
97
+
98
+
99
+ # Overloads for different function types
100
+ @overload
101
+ def deprecated(func: F,
102
+ *,
103
+ removal_version: str | None = None,
104
+ replacement: str | None = None,
105
+ reason: str | None = None,
106
+ feature_name: str | None = None,
107
+ metadata: dict[str, Any] | None = None) -> F:
108
+ """Overload for direct decorator usage (when called without parentheses)."""
109
+ ...
110
+
111
+
112
+ @overload
113
+ def deprecated(*,
114
+ removal_version: str | None = None,
115
+ replacement: str | None = None,
116
+ reason: str | None = None,
117
+ feature_name: str | None = None,
118
+ metadata: dict[str, Any] | None = None) -> Callable[[F], F]:
119
+ """Overload for decorator factory usage (when called with parentheses)."""
120
+ ...
121
+
122
+
123
+ def deprecated(func: Any = None,
124
+ *,
125
+ removal_version: str | None = None,
126
+ replacement: str | None = None,
127
+ reason: str | None = None,
128
+ feature_name: str | None = None,
129
+ metadata: dict[str, Any] | None = None) -> Any:
130
+ """
131
+ Decorator that can wrap any type of function (sync, async, generator,
132
+ async generator) and logs a deprecation warning.
133
+
134
+ Args:
135
+ func: The function to be decorated.
136
+ removal_version: The version when the function will be removed
137
+ replacement: What to use instead of this function
138
+ reason: Why the function is being deprecated
139
+ feature_name: Optional name of the feature that is deprecated. If provided, the warning will be
140
+ prefixed with "The <feature_name> feature is deprecated".
141
+ metadata: Optional dictionary of metadata to log with the warning. This can include information
142
+ like version, author, etc. If provided, the metadata will be
143
+ logged alongside the deprecation warning.
144
+ """
145
+ function_name: str = f"{func.__module__}.{func.__qualname__}" if func else "<unknown_function>"
146
+
147
+ # If called as @deprecated(...) but not immediately passed a function
148
+ if func is None:
149
+
150
+ def decorator_wrapper(actual_func):
151
+ return deprecated(actual_func,
152
+ removal_version=removal_version,
153
+ replacement=replacement,
154
+ reason=reason,
155
+ feature_name=feature_name,
156
+ metadata=metadata)
157
+
158
+ return decorator_wrapper
159
+
160
+ # --- Validate metadata ---
161
+ if metadata is not None:
162
+ if not isinstance(metadata, dict):
163
+ raise TypeError("metadata must be a dict[str, Any].")
164
+ if any(not isinstance(k, str) for k in metadata.keys()):
165
+ raise TypeError("All metadata keys must be strings.")
166
+
167
+ # --- Now detect the function type and wrap accordingly ---
168
+ if inspect.isasyncgenfunction(func):
169
+ # ---------------------
170
+ # ASYNC GENERATOR
171
+ # ---------------------
172
+
173
+ @functools.wraps(func)
174
+ async def async_gen_wrapper(*args, **kwargs) -> AsyncGenerator[Any, Any]:
175
+ issue_deprecation_warning(function_name, removal_version, replacement, reason, feature_name, metadata)
176
+ async for item in func(*args, **kwargs):
177
+ yield item # yield the original item
178
+
179
+ return async_gen_wrapper
180
+
181
+ if inspect.iscoroutinefunction(func):
182
+ # ---------------------
183
+ # ASYNC FUNCTION
184
+ # ---------------------
185
+ @functools.wraps(func)
186
+ async def async_wrapper(*args, **kwargs) -> Any:
187
+ issue_deprecation_warning(function_name, removal_version, replacement, reason, feature_name, metadata)
188
+ result = await func(*args, **kwargs)
189
+ return result
190
+
191
+ return async_wrapper
192
+
193
+ if inspect.isgeneratorfunction(func):
194
+ # ---------------------
195
+ # SYNC GENERATOR
196
+ # ---------------------
197
+ @functools.wraps(func)
198
+ def sync_gen_wrapper(*args, **kwargs) -> Generator[Any, Any, Any]:
199
+ issue_deprecation_warning(function_name, removal_version, replacement, reason, feature_name, metadata)
200
+ yield from func(*args, **kwargs) # yield the original item
201
+
202
+ return sync_gen_wrapper
203
+
204
+ @functools.wraps(func)
205
+ def sync_wrapper(*args, **kwargs) -> Any:
206
+ issue_deprecation_warning(function_name, removal_version, replacement, reason, feature_name, metadata)
207
+ result = func(*args, **kwargs)
208
+ return result
209
+
210
+ return sync_wrapper