nvidia-nat-semantic-kernel 1.3.0a20250826__py3-none-any.whl → 1.3.0a20251111__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.
@@ -13,13 +13,75 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
+ from typing import TypeVar
17
+
16
18
  from nat.builder.builder import Builder
17
19
  from nat.builder.framework_enum import LLMFrameworkEnum
18
20
  from nat.cli.register_workflow import register_llm_client
21
+ from nat.data_models.llm import LLMBaseConfig
19
22
  from nat.data_models.retry_mixin import RetryMixin
23
+ from nat.data_models.thinking_mixin import ThinkingMixin
20
24
  from nat.llm.azure_openai_llm import AzureOpenAIModelConfig
21
25
  from nat.llm.openai_llm import OpenAIModelConfig
26
+ from nat.llm.utils.thinking import BaseThinkingInjector
27
+ from nat.llm.utils.thinking import FunctionArgumentWrapper
28
+ from nat.llm.utils.thinking import patch_with_thinking
22
29
  from nat.utils.exception_handlers.automatic_retries import patch_with_retry
30
+ from nat.utils.type_utils import override
31
+
32
+ ModelType = TypeVar("ModelType")
33
+
34
+
35
+ def _patch_llm_based_on_config(client: ModelType, llm_config: LLMBaseConfig) -> ModelType:
36
+
37
+ from semantic_kernel.contents.chat_history import ChatHistory
38
+
39
+ class SemanticKernelThinkingInjector(BaseThinkingInjector):
40
+
41
+ @override
42
+ def inject(self, chat_history: ChatHistory, *args, **kwargs) -> FunctionArgumentWrapper:
43
+ """
44
+ Inject a system prompt into the chat_history.
45
+
46
+ The chat_history is the first (non-object) argument to the function.
47
+ The rest of the arguments are passed through unchanged.
48
+
49
+ Args:
50
+ chat_history: The ChatHistory object to inject the system prompt into.
51
+ *args: The rest of the arguments to the function.
52
+ **kwargs: The rest of the keyword arguments to the function.
53
+
54
+ Returns:
55
+ FunctionArgumentWrapper: An object that contains the transformed args and kwargs.
56
+ """
57
+ if chat_history.system_message is None:
58
+ new_messages = ChatHistory(chat_history.messages, system_message=self.system_prompt)
59
+ return FunctionArgumentWrapper(new_messages, *args, **kwargs)
60
+ else:
61
+ new_messages = ChatHistory(
62
+ chat_history.messages,
63
+ system_message=f"{self.system_prompt}\n\n{chat_history.system_message}",
64
+ )
65
+ return FunctionArgumentWrapper(new_messages, *args, **kwargs)
66
+
67
+ if isinstance(llm_config, RetryMixin):
68
+ client = patch_with_retry(client,
69
+ retries=llm_config.num_retries,
70
+ retry_codes=llm_config.retry_on_status_codes,
71
+ retry_on_messages=llm_config.retry_on_errors)
72
+
73
+ if isinstance(llm_config, ThinkingMixin) and llm_config.thinking_system_prompt is not None:
74
+ client = patch_with_thinking(
75
+ client,
76
+ SemanticKernelThinkingInjector(
77
+ system_prompt=llm_config.thinking_system_prompt,
78
+ function_names=[
79
+ "get_chat_message_contents",
80
+ "get_streaming_chat_message_contents",
81
+ ],
82
+ ))
83
+
84
+ return client
23
85
 
24
86
 
25
87
  @register_llm_client(config_type=AzureOpenAIModelConfig, wrapper_type=LLMFrameworkEnum.SEMANTIC_KERNEL)
@@ -34,13 +96,7 @@ async def azure_openai_semantic_kernel(llm_config: AzureOpenAIModelConfig, _buil
34
96
  deployment_name=llm_config.azure_deployment,
35
97
  )
36
98
 
37
- if isinstance(llm_config, RetryMixin):
38
- llm = patch_with_retry(llm,
39
- retries=llm_config.num_retries,
40
- retry_codes=llm_config.retry_on_status_codes,
41
- retry_on_messages=llm_config.retry_on_errors)
42
-
43
- yield llm
99
+ yield _patch_llm_based_on_config(llm, llm_config)
44
100
 
45
101
 
46
102
  @register_llm_client(config_type=OpenAIModelConfig, wrapper_type=LLMFrameworkEnum.SEMANTIC_KERNEL)
@@ -50,10 +106,4 @@ async def openai_semantic_kernel(llm_config: OpenAIModelConfig, _builder: Builde
50
106
 
51
107
  llm = OpenAIChatCompletion(ai_model_id=llm_config.model_name)
52
108
 
53
- if isinstance(llm_config, RetryMixin):
54
- llm = patch_with_retry(llm,
55
- retries=llm_config.num_retries,
56
- retry_codes=llm_config.retry_on_status_codes,
57
- retry_on_messages=llm_config.retry_on_errors)
58
-
59
- yield llm
109
+ yield _patch_llm_based_on_config(llm, llm_config)
@@ -1,13 +1,24 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nvidia-nat-semantic-kernel
3
- Version: 1.3.0a20250826
3
+ Version: 1.3.0a20251111
4
4
  Summary: Subpackage for Semantic-Kernel integration in NeMo Agent toolkit
5
+ Author: NVIDIA Corporation
6
+ Maintainer: NVIDIA Corporation
7
+ License: Apache-2.0
8
+ Project-URL: documentation, https://docs.nvidia.com/nemo/agent-toolkit/latest/
9
+ Project-URL: source, https://github.com/NVIDIA/NeMo-Agent-Toolkit
5
10
  Keywords: ai,rag,agents
6
11
  Classifier: Programming Language :: Python
7
- Requires-Python: <3.13,>=3.11
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Requires-Python: <3.14,>=3.11
8
16
  Description-Content-Type: text/markdown
9
- Requires-Dist: nvidia-nat==v1.3.0a20250826
10
- Requires-Dist: semantic-kernel~=1.24.0
17
+ License-File: LICENSE-3rd-party.txt
18
+ License-File: LICENSE.md
19
+ Requires-Dist: nvidia-nat==v1.3.0a20251111
20
+ Requires-Dist: semantic-kernel~=1.35
21
+ Dynamic: license-file
11
22
 
12
23
  <!--
13
24
  SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
@@ -0,0 +1,12 @@
1
+ nat/meta/pypi.md,sha256=rFmwVds3akmoz0TE1SOjCjCUbB6SWfaRex_Vi5OfUAk,1116
2
+ nat/plugins/semantic_kernel/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ nat/plugins/semantic_kernel/llm.py,sha256=z_Qeky9kndYsDEbJaHHALe6hcT1dc1NiBJTpLxif6_c,4622
4
+ nat/plugins/semantic_kernel/register.py,sha256=_R3bhGmz___696_NwyIcpw3koMBiWqIFoWEFJ0VAgXs,831
5
+ nat/plugins/semantic_kernel/tool_wrapper.py,sha256=N6WGEdveLYFKtOKjxEMMNT5vG8QJUoSddtswQ1fPEzQ,7121
6
+ nvidia_nat_semantic_kernel-1.3.0a20251111.dist-info/licenses/LICENSE-3rd-party.txt,sha256=fOk5jMmCX9YoKWyYzTtfgl-SUy477audFC5hNY4oP7Q,284609
7
+ nvidia_nat_semantic_kernel-1.3.0a20251111.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
8
+ nvidia_nat_semantic_kernel-1.3.0a20251111.dist-info/METADATA,sha256=4ik8uvw-XCMOru-uLIHhoLiAa0vd5Icn8PxibP2luL8,1946
9
+ nvidia_nat_semantic_kernel-1.3.0a20251111.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
+ nvidia_nat_semantic_kernel-1.3.0a20251111.dist-info/entry_points.txt,sha256=0jCtQBAn5Ohs9XoVCF34WvNCV33OwAsH8bjFzgw_ByM,76
11
+ nvidia_nat_semantic_kernel-1.3.0a20251111.dist-info/top_level.txt,sha256=8-CJ2cP6-f0ZReXe5Hzqp-5pvzzHz-5Ds5H2bGqh1-U,4
12
+ nvidia_nat_semantic_kernel-1.3.0a20251111.dist-info/RECORD,,