@sateeshreddy/n8n-nodes-nvidia-nim 0.1.0 → 1.0.2
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.
- package/README.md +234 -10
- package/dist/nodes/NvidiaNim/NvidiaNim.node.d.ts.map +1 -1
- package/dist/nodes/NvidiaNim/NvidiaNim.node.js +28 -17
- package/dist/nodes/NvidiaNim/NvidiaNim.node.js.map +1 -1
- package/dist/nodes/NvidiaNim/NvidiaNim.node.json +4 -2
- package/nodes/NvidiaNim/NvidiaNim.node.json +4 -2
- package/nodes/NvidiaNim/NvidiaNim.node.ts +34 -24
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,21 +1,245 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<img src="https://upload.wikimedia.org/wikipedia/commons/a/a4/NVIDIA_logo.svg" height="48" alt="NVIDIA Logo" />
|
|
4
|
+
|
|
1
5
|
# n8n-nodes-nvidia-nim
|
|
2
6
|
|
|
3
|
-
|
|
7
|
+
**Connect any free NVIDIA NIM language model to your n8n workflows — in one node.**
|
|
8
|
+
|
|
9
|
+
[](https://www.npmjs.com/package/n8n-nodes-nvidia-nim)
|
|
10
|
+
[](https://n8n.io)
|
|
11
|
+
[](LICENSE)
|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Overview
|
|
18
|
+
|
|
19
|
+
`n8n-nodes-nvidia-nim` is an n8n community node that gives you access to **NVIDIA NIM's free hosted language models** directly inside your workflows.
|
|
20
|
+
It plugs into n8n's **AI Agent** as a drop-in language model — just like the built-in OpenAI or Anthropic nodes.
|
|
21
|
+
|
|
22
|
+
### Why use this?
|
|
23
|
+
|
|
24
|
+
- ✅ Free tier models via [build.nvidia.com](https://build.nvidia.com)
|
|
25
|
+
- ✅ Works as a proper **AI sub-node** (connect to any AI Agent)
|
|
26
|
+
- ✅ Supports 17+ models including Llama 4, Mistral, Qwen3, Gemma, and more
|
|
27
|
+
- ✅ Drop-in OpenAI-compatible API — no extra setup
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Supported Models
|
|
32
|
+
|
|
33
|
+
| Model | Value |
|
|
34
|
+
|---|---|
|
|
35
|
+
| Llama 4 Maverick 17B 128E Instruct *(default)* | `meta/llama-4-maverick-17b-128e-instruct` |
|
|
36
|
+
| Mistral Large 3 675B Instruct | `mistralai/mistral-large-3-675b-instruct-2512` |
|
|
37
|
+
| Qwen3 Coder 480B A35B Instruct | `qwen/qwen3-coder-480b-a35b-instruct` |
|
|
38
|
+
| Mistral Nemotron (Function Calling) | `mistralai/mistral-nemotron` |
|
|
39
|
+
| Mistral Medium 3 Instruct | `mistralai/mistral-medium-3-instruct` |
|
|
40
|
+
| Magistral Small 2506 | `mistralai/magistral-small-2506` |
|
|
41
|
+
| Step 3.5 Flash (Agentic) | `stepfun-ai/step-3.5-flash` |
|
|
42
|
+
| Seed OSS 36B Instruct (Agentic) | `bytedance/seed-oss-36b-instruct` |
|
|
43
|
+
| GLM-4.7 (Tool Calling) | `thudm/glm-4.7` |
|
|
44
|
+
| MiniMax M2.7 | `minimax/minimax-m2.7` |
|
|
45
|
+
| Phi-4 Multimodal Instruct | `microsoft/phi-4-multimodal-instruct` |
|
|
46
|
+
| Gemma 3N E4B IT | `google/gemma-3n-e4b-it` |
|
|
47
|
+
| Gemma 3N E2B IT | `google/gemma-3n-e2b-it` |
|
|
48
|
+
| Gemma 2 2B IT | `google/gemma-2-2b-it` |
|
|
49
|
+
| Dracarys Llama 3.1 70B Instruct | `abacusai/dracarys-llama-3.1-70b-instruct` |
|
|
50
|
+
| Nemotron Mini 4B Instruct | `nvidia/nemotron-mini-4b-instruct` |
|
|
51
|
+
| Solar 10.7B Instruct | `upstage/solar-10.7b-instruct` |
|
|
52
|
+
|
|
53
|
+
---
|
|
4
54
|
|
|
5
55
|
## Installation
|
|
6
56
|
|
|
7
|
-
|
|
8
|
-
|
|
57
|
+
### Via n8n Community Nodes (Recommended)
|
|
58
|
+
|
|
59
|
+
1. Open your n8n instance
|
|
60
|
+
2. Go to **Settings → Community Nodes**
|
|
61
|
+
3. Click **Install**
|
|
62
|
+
4. Enter `n8n-nodes-nvidia-nim` and confirm
|
|
63
|
+
|
|
64
|
+
### Manual Installation
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Navigate to your n8n custom nodes directory
|
|
68
|
+
cd ~/.n8n/custom/
|
|
69
|
+
|
|
70
|
+
# Install the package
|
|
71
|
+
npm install n8n-nodes-nvidia-nim
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Then restart n8n.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Getting Your API Key
|
|
79
|
+
|
|
80
|
+
1. Visit [build.nvidia.com](https://build.nvidia.com)
|
|
81
|
+
2. Sign in or create a free account
|
|
82
|
+
3. Navigate to **API Keys** in your dashboard
|
|
83
|
+
4. Generate a new key and copy it
|
|
84
|
+
|
|
85
|
+
> **Note:** The free tier gives you a generous number of inference credits — no credit card required.
|
|
86
|
+
|
|
87
|
+
---
|
|
9
88
|
|
|
10
89
|
## Usage
|
|
11
90
|
|
|
12
|
-
|
|
91
|
+
### 1. Add Credentials
|
|
92
|
+
|
|
93
|
+
In n8n, go to **Credentials → New → NVIDIA NIM API** and paste your API key.
|
|
94
|
+
|
|
95
|
+
### 2. Add the Node to a Workflow
|
|
96
|
+
|
|
97
|
+
1. Add an **AI Agent** node to your workflow
|
|
98
|
+
2. In the Agent's **Model** slot, click the `+` button
|
|
99
|
+
3. Search for **NVIDIA NIM** and select it
|
|
100
|
+
4. Configure the model, temperature, and max tokens
|
|
101
|
+
5. Run your workflow
|
|
102
|
+
|
|
103
|
+
The node acts as a language model supplier — it connects to AI Agents, chains, and any other LangChain-compatible n8n node.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Configuration Options
|
|
108
|
+
|
|
109
|
+
| Parameter | Type | Default | Description |
|
|
110
|
+
|---|---|---|---|
|
|
111
|
+
| **Model** | Dropdown | `llama-4-maverick-17b-128e-instruct` | The NIM model to use |
|
|
112
|
+
| **Temperature** | Number (0–2) | `0.7` | Controls output randomness. Lower = more deterministic |
|
|
113
|
+
| **Max Tokens** | Number (1–4096) | `1000` | Maximum tokens in the response |
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Known Issue — Routing Light Not Animating
|
|
118
|
+
|
|
119
|
+
> ⚠️ **This section documents a bug found in earlier versions of this node and how it was fixed.**
|
|
120
|
+
> If you installed version `1.0.0` or earlier, please update to the latest version.
|
|
121
|
+
|
|
122
|
+
### What was happening
|
|
123
|
+
|
|
124
|
+
When users ran a workflow containing this node, the **routing light** (the animated glow/pulse around a node that shows it is actively executing) never appeared — even though the node was working correctly behind the scenes.
|
|
125
|
+
|
|
126
|
+
Every other node in the workflow showed the animation, but the NVIDIA NIM node stayed visually "dark" throughout execution.
|
|
127
|
+
|
|
128
|
+
### Root Cause
|
|
129
|
+
|
|
130
|
+
This node uses n8n's `supplyData()` method instead of `execute()` — which is the correct pattern for **AI sub-nodes** (language model supply nodes that connect to AI Agents). However, `supplyData` has a different execution lifecycle than `execute`, and n8n tracks visual status through that lifecycle.
|
|
131
|
+
|
|
132
|
+
Three things were missing:
|
|
133
|
+
|
|
134
|
+
**1. No `closeFunction` returned**
|
|
135
|
+
|
|
136
|
+
`supplyData` must return a `closeFunction` alongside the model response. n8n uses this callback as the signal that the node has finished its work — which is what triggers the routing light to complete its animation and mark the node as done.
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
// ❌ Before — n8n never knew the node finished
|
|
140
|
+
return {
|
|
141
|
+
response: chatModel,
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// ✅ After — n8n now correctly tracks completion
|
|
145
|
+
return {
|
|
146
|
+
response: chatModel,
|
|
147
|
+
closeFunction: async () => {},
|
|
148
|
+
};
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
**2. Errors were not re-thrown as `NodeOperationError`**
|
|
152
|
+
|
|
153
|
+
When the node threw an error (bad API key, network failure, etc.), n8n had no way to update the node's visual state to "failed". The routing light would simply never appear.
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
// ❌ Before — silent failure, n8n UI stays blank
|
|
157
|
+
} catch (error) {
|
|
158
|
+
console.error(error);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// ✅ After — n8n marks the node as failed with an error badge
|
|
162
|
+
} catch (error) {
|
|
163
|
+
throw new NodeOperationError(this.getNode(), error as Error);
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
**3. Missing `outputConnectionTypes` in node descriptor**
|
|
168
|
+
|
|
169
|
+
Without declaring `outputConnectionTypes`, n8n's UI couldn't properly register the node as a typed AI supply node, which prevented the execution tracker from attaching to it.
|
|
170
|
+
|
|
171
|
+
```json
|
|
172
|
+
// ✅ Added to NvidiaNim.node.json
|
|
173
|
+
"outputConnectionTypes": {
|
|
174
|
+
"ai_languageModel": [{ "type": "ai_languageModel" }]
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### The Fix (v1.1.0+)
|
|
179
|
+
|
|
180
|
+
All three issues were resolved in `v1.1.0`. The node now correctly shows the routing light animation during execution, displays an error badge on failure, and cleans up properly after each run.
|
|
181
|
+
|
|
182
|
+
---
|
|
13
183
|
|
|
14
184
|
## Development
|
|
15
185
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
186
|
+
```bash
|
|
187
|
+
# Install dependencies
|
|
188
|
+
npm install
|
|
189
|
+
|
|
190
|
+
# TypeScript watch mode (auto-recompile on save)
|
|
191
|
+
npm run dev
|
|
192
|
+
|
|
193
|
+
# Build distributable files
|
|
194
|
+
npm run build
|
|
195
|
+
|
|
196
|
+
# Lint code
|
|
197
|
+
npm run lint
|
|
198
|
+
|
|
199
|
+
# Auto-fix lint issues
|
|
200
|
+
npm run lintfix
|
|
201
|
+
|
|
202
|
+
# Format with Prettier
|
|
203
|
+
npm run format
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Project Structure
|
|
207
|
+
|
|
208
|
+
```
|
|
209
|
+
n8n-nodes-nvidia-nim/
|
|
210
|
+
├── credentials/
|
|
211
|
+
│ └── NvidiaNimApi.credentials.ts # API key credential definition
|
|
212
|
+
├── nodes/
|
|
213
|
+
│ └── NvidiaNim/
|
|
214
|
+
│ ├── NvidiaNim.node.ts # Node logic (supplyData)
|
|
215
|
+
│ ├── NvidiaNim.node.json # Node descriptor & UI properties
|
|
216
|
+
│ └── nvidia-nim.png # Node icon
|
|
217
|
+
├── dist/ # Compiled output (generated)
|
|
218
|
+
├── package.json
|
|
219
|
+
└── README.md
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## Contributing
|
|
225
|
+
|
|
226
|
+
Pull requests are welcome! If you'd like to add a new model, fix a bug, or improve documentation:
|
|
227
|
+
|
|
228
|
+
1. Fork the repo
|
|
229
|
+
2. Create a feature branch: `git checkout -b feat/your-feature`
|
|
230
|
+
3. Commit your changes: `git commit -m 'feat: add your feature'`
|
|
231
|
+
4. Push and open a PR
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## License
|
|
236
|
+
|
|
237
|
+
[MIT](LICENSE)
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
<div align="center">
|
|
242
|
+
|
|
243
|
+
Made with ☕ for the n8n community · Powered by [NVIDIA NIM](https://build.nvidia.com)
|
|
244
|
+
|
|
245
|
+
</div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NvidiaNim.node.d.ts","sourceRoot":"","sources":["../../../nodes/NvidiaNim/NvidiaNim.node.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"NvidiaNim.node.d.ts","sourceRoot":"","sources":["../../../nodes/NvidiaNim/NvidiaNim.node.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,SAAS,EACT,oBAAoB,EACpB,oBAAoB,EACpB,UAAU,EAEV,MAAM,cAAc,CAAC;AAItB,qBAAa,SAAU,YAAW,SAAS;IAC1C,WAAW,EAAE,oBAAoB,CAA2C;IAEtE,UAAU,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,UAAU,CAAC;CA8BjE"}
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.NvidiaNim = void 0;
|
|
7
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
7
8
|
const openai_1 = require("@langchain/openai");
|
|
8
9
|
const NvidiaNim_node_json_1 = __importDefault(require("./NvidiaNim.node.json"));
|
|
9
10
|
class NvidiaNim {
|
|
@@ -11,23 +12,33 @@ class NvidiaNim {
|
|
|
11
12
|
this.description = NvidiaNim_node_json_1.default;
|
|
12
13
|
}
|
|
13
14
|
async supplyData() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
15
|
+
try {
|
|
16
|
+
const credentials = await this.getCredentials('nvidiaNimApi');
|
|
17
|
+
const model = this.getNodeParameter('model', 0);
|
|
18
|
+
const temperature = this.getNodeParameter('temperature', 0);
|
|
19
|
+
const maxTokens = this.getNodeParameter('maxTokens', 0);
|
|
20
|
+
const apiKey = credentials.apiKey;
|
|
21
|
+
const chatModel = new openai_1.ChatOpenAI({
|
|
22
|
+
apiKey,
|
|
23
|
+
modelName: model,
|
|
24
|
+
temperature,
|
|
25
|
+
maxTokens,
|
|
26
|
+
configuration: {
|
|
27
|
+
baseURL: 'https://integrate.api.nvidia.com/v1',
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
response: chatModel,
|
|
32
|
+
// Required: tells n8n the node has finished supplying data,
|
|
33
|
+
// which triggers the routing light animation to complete correctly.
|
|
34
|
+
closeFunction: async () => { },
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
// Re-throwing as NodeOperationError lets n8n properly
|
|
39
|
+
// update the node's visual status to "error" in the UI.
|
|
40
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
|
|
41
|
+
}
|
|
31
42
|
}
|
|
32
43
|
}
|
|
33
44
|
exports.NvidiaNim = NvidiaNim;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NvidiaNim.node.js","sourceRoot":"","sources":["../../../nodes/NvidiaNim/NvidiaNim.node.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"NvidiaNim.node.js","sourceRoot":"","sources":["../../../nodes/NvidiaNim/NvidiaNim.node.ts"],"names":[],"mappings":";;;;;;AAAA,+CAMsB;AACtB,8CAA+C;AAC/C,gFAAoD;AAEpD,MAAa,SAAS;IAAtB;QACC,gBAAW,GAAyB,6BAAuC,CAAC;IAgC7E,CAAC;IA9BA,KAAK,CAAC,UAAU;QACf,IAAI,CAAC;YACJ,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;YAC9D,MAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAW,CAAC;YAC1D,MAAM,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC,aAAa,EAAE,CAAC,CAAW,CAAC;YACtE,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,CAAC,CAAW,CAAC;YAClE,MAAM,MAAM,GAAG,WAAW,CAAC,MAAgB,CAAC;YAE5C,MAAM,SAAS,GAAG,IAAI,mBAAU,CAAC;gBAChC,MAAM;gBACN,SAAS,EAAE,KAAK;gBAChB,WAAW;gBACX,SAAS;gBACT,aAAa,EAAE;oBACd,OAAO,EAAE,qCAAqC;iBAC9C;aACD,CAAC,CAAC;YAEH,OAAO;gBACN,QAAQ,EAAE,SAAS;gBACnB,4DAA4D;gBAC5D,oEAAoE;gBACpE,aAAa,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;aAC7B,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,sDAAsD;YACtD,wDAAwD;YACxD,MAAM,IAAI,iCAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAc,CAAC,CAAC;QAC9D,CAAC;IACF,CAAC;CACD;AAjCD,8BAiCC"}
|
|
@@ -9,8 +9,12 @@
|
|
|
9
9
|
"name": "NVIDIA NIM"
|
|
10
10
|
},
|
|
11
11
|
"inputs": [],
|
|
12
|
+
"inputNames": [],
|
|
12
13
|
"outputs": ["ai_languageModel"],
|
|
13
14
|
"outputNames": ["Model"],
|
|
15
|
+
"outputConnectionTypes": {
|
|
16
|
+
"ai_languageModel": [{ "type": "ai_languageModel" }]
|
|
17
|
+
},
|
|
14
18
|
"codex": {
|
|
15
19
|
"categories": ["AI"],
|
|
16
20
|
"subcategories": {
|
|
@@ -31,8 +35,6 @@
|
|
|
31
35
|
"name": "model",
|
|
32
36
|
"type": "options",
|
|
33
37
|
"options": [
|
|
34
|
-
{ "name": "GLM-4.7 (Tool Calling)", "value": "thudm/glm-4.7" },
|
|
35
|
-
{ "name": "MiniMax M2.7", "value": "minimax/minimax-m2.7" },
|
|
36
38
|
{ "name": "Step 3.5 Flash (Agentic)", "value": "stepfun-ai/step-3.5-flash" },
|
|
37
39
|
{ "name": "Mistral Large 3 675B Instruct", "value": "mistralai/mistral-large-3-675b-instruct-2512" },
|
|
38
40
|
{ "name": "Seed OSS 36B Instruct (Agentic)", "value": "bytedance/seed-oss-36b-instruct" },
|
|
@@ -9,8 +9,12 @@
|
|
|
9
9
|
"name": "NVIDIA NIM"
|
|
10
10
|
},
|
|
11
11
|
"inputs": [],
|
|
12
|
+
"inputNames": [],
|
|
12
13
|
"outputs": ["ai_languageModel"],
|
|
13
14
|
"outputNames": ["Model"],
|
|
15
|
+
"outputConnectionTypes": {
|
|
16
|
+
"ai_languageModel": [{ "type": "ai_languageModel" }]
|
|
17
|
+
},
|
|
14
18
|
"codex": {
|
|
15
19
|
"categories": ["AI"],
|
|
16
20
|
"subcategories": {
|
|
@@ -31,8 +35,6 @@
|
|
|
31
35
|
"name": "model",
|
|
32
36
|
"type": "options",
|
|
33
37
|
"options": [
|
|
34
|
-
{ "name": "GLM-4.7 (Tool Calling)", "value": "thudm/glm-4.7" },
|
|
35
|
-
{ "name": "MiniMax M2.7", "value": "minimax/minimax-m2.7" },
|
|
36
38
|
{ "name": "Step 3.5 Flash (Agentic)", "value": "stepfun-ai/step-3.5-flash" },
|
|
37
39
|
{ "name": "Mistral Large 3 675B Instruct", "value": "mistralai/mistral-large-3-675b-instruct-2512" },
|
|
38
40
|
{ "name": "Seed OSS 36B Instruct (Agentic)", "value": "bytedance/seed-oss-36b-instruct" },
|
|
@@ -1,34 +1,44 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
INodeType,
|
|
3
|
+
INodeTypeDescription,
|
|
4
|
+
ISupplyDataFunctions,
|
|
5
|
+
SupplyData,
|
|
6
|
+
NodeOperationError,
|
|
6
7
|
} from 'n8n-workflow';
|
|
7
8
|
import { ChatOpenAI } from '@langchain/openai';
|
|
8
9
|
import nodeDescription from './NvidiaNim.node.json';
|
|
9
10
|
|
|
10
11
|
export class NvidiaNim implements INodeType {
|
|
11
|
-
|
|
12
|
+
description: INodeTypeDescription = nodeDescription as INodeTypeDescription;
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
async supplyData(this: ISupplyDataFunctions): Promise<SupplyData> {
|
|
15
|
+
try {
|
|
16
|
+
const credentials = await this.getCredentials('nvidiaNimApi');
|
|
17
|
+
const model = this.getNodeParameter('model', 0) as string;
|
|
18
|
+
const temperature = this.getNodeParameter('temperature', 0) as number;
|
|
19
|
+
const maxTokens = this.getNodeParameter('maxTokens', 0) as number;
|
|
20
|
+
const apiKey = credentials.apiKey as string;
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
const chatModel = new ChatOpenAI({
|
|
23
|
+
apiKey,
|
|
24
|
+
modelName: model,
|
|
25
|
+
temperature,
|
|
26
|
+
maxTokens,
|
|
27
|
+
configuration: {
|
|
28
|
+
baseURL: 'https://integrate.api.nvidia.com/v1',
|
|
29
|
+
},
|
|
30
|
+
});
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
return {
|
|
33
|
+
response: chatModel,
|
|
34
|
+
// Required: tells n8n the node has finished supplying data,
|
|
35
|
+
// which triggers the routing light animation to complete correctly.
|
|
36
|
+
closeFunction: async () => {},
|
|
37
|
+
};
|
|
38
|
+
} catch (error) {
|
|
39
|
+
// Re-throwing as NodeOperationError lets n8n properly
|
|
40
|
+
// update the node's visual status to "error" in the UI.
|
|
41
|
+
throw new NodeOperationError(this.getNode(), error as Error);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
34
44
|
}
|