nvidia-nat-llama-index 1.4.0a20251015__py3-none-any.whl → 1.4.0a20251022__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.
- nat/plugins/llama_index/llm.py +31 -7
- {nvidia_nat_llama_index-1.4.0a20251015.dist-info → nvidia_nat_llama_index-1.4.0a20251022.dist-info}/METADATA +6 -6
- {nvidia_nat_llama_index-1.4.0a20251015.dist-info → nvidia_nat_llama_index-1.4.0a20251022.dist-info}/RECORD +8 -8
- {nvidia_nat_llama_index-1.4.0a20251015.dist-info → nvidia_nat_llama_index-1.4.0a20251022.dist-info}/WHEEL +0 -0
- {nvidia_nat_llama_index-1.4.0a20251015.dist-info → nvidia_nat_llama_index-1.4.0a20251022.dist-info}/entry_points.txt +0 -0
- {nvidia_nat_llama_index-1.4.0a20251015.dist-info → nvidia_nat_llama_index-1.4.0a20251022.dist-info}/licenses/LICENSE-3rd-party.txt +0 -0
- {nvidia_nat_llama_index-1.4.0a20251015.dist-info → nvidia_nat_llama_index-1.4.0a20251022.dist-info}/licenses/LICENSE.md +0 -0
- {nvidia_nat_llama_index-1.4.0a20251015.dist-info → nvidia_nat_llama_index-1.4.0a20251022.dist-info}/top_level.txt +0 -0
nat/plugins/llama_index/llm.py
CHANGED
@@ -19,6 +19,7 @@ from typing import TypeVar
|
|
19
19
|
from nat.builder.builder import Builder
|
20
20
|
from nat.builder.framework_enum import LLMFrameworkEnum
|
21
21
|
from nat.cli.register_workflow import register_llm_client
|
22
|
+
from nat.data_models.llm import APITypeEnum
|
22
23
|
from nat.data_models.llm import LLMBaseConfig
|
23
24
|
from nat.data_models.retry_mixin import RetryMixin
|
24
25
|
from nat.data_models.thinking_mixin import ThinkingMixin
|
@@ -31,6 +32,7 @@ from nat.llm.utils.thinking import BaseThinkingInjector
|
|
31
32
|
from nat.llm.utils.thinking import FunctionArgumentWrapper
|
32
33
|
from nat.llm.utils.thinking import patch_with_thinking
|
33
34
|
from nat.utils.exception_handlers.automatic_retries import patch_with_retry
|
35
|
+
from nat.utils.responses_api import validate_no_responses_api
|
34
36
|
from nat.utils.type_utils import override
|
35
37
|
|
36
38
|
ModelType = TypeVar("ModelType")
|
@@ -44,8 +46,16 @@ def _patch_llm_based_on_config(client: ModelType, llm_config: LLMBaseConfig) ->
|
|
44
46
|
|
45
47
|
@override
|
46
48
|
def inject(self, messages: Sequence[ChatMessage], *args, **kwargs) -> FunctionArgumentWrapper:
|
47
|
-
|
48
|
-
|
49
|
+
for i, message in enumerate(messages):
|
50
|
+
if message.role == "system":
|
51
|
+
if self.system_prompt not in str(message.content):
|
52
|
+
messages = list(messages)
|
53
|
+
messages[i] = ChatMessage(role="system", content=f"{message.content}\n{self.system_prompt}")
|
54
|
+
break
|
55
|
+
else:
|
56
|
+
messages = list(messages)
|
57
|
+
messages.insert(0, ChatMessage(role="system", content=self.system_prompt))
|
58
|
+
return FunctionArgumentWrapper(messages, *args, **kwargs)
|
49
59
|
|
50
60
|
if isinstance(llm_config, RetryMixin):
|
51
61
|
client = patch_with_retry(client,
|
@@ -74,8 +84,10 @@ async def aws_bedrock_llama_index(llm_config: AWSBedrockModelConfig, _builder: B
|
|
74
84
|
|
75
85
|
from llama_index.llms.bedrock import Bedrock
|
76
86
|
|
87
|
+
validate_no_responses_api(llm_config, LLMFrameworkEnum.LLAMA_INDEX)
|
88
|
+
|
77
89
|
# LlamaIndex uses context_size instead of max_tokens
|
78
|
-
llm = Bedrock(**llm_config.model_dump(exclude={"type", "top_p", "thinking"}, by_alias=True))
|
90
|
+
llm = Bedrock(**llm_config.model_dump(exclude={"type", "top_p", "thinking", "api_type"}, by_alias=True))
|
79
91
|
|
80
92
|
yield _patch_llm_based_on_config(llm, llm_config)
|
81
93
|
|
@@ -85,7 +97,9 @@ async def azure_openai_llama_index(llm_config: AzureOpenAIModelConfig, _builder:
|
|
85
97
|
|
86
98
|
from llama_index.llms.azure_openai import AzureOpenAI
|
87
99
|
|
88
|
-
|
100
|
+
validate_no_responses_api(llm_config, LLMFrameworkEnum.LLAMA_INDEX)
|
101
|
+
|
102
|
+
llm = AzureOpenAI(**llm_config.model_dump(exclude={"type", "thinking", "api_type"}, by_alias=True))
|
89
103
|
|
90
104
|
yield _patch_llm_based_on_config(llm, llm_config)
|
91
105
|
|
@@ -95,7 +109,9 @@ async def nim_llama_index(llm_config: NIMModelConfig, _builder: Builder):
|
|
95
109
|
|
96
110
|
from llama_index.llms.nvidia import NVIDIA
|
97
111
|
|
98
|
-
|
112
|
+
validate_no_responses_api(llm_config, LLMFrameworkEnum.LLAMA_INDEX)
|
113
|
+
|
114
|
+
llm = NVIDIA(**llm_config.model_dump(exclude={"type", "thinking", "api_type"}, by_alias=True, exclude_none=True))
|
99
115
|
|
100
116
|
yield _patch_llm_based_on_config(llm, llm_config)
|
101
117
|
|
@@ -104,8 +120,14 @@ async def nim_llama_index(llm_config: NIMModelConfig, _builder: Builder):
|
|
104
120
|
async def openai_llama_index(llm_config: OpenAIModelConfig, _builder: Builder):
|
105
121
|
|
106
122
|
from llama_index.llms.openai import OpenAI
|
123
|
+
from llama_index.llms.openai import OpenAIResponses
|
107
124
|
|
108
|
-
|
125
|
+
if llm_config.api_type == APITypeEnum.RESPONSES:
|
126
|
+
llm = OpenAIResponses(
|
127
|
+
**llm_config.model_dump(exclude={"type", "thinking", "api_type"}, by_alias=True, exclude_none=True))
|
128
|
+
else:
|
129
|
+
llm = OpenAI(
|
130
|
+
**llm_config.model_dump(exclude={"type", "thinking", "api_type"}, by_alias=True, exclude_none=True))
|
109
131
|
|
110
132
|
yield _patch_llm_based_on_config(llm, llm_config)
|
111
133
|
|
@@ -115,6 +137,8 @@ async def litellm_llama_index(llm_config: LiteLlmModelConfig, _builder: Builder)
|
|
115
137
|
|
116
138
|
from llama_index.llms.litellm import LiteLLM
|
117
139
|
|
118
|
-
|
140
|
+
validate_no_responses_api(llm_config, LLMFrameworkEnum.LLAMA_INDEX)
|
141
|
+
|
142
|
+
llm = LiteLLM(**llm_config.model_dump(exclude={"type", "thinking", "api_type"}, by_alias=True, exclude_none=True))
|
119
143
|
|
120
144
|
yield _patch_llm_based_on_config(llm, llm_config)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: nvidia-nat-llama-index
|
3
|
-
Version: 1.4.
|
3
|
+
Version: 1.4.0a20251022
|
4
4
|
Summary: Subpackage for Llama-Index integration in NeMo Agent toolkit
|
5
5
|
Author: NVIDIA Corporation
|
6
6
|
Maintainer: NVIDIA Corporation
|
@@ -16,18 +16,18 @@ Requires-Python: <3.14,>=3.11
|
|
16
16
|
Description-Content-Type: text/markdown
|
17
17
|
License-File: LICENSE-3rd-party.txt
|
18
18
|
License-File: LICENSE.md
|
19
|
-
Requires-Dist: nvidia-nat==v1.4.
|
20
|
-
Requires-Dist: llama-index-core~=0.12.
|
19
|
+
Requires-Dist: nvidia-nat==v1.4.0a20251022
|
20
|
+
Requires-Dist: llama-index-core~=0.12.40
|
21
21
|
Requires-Dist: llama-index-embeddings-azure-openai~=0.3.9
|
22
22
|
Requires-Dist: llama-index-embeddings-nvidia~=0.3.1
|
23
23
|
Requires-Dist: llama-index-embeddings-openai~=0.3.1
|
24
24
|
Requires-Dist: llama-index-llms-azure-openai~=0.3.2
|
25
25
|
Requires-Dist: llama-index-llms-bedrock~=0.3.8
|
26
26
|
Requires-Dist: llama-index-llms-litellm~=0.5.1
|
27
|
-
Requires-Dist: llama-index-llms-nvidia~=0.3.
|
28
|
-
Requires-Dist: llama-index-llms-openai
|
27
|
+
Requires-Dist: llama-index-llms-nvidia~=0.3.4
|
28
|
+
Requires-Dist: llama-index-llms-openai<1.0.0,>=0.4.2
|
29
29
|
Requires-Dist: llama-index-readers-file~=0.4.4
|
30
|
-
Requires-Dist: llama-index~=0.12.
|
30
|
+
Requires-Dist: llama-index~=0.12.40
|
31
31
|
Dynamic: license-file
|
32
32
|
|
33
33
|
<!--
|
@@ -1,13 +1,13 @@
|
|
1
1
|
nat/meta/pypi.md,sha256=s9C3pgWB0HLIXTx5QPryNOWN0O2fIRIap0p9_zCHlTs,1112
|
2
2
|
nat/plugins/llama_index/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
3
|
nat/plugins/llama_index/embedder.py,sha256=4c4uAa19UArqA_Npe5mwEnUhCaguTbyWcAntBzcPEeQ,3493
|
4
|
-
nat/plugins/llama_index/llm.py,sha256=
|
4
|
+
nat/plugins/llama_index/llm.py,sha256=Vd331oSjTH4a9IAh3mgULXd3Ao9pBJ54WPQsXIz8drI,6088
|
5
5
|
nat/plugins/llama_index/register.py,sha256=1x_b8u6cuQwh4Iz_7TcIFWXvLIL9IIKUPE-zR9d6ug8,859
|
6
6
|
nat/plugins/llama_index/tool_wrapper.py,sha256=VFKMIIeLdWqHwW2Ax11E2w-_9w3ow6Iuhra1Hk78RYM,1387
|
7
|
-
nvidia_nat_llama_index-1.4.
|
8
|
-
nvidia_nat_llama_index-1.4.
|
9
|
-
nvidia_nat_llama_index-1.4.
|
10
|
-
nvidia_nat_llama_index-1.4.
|
11
|
-
nvidia_nat_llama_index-1.4.
|
12
|
-
nvidia_nat_llama_index-1.4.
|
13
|
-
nvidia_nat_llama_index-1.4.
|
7
|
+
nvidia_nat_llama_index-1.4.0a20251022.dist-info/licenses/LICENSE-3rd-party.txt,sha256=fOk5jMmCX9YoKWyYzTtfgl-SUy477audFC5hNY4oP7Q,284609
|
8
|
+
nvidia_nat_llama_index-1.4.0a20251022.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
|
9
|
+
nvidia_nat_llama_index-1.4.0a20251022.dist-info/METADATA,sha256=47Xuj2LLuhMXEnV3QfJlyeWcKLPDTdF_0ELQ1N1acrQ,2428
|
10
|
+
nvidia_nat_llama_index-1.4.0a20251022.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
11
|
+
nvidia_nat_llama_index-1.4.0a20251022.dist-info/entry_points.txt,sha256=2LqRRju5448P2v8B3y6TSPnk-nOd5T3AmV5JibCnoQc,68
|
12
|
+
nvidia_nat_llama_index-1.4.0a20251022.dist-info/top_level.txt,sha256=8-CJ2cP6-f0ZReXe5Hzqp-5pvzzHz-5Ds5H2bGqh1-U,4
|
13
|
+
nvidia_nat_llama_index-1.4.0a20251022.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|