nvidia-nat-semantic-kernel 1.2.0a20250813__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.

Potentially problematic release.


This version of nvidia-nat-semantic-kernel might be problematic. Click here for more details.

nat/meta/pypi.md ADDED
@@ -0,0 +1,23 @@
1
+ <!--
2
+ SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3
+ SPDX-License-Identifier: Apache-2.0
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ -->
17
+
18
+ ![NVIDIA NeMo Agent Toolkit](https://media.githubusercontent.com/media/NVIDIA/NeMo-Agent-Toolkit/refs/heads/main/docs/source/_static/aiqtoolkit_banner.png "NeMo Agent toolkit banner image")
19
+
20
+ # NVIDIA NeMo Agent Toolkit Subpackage
21
+ This is a subpackage for Semantic-Kernel integration in NeMo Agent toolkit.
22
+
23
+ For more information about the NVIDIA NeMo Agent toolkit, please visit the [NeMo Agent toolkit GitHub Repo](https://github.com/NVIDIA/NeMo-Agent-Toolkit).
File without changes
@@ -0,0 +1,41 @@
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
+ from nat.builder.builder import Builder
17
+ from nat.builder.framework_enum import LLMFrameworkEnum
18
+ from nat.cli.register_workflow import register_llm_client
19
+ from nat.data_models.retry_mixin import RetryMixin
20
+ from nat.llm.openai_llm import OpenAIModelConfig
21
+ from nat.utils.exception_handlers.automatic_retries import patch_with_retry
22
+
23
+
24
+ @register_llm_client(config_type=OpenAIModelConfig, wrapper_type=LLMFrameworkEnum.SEMANTIC_KERNEL)
25
+ async def openai_semantic_kernel(llm_config: OpenAIModelConfig, builder: Builder):
26
+
27
+ from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion
28
+
29
+ config_obj = {
30
+ **llm_config.model_dump(exclude={"type"}, by_alias=True),
31
+ }
32
+
33
+ llm = OpenAIChatCompletion(ai_model_id=config_obj.get("model"))
34
+
35
+ if isinstance(llm_config, RetryMixin):
36
+ llm = patch_with_retry(llm,
37
+ retries=llm_config.num_retries,
38
+ retry_codes=llm_config.retry_on_status_codes,
39
+ retry_on_messages=llm_config.retry_on_errors)
40
+
41
+ yield llm
@@ -0,0 +1,23 @@
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
+ # pylint: disable=unused-import
17
+ # flake8: noqa
18
+ # isort:skip_file
19
+
20
+ # Import any providers which need to be automatically registered here
21
+
22
+ from . import llm
23
+ from . import tool_wrapper
@@ -0,0 +1,163 @@
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 logging
17
+ import types
18
+ from collections.abc import Callable
19
+ from dataclasses import is_dataclass
20
+ from typing import Any
21
+ from typing import Union
22
+ from typing import get_args
23
+ from typing import get_origin
24
+
25
+ from pydantic import BaseModel
26
+
27
+ from nat.builder.builder import Builder
28
+ from nat.builder.framework_enum import LLMFrameworkEnum
29
+ from nat.builder.function import Function
30
+ from nat.cli.register_workflow import register_tool_wrapper
31
+
32
+ logger = logging.getLogger(__name__)
33
+
34
+ # pylint: disable=consider-alternative-union-syntax)
35
+
36
+
37
+ def get_type_info(field_type):
38
+ origin = get_origin(field_type)
39
+ if origin is None:
40
+ # It’s a simple type
41
+ return getattr(field_type, "__name__", str(field_type))
42
+
43
+ # Handle Union types specially
44
+ if origin in (Union, types.UnionType):
45
+ # Pick the first type that isn’t NoneType
46
+ non_none = [arg for arg in get_args(field_type) if arg is not type(None)]
47
+ if non_none:
48
+ return getattr(non_none[0], "__name__", str(non_none[0]))
49
+
50
+ return 'str' # fallback if union is only str (unlikely)
51
+
52
+ # For other generics, capture both the origin and its parameters
53
+ return getattr(origin, "__name__", str(origin))
54
+
55
+
56
+ def resolve_type(t):
57
+ origin = get_origin(t)
58
+ if origin in (Union, types.UnionType):
59
+ # Pick the first type that isn’t NoneType
60
+ for arg in get_args(t):
61
+ if arg is not None:
62
+ return arg
63
+
64
+ return t # fallback if union is only NoneType (unlikely)
65
+ return t
66
+
67
+
68
+ @register_tool_wrapper(wrapper_type=LLMFrameworkEnum.SEMANTIC_KERNEL)
69
+ def semantic_kernel_tool_wrapper(name: str, fn: Function, builder: Builder):
70
+
71
+ async def callable_ainvoke(*args, **kwargs):
72
+ return await fn.acall_invoke(*args, **kwargs)
73
+
74
+ async def callable_astream(*args, **kwargs):
75
+ async for item in fn.acall_stream(*args, **kwargs):
76
+ yield item
77
+
78
+ def nat_kernel_function(
79
+ func: Callable[..., object] | None = None,
80
+ aiq_function: Function | None = None,
81
+ name: str | None = None,
82
+ description: str | None = None,
83
+ ) -> Callable[..., Any]:
84
+ """
85
+ Modified version of Semantic Kernel's kernel_function decorator.
86
+
87
+ Uses `aiq` Function properties instead of doing type inference on the function's inner
88
+ """
89
+
90
+ def decorator(func: Callable[..., object]) -> Callable[..., object]:
91
+ """The actual decorator function."""
92
+ setattr(func, "__kernel_function__", True)
93
+ setattr(func, "__kernel_function_description__", description or aiq_function.description)
94
+ setattr(func, "__kernel_function_name__", name or aiq_function.config.type)
95
+
96
+ # Always defer to single output schema, if present, for now
97
+ # No need to check streaming output is present given one of the two is always present
98
+ has_single = aiq_function.has_single_output
99
+ has_streaming = aiq_function.has_streaming_output
100
+ output_schema = aiq_function.single_output_schema if has_single else aiq_function.streaming_output_schema
101
+ setattr(func, "__kernel_function_streaming__", not aiq_function.has_single_output if has_single else True)
102
+
103
+ if has_single and has_streaming:
104
+ logger.warning("Function has both single and streaming output schemas. "
105
+ "Defaulting to single output schema.")
106
+
107
+ input_annotations = []
108
+ for arg_name, annotation in aiq_function.input_schema.model_fields.items():
109
+ type_obj = resolve_type(annotation.annotation)
110
+ include_in_choices = True
111
+ if isinstance(type_obj, type) and (issubclass(type_obj, BaseModel) or is_dataclass(type_obj)):
112
+ logger.warning(
113
+ "Nested non-native model detected in input schema for parameter: %s. "
114
+ "Setting include_in_function_choices to False.",
115
+ arg_name)
116
+ # Don't error out here
117
+ # Just instead avoid showing the tool to the model
118
+ include_in_choices = False
119
+ input_annotations.append({
120
+ "is_required": annotation.is_required(),
121
+ "name": arg_name,
122
+ "type_": get_type_info(annotation.annotation),
123
+ "type_object": type_obj,
124
+ "include_in_function_choices": include_in_choices
125
+ })
126
+
127
+ setattr(func, "__kernel_function_parameters__", input_annotations)
128
+
129
+ return_annotations = []
130
+ for arg_name, annotation in output_schema.model_fields.items():
131
+ type_obj = resolve_type(annotation.annotation)
132
+ include_in_choices = True
133
+ if isinstance(type_obj, type) and (issubclass(type_obj, BaseModel) or is_dataclass(type_obj)):
134
+ logger.warning(
135
+ "Nested non-native model detected in output schema for parameter: %s. "
136
+ "Setting include_in_function_choices to False.",
137
+ arg_name)
138
+ include_in_choices = False
139
+ return_annotations.append({
140
+ "is_required": annotation.is_required(),
141
+ "name": arg_name,
142
+ "type_": get_type_info(annotation.annotation),
143
+ "type_object": type_obj,
144
+ "include_in_function_choices": include_in_choices
145
+ })
146
+ return_annotation = return_annotations[0]
147
+
148
+ setattr(func, "__kernel_function_return_type__", return_annotation.get("type_", "None"))
149
+ setattr(func, "__kernel_function_return_type_object__", return_annotation.get("type_object", None))
150
+ setattr(func, "__kernel_function_return_description__", return_annotation.get("description", ""))
151
+ setattr(func, "__kernel_function_return_required__", return_annotation.get("is_required", False))
152
+ return func
153
+
154
+ if func:
155
+ return decorator(func)
156
+ return decorator
157
+
158
+ if fn.has_streaming_output and not fn.has_single_output:
159
+ kernel_func = nat_kernel_function(func=callable_astream, aiq_function=fn, name=name, description=fn.description)
160
+ else:
161
+ kernel_func = nat_kernel_function(func=callable_ainvoke, aiq_function=fn, name=name, description=fn.description)
162
+
163
+ return {name: kernel_func}
@@ -0,0 +1,34 @@
1
+ Metadata-Version: 2.4
2
+ Name: nvidia-nat-semantic-kernel
3
+ Version: 1.2.0a20250813
4
+ Summary: Subpackage for Semantic-Kernel integration in NeMo Agent toolkit
5
+ Keywords: ai,rag,agents
6
+ Classifier: Programming Language :: Python
7
+ Requires-Python: <3.13,>=3.11
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: nvidia-nat==v1.2.0a20250813
10
+ Requires-Dist: semantic-kernel~=1.24.0
11
+
12
+ <!--
13
+ SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
14
+ SPDX-License-Identifier: Apache-2.0
15
+
16
+ Licensed under the Apache License, Version 2.0 (the "License");
17
+ you may not use this file except in compliance with the License.
18
+ You may obtain a copy of the License at
19
+
20
+ http://www.apache.org/licenses/LICENSE-2.0
21
+
22
+ Unless required by applicable law or agreed to in writing, software
23
+ distributed under the License is distributed on an "AS IS" BASIS,
24
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25
+ See the License for the specific language governing permissions and
26
+ limitations under the License.
27
+ -->
28
+
29
+ ![NVIDIA NeMo Agent Toolkit](https://media.githubusercontent.com/media/NVIDIA/NeMo-Agent-Toolkit/refs/heads/main/docs/source/_static/aiqtoolkit_banner.png "NeMo Agent toolkit banner image")
30
+
31
+ # NVIDIA NeMo Agent Toolkit Subpackage
32
+ This is a subpackage for Semantic-Kernel integration in NeMo Agent toolkit.
33
+
34
+ For more information about the NVIDIA NeMo Agent toolkit, please visit the [NeMo Agent toolkit GitHub Repo](https://github.com/NVIDIA/NeMo-Agent-Toolkit).
@@ -0,0 +1,10 @@
1
+ nat/meta/pypi.md,sha256=Ki8bvrAo3d2iW7q6vTszp2AY2fapDP--el1wKuOtWcQ,1127
2
+ nat/plugins/semantic_kernel/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ nat/plugins/semantic_kernel/llm.py,sha256=C2ISvuCkz_YN0yOgyf1QJPtbJmX_1kgLpQumwpKfcOI,1744
4
+ nat/plugins/semantic_kernel/register.py,sha256=RKXyuaXy4ftA5IL2RrCofIBjpie_-2lP9YZoHAiyPU0,863
5
+ nat/plugins/semantic_kernel/tool_wrapper.py,sha256=reg19DFn6uc5S1RIYJPVOcm-k6uG7h3ao2Sxwj8U-e0,7175
6
+ nvidia_nat_semantic_kernel-1.2.0a20250813.dist-info/METADATA,sha256=zkJCtJW_ERDMpvmep1815csur7HzJ2jEb3EQ2l6r7fE,1500
7
+ nvidia_nat_semantic_kernel-1.2.0a20250813.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
+ nvidia_nat_semantic_kernel-1.2.0a20250813.dist-info/entry_points.txt,sha256=0jCtQBAn5Ohs9XoVCF34WvNCV33OwAsH8bjFzgw_ByM,76
9
+ nvidia_nat_semantic_kernel-1.2.0a20250813.dist-info/top_level.txt,sha256=8-CJ2cP6-f0ZReXe5Hzqp-5pvzzHz-5Ds5H2bGqh1-U,4
10
+ nvidia_nat_semantic_kernel-1.2.0a20250813.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [nat.components]
2
+ nat_semantic_kernel = nat.plugins.semantic_kernel.register