@zerogpu/n8n-nodes-zerogpu 0.1.1 → 0.3.0
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 +84 -4
- package/dist/nodes/ZeroGpu/ZeroGpu.node.d.ts +7 -2
- package/dist/nodes/ZeroGpu/ZeroGpu.node.js +43 -9
- package/dist/nodes/ZeroGpu/ZeroGpu.node.js.map +1 -1
- package/dist/nodes/ZeroGpu/loadOptions/getModels.d.ts +2 -0
- package/dist/nodes/ZeroGpu/loadOptions/getModels.js +21 -0
- package/dist/nodes/ZeroGpu/loadOptions/getModels.js.map +1 -0
- package/dist/nodes/ZeroGpu/resources/classification/index.d.ts +2 -0
- package/dist/nodes/ZeroGpu/resources/classification/index.js +65 -0
- package/dist/nodes/ZeroGpu/resources/classification/index.js.map +1 -0
- package/dist/nodes/ZeroGpu/resources/document/index.d.ts +2 -0
- package/dist/nodes/ZeroGpu/resources/document/index.js +37 -0
- package/dist/nodes/ZeroGpu/resources/document/index.js.map +1 -0
- package/dist/nodes/ZeroGpu/resources/extraction/index.d.ts +2 -0
- package/dist/nodes/ZeroGpu/resources/extraction/index.js +57 -0
- package/dist/nodes/ZeroGpu/resources/extraction/index.js.map +1 -0
- package/dist/nodes/ZeroGpu/resources/moderation/index.d.ts +2 -0
- package/dist/nodes/ZeroGpu/resources/moderation/index.js +28 -0
- package/dist/nodes/ZeroGpu/resources/moderation/index.js.map +1 -0
- package/dist/nodes/ZeroGpu/resources/summarization/index.d.ts +2 -0
- package/dist/nodes/ZeroGpu/resources/summarization/index.js +28 -0
- package/dist/nodes/ZeroGpu/resources/summarization/index.js.map +1 -0
- package/dist/nodes/ZeroGpu/shared/descriptions.d.ts +7 -0
- package/dist/nodes/ZeroGpu/shared/descriptions.js +83 -0
- package/dist/nodes/ZeroGpu/shared/descriptions.js.map +1 -0
- package/dist/nodes/ZeroGpu/shared/operations.d.ts +3 -0
- package/dist/nodes/ZeroGpu/shared/operations.js +19 -0
- package/dist/nodes/ZeroGpu/shared/operations.js.map +1 -0
- package/dist/nodes/ZeroGpu/shared/routing.d.ts +5 -0
- package/dist/nodes/ZeroGpu/shared/routing.js +170 -0
- package/dist/nodes/ZeroGpu/shared/routing.js.map +1 -0
- package/dist/nodes/ZeroGpuChatModel/ZeroGpuChatModel.node.d.ts +10 -0
- package/dist/nodes/ZeroGpuChatModel/ZeroGpuChatModel.node.js +164 -0
- package/dist/nodes/ZeroGpuChatModel/ZeroGpuChatModel.node.js.map +1 -0
- package/dist/nodes/ZeroGpuChatModel/ZeroGpuChatModel.node.json +18 -0
- package/dist/nodes/shared/models.d.ts +19 -0
- package/dist/nodes/shared/models.js +16 -0
- package/dist/nodes/shared/models.js.map +1 -0
- package/dist/package.json +6 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -3
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MODEL_FILTERS = void 0;
|
|
4
|
+
const models_1 = require("../../shared/models");
|
|
5
|
+
const hasUsecase = (usecase) => ({ modelUsecases }) => Boolean(modelUsecases && usecase in modelUsecases);
|
|
6
|
+
exports.MODEL_FILTERS = {
|
|
7
|
+
classifyByLabels: ({ taskType }) => taskType === 'classification',
|
|
8
|
+
classifyBySchema: hasUsecase('classification'),
|
|
9
|
+
classifyDomain: ({ taskType }) => taskType === 'iab_classify_domain',
|
|
10
|
+
classifyIab: ({ taskType }) => taskType === 'iab_classify',
|
|
11
|
+
detectPii: hasUsecase('ner'),
|
|
12
|
+
extractEntities: hasUsecase('ner'),
|
|
13
|
+
extractJson: hasUsecase('json'),
|
|
14
|
+
extractText: ({ modelId }) => modelId === models_1.OCR_MODEL_ID,
|
|
15
|
+
moderate: ({ taskType }) => taskType === 'moderation',
|
|
16
|
+
redactPii: hasUsecase('ner'),
|
|
17
|
+
summarize: ({ taskDisplayName }) => taskDisplayName === 'Summarization',
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.js","sourceRoot":"","sources":["../../../../nodes/ZeroGpu/shared/operations.ts"],"names":[],"mappings":";;;AAAA,gDAAsE;AAetE,MAAM,UAAU,GACf,CAAC,OAAe,EAAE,EAAE,CACpB,CAAC,EAAE,aAAa,EAAgB,EAAW,EAAE,CAC5C,OAAO,CAAC,aAAa,IAAI,OAAO,IAAI,aAAa,CAAC,CAAC;AAGxC,QAAA,aAAa,GAAwD;IACjF,gBAAgB,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,KAAK,gBAAgB;IACjE,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,CAAC;IAC9C,cAAc,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,KAAK,qBAAqB;IACpE,WAAW,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,KAAK,cAAc;IAC1D,SAAS,EAAE,UAAU,CAAC,KAAK,CAAC;IAC5B,eAAe,EAAE,UAAU,CAAC,KAAK,CAAC;IAClC,WAAW,EAAE,UAAU,CAAC,MAAM,CAAC;IAC/B,WAAW,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,KAAK,qBAAY;IACtD,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,KAAK,YAAY;IACrD,SAAS,EAAE,UAAU,CAAC,KAAK,CAAC;IAC5B,SAAS,EAAE,CAAC,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC,eAAe,KAAK,eAAe;CACvE,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IExecuteSingleFunctions, IHttpRequestOptions, IN8nHttpFullResponse, INodeExecutionData, INodePropertyRouting } from 'n8n-workflow';
|
|
2
|
+
export declare function buildRequestBody(this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions>;
|
|
3
|
+
export declare function parseResult(this: IExecuteSingleFunctions, _items: INodeExecutionData[], response: IN8nHttpFullResponse): Promise<INodeExecutionData[]>;
|
|
4
|
+
export declare const chatCompletionsRouting: INodePropertyRouting;
|
|
5
|
+
export declare const moderationsRouting: INodePropertyRouting;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.moderationsRouting = exports.chatCompletionsRouting = void 0;
|
|
4
|
+
exports.buildRequestBody = buildRequestBody;
|
|
5
|
+
exports.parseResult = parseResult;
|
|
6
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
7
|
+
const SUMMARY_PROMPT = "Summarize the user's text faithfully and concisely. Reply with the summary only.";
|
|
8
|
+
function fail(context, message, description) {
|
|
9
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), message, {
|
|
10
|
+
itemIndex: context.getItemIndex(),
|
|
11
|
+
description,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
function getRequiredString(context, name, label) {
|
|
15
|
+
var _a;
|
|
16
|
+
const value = String((_a = context.getNodeParameter(name)) !== null && _a !== void 0 ? _a : '');
|
|
17
|
+
if (value.trim() === '')
|
|
18
|
+
fail(context, `Enter the ${label}`);
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
function getLabels(context) {
|
|
22
|
+
var _a;
|
|
23
|
+
const labels = String((_a = context.getNodeParameter('labels')) !== null && _a !== void 0 ? _a : '')
|
|
24
|
+
.split(',')
|
|
25
|
+
.map((label) => label.trim())
|
|
26
|
+
.filter((label) => label !== '');
|
|
27
|
+
if (labels.length === 0)
|
|
28
|
+
fail(context, 'Enter at least one label, separated by commas');
|
|
29
|
+
return labels;
|
|
30
|
+
}
|
|
31
|
+
function getSchema(context, example) {
|
|
32
|
+
const shape = `Schema must be a JSON object that maps each name to a list of strings, like ${example}`;
|
|
33
|
+
const value = context.getNodeParameter('schema');
|
|
34
|
+
let schema = value;
|
|
35
|
+
if (typeof value === 'string') {
|
|
36
|
+
try {
|
|
37
|
+
schema = (0, n8n_workflow_1.jsonParse)(value);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
fail(context, 'Schema is not valid JSON', shape);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const isValid = typeof schema === 'object' &&
|
|
44
|
+
schema !== null &&
|
|
45
|
+
!Array.isArray(schema) &&
|
|
46
|
+
Object.keys(schema).length > 0 &&
|
|
47
|
+
Object.values(schema).every((items) => Array.isArray(items) &&
|
|
48
|
+
items.length > 0 &&
|
|
49
|
+
items.every((item) => typeof item === 'string' && item.trim() !== ''));
|
|
50
|
+
if (!isValid)
|
|
51
|
+
fail(context, shape);
|
|
52
|
+
return schema;
|
|
53
|
+
}
|
|
54
|
+
function getThreshold(context) {
|
|
55
|
+
const { threshold } = context.getNodeParameter('options', {});
|
|
56
|
+
if (threshold === undefined)
|
|
57
|
+
return {};
|
|
58
|
+
if (typeof threshold !== 'number' || !(threshold >= 0 && threshold <= 1)) {
|
|
59
|
+
fail(context, 'Threshold must be a number from 0 to 1');
|
|
60
|
+
}
|
|
61
|
+
return { threshold };
|
|
62
|
+
}
|
|
63
|
+
function chatBody(model, messages, metadata) {
|
|
64
|
+
return metadata ? { model, messages, metadata } : { model, messages };
|
|
65
|
+
}
|
|
66
|
+
function buildBody(context, operation) {
|
|
67
|
+
const model = getRequiredString(context, 'model', 'Model');
|
|
68
|
+
const user = (content) => ({ role: 'user', content });
|
|
69
|
+
const text = () => user(getRequiredString(context, 'text', 'Text'));
|
|
70
|
+
switch (operation) {
|
|
71
|
+
case 'classifyByLabels':
|
|
72
|
+
return chatBody(model, [
|
|
73
|
+
{ role: 'system', content: `[${getLabels(context).join(',')}]` },
|
|
74
|
+
text(),
|
|
75
|
+
]);
|
|
76
|
+
case 'classifyBySchema':
|
|
77
|
+
return chatBody(model, [text()], {
|
|
78
|
+
usecase: 'classification',
|
|
79
|
+
schema: getSchema(context, '{"sentiment": ["positive", "negative"]}'),
|
|
80
|
+
...getThreshold(context),
|
|
81
|
+
});
|
|
82
|
+
case 'classifyDomain':
|
|
83
|
+
return chatBody(model, [user(getRequiredString(context, 'domain', 'Domain'))]);
|
|
84
|
+
case 'classifyIab':
|
|
85
|
+
return chatBody(model, [text()]);
|
|
86
|
+
case 'detectPii':
|
|
87
|
+
case 'extractEntities':
|
|
88
|
+
case 'redactPii':
|
|
89
|
+
return chatBody(model, [text()], {
|
|
90
|
+
usecase: 'ner',
|
|
91
|
+
labels: getLabels(context),
|
|
92
|
+
...getThreshold(context),
|
|
93
|
+
});
|
|
94
|
+
case 'extractJson':
|
|
95
|
+
return chatBody(model, [text()], {
|
|
96
|
+
usecase: 'json',
|
|
97
|
+
schema: getSchema(context, '{"contact": ["name::str::Full name"]}'),
|
|
98
|
+
});
|
|
99
|
+
case 'extractText': {
|
|
100
|
+
const url = getRequiredString(context, 'documentUrl', 'Document URL').trim();
|
|
101
|
+
const filename = url.split(/[?#]/)[0].split('/').pop() || 'document';
|
|
102
|
+
return chatBody(model, [
|
|
103
|
+
{ role: 'user', content: [{ type: 'file', file: { filename, file_data: url } }] },
|
|
104
|
+
]);
|
|
105
|
+
}
|
|
106
|
+
case 'moderate':
|
|
107
|
+
return { model, input: getRequiredString(context, 'text', 'Text') };
|
|
108
|
+
case 'summarize':
|
|
109
|
+
return chatBody(model, [{ role: 'system', content: SUMMARY_PROMPT }, text()]);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async function buildRequestBody(requestOptions) {
|
|
113
|
+
requestOptions.body = buildBody(this, this.getNodeParameter('operation'));
|
|
114
|
+
return requestOptions;
|
|
115
|
+
}
|
|
116
|
+
function isObject(value) {
|
|
117
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
118
|
+
}
|
|
119
|
+
function redact(text, entities) {
|
|
120
|
+
return Object.entries(entities)
|
|
121
|
+
.flatMap(([label, values]) => values
|
|
122
|
+
.filter((value) => typeof value === 'string' && value !== '')
|
|
123
|
+
.map((value) => ({
|
|
124
|
+
value,
|
|
125
|
+
tag: `[${label.trim().toUpperCase().replace(/\s+/g, '_')}]`,
|
|
126
|
+
})))
|
|
127
|
+
.sort((a, b) => b.value.length - a.value.length)
|
|
128
|
+
.reduce((result, { value, tag }) => result.split(value).join(tag), text);
|
|
129
|
+
}
|
|
130
|
+
async function parseResult(_items, response) {
|
|
131
|
+
var _a, _b, _c;
|
|
132
|
+
const operation = this.getNodeParameter('operation');
|
|
133
|
+
const body = response.body;
|
|
134
|
+
const content = (_c = (_b = (_a = body === null || body === void 0 ? void 0 : body.choices) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.message) === null || _c === void 0 ? void 0 : _c.content;
|
|
135
|
+
if (typeof content !== 'string') {
|
|
136
|
+
fail(this, 'ZeroGPU returned no result', JSON.stringify(response.body));
|
|
137
|
+
}
|
|
138
|
+
if (operation === 'summarize')
|
|
139
|
+
return [{ json: { summary: content } }];
|
|
140
|
+
if (operation === 'extractText')
|
|
141
|
+
return [{ json: { markdown: content } }];
|
|
142
|
+
let result;
|
|
143
|
+
try {
|
|
144
|
+
result = (0, n8n_workflow_1.jsonParse)(content);
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
fail(this, "ZeroGPU returned a result that isn't JSON", content);
|
|
148
|
+
}
|
|
149
|
+
if (!isObject(result))
|
|
150
|
+
fail(this, "ZeroGPU returned a result that isn't a JSON object", content);
|
|
151
|
+
if (operation === 'redactPii') {
|
|
152
|
+
const { entities } = result;
|
|
153
|
+
if (!isObject(entities) || !Object.values(entities).every(Array.isArray)) {
|
|
154
|
+
fail(this, 'ZeroGPU returned entities in an unexpected shape', content);
|
|
155
|
+
}
|
|
156
|
+
const text = this.getNodeParameter('text');
|
|
157
|
+
return [{ json: { text: redact(text, entities), entities } }];
|
|
158
|
+
}
|
|
159
|
+
return [{ json: result }];
|
|
160
|
+
}
|
|
161
|
+
exports.chatCompletionsRouting = {
|
|
162
|
+
request: { method: 'POST', url: '/chat/completions' },
|
|
163
|
+
send: { preSend: [buildRequestBody] },
|
|
164
|
+
output: { postReceive: [parseResult] },
|
|
165
|
+
};
|
|
166
|
+
exports.moderationsRouting = {
|
|
167
|
+
request: { method: 'POST', url: '/moderations' },
|
|
168
|
+
send: { preSend: [buildRequestBody] },
|
|
169
|
+
};
|
|
170
|
+
//# sourceMappingURL=routing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routing.js","sourceRoot":"","sources":["../../../../nodes/ZeroGpu/shared/routing.ts"],"names":[],"mappings":";;;AAiIA,4CAMC;AAqBD,kCAiCC;AArLD,+CAA6D;AAG7D,MAAM,cAAc,GACnB,kFAAkF,CAAC;AAIpF,SAAS,IAAI,CAAC,OAAgC,EAAE,OAAe,EAAE,WAAoB;IACpF,MAAM,IAAI,iCAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE;QACxD,SAAS,EAAE,OAAO,CAAC,YAAY,EAAE;QACjC,WAAW;KACX,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,OAAgC,EAAE,IAAY,EAAE,KAAa;;IACvF,MAAM,KAAK,GAAG,MAAM,CAAC,MAAA,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,mCAAI,EAAE,CAAC,CAAC;IAC3D,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,IAAI,CAAC,OAAO,EAAE,aAAa,KAAK,EAAE,CAAC,CAAC;IAC7D,OAAO,KAAK,CAAC;AACd,CAAC;AAED,SAAS,SAAS,CAAC,OAAgC;;IAClD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAA,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,mCAAI,EAAE,CAAC;SAC7D,KAAK,CAAC,GAAG,CAAC;S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,OAAO,EAAE,CAAC,gBAAgB,CAAC,EAAE;CACrC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ILoadOptionsFunctions, INodePropertyOptions, INodeType, INodeTypeDescription, ISupplyDataFunctions, SupplyData } from 'n8n-workflow';
|
|
2
|
+
export declare class ZeroGpuChatModel implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
methods: {
|
|
5
|
+
loadOptions: {
|
|
6
|
+
getModels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZeroGpuChatModel = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const ai_node_sdk_1 = require("@n8n/ai-node-sdk");
|
|
6
|
+
const models_1 = require("../shared/models");
|
|
7
|
+
const BASE_URL = 'https://api.zerogpu.ai/v1';
|
|
8
|
+
const CHAT_TASKS = ['Text Generation', 'Summarization'];
|
|
9
|
+
function isChatModel({ chat, taskDisplayName, taskType, modelId }) {
|
|
10
|
+
if (chat !== undefined)
|
|
11
|
+
return chat !== null;
|
|
12
|
+
return (CHAT_TASKS.includes(taskDisplayName !== null && taskDisplayName !== void 0 ? taskDisplayName : '') &&
|
|
13
|
+
taskType !== 'moderation' &&
|
|
14
|
+
modelId !== models_1.OCR_MODEL_ID);
|
|
15
|
+
}
|
|
16
|
+
async function assertSettingsSupported(context, model, options, itemIndex) {
|
|
17
|
+
var _a;
|
|
18
|
+
let models;
|
|
19
|
+
try {
|
|
20
|
+
models = await (0, models_1.fetchModels)(context);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const capabilities = (_a = models.find(({ modelId }) => modelId === model)) === null || _a === void 0 ? void 0 : _a.chat;
|
|
26
|
+
if (!capabilities)
|
|
27
|
+
return;
|
|
28
|
+
const unsupported = [];
|
|
29
|
+
if (options.maxTokens !== undefined && capabilities.maxTokens === false) {
|
|
30
|
+
unsupported.push('Maximum Tokens');
|
|
31
|
+
}
|
|
32
|
+
if (options.reasoningEffort !== undefined && capabilities.reasoningEffort === false) {
|
|
33
|
+
unsupported.push('Reasoning Effort');
|
|
34
|
+
}
|
|
35
|
+
if (unsupported.length > 0) {
|
|
36
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), `${model} doesn't support ${unsupported.join(' or ')}. Remove it from Options or choose another model.`, { itemIndex });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
class ZeroGpuChatModel {
|
|
40
|
+
constructor() {
|
|
41
|
+
this.description = {
|
|
42
|
+
displayName: 'ZeroGPU Chat Model',
|
|
43
|
+
name: 'zeroGpuChatModel',
|
|
44
|
+
icon: { light: 'file:../../icons/zerogpu.svg', dark: 'file:../../icons/zerogpu.dark.svg' },
|
|
45
|
+
group: ['transform'],
|
|
46
|
+
version: [1],
|
|
47
|
+
subtitle: '={{$parameter["model"]}}',
|
|
48
|
+
description: 'Use ZeroGPU small and nano language models in AI workflows',
|
|
49
|
+
defaults: {
|
|
50
|
+
name: 'ZeroGPU Chat Model',
|
|
51
|
+
},
|
|
52
|
+
codex: {
|
|
53
|
+
categories: ['assistant'],
|
|
54
|
+
subcategories: {
|
|
55
|
+
AI: ['Language Models', 'Root Nodes'],
|
|
56
|
+
'Language Models': ['Chat Models (Recommended)'],
|
|
57
|
+
},
|
|
58
|
+
resources: {
|
|
59
|
+
primaryDocumentation: [{ url: 'https://github.com/zerogpu/n8n-nodes-zerogpu#readme' }],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
inputs: [],
|
|
63
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.AiLanguageModel],
|
|
64
|
+
outputNames: ['Model'],
|
|
65
|
+
credentials: [
|
|
66
|
+
{
|
|
67
|
+
name: 'zeroGpuApi',
|
|
68
|
+
required: true,
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
properties: [
|
|
72
|
+
{
|
|
73
|
+
displayName: 'Model Name or ID',
|
|
74
|
+
name: 'model',
|
|
75
|
+
type: 'options',
|
|
76
|
+
required: true,
|
|
77
|
+
typeOptions: {
|
|
78
|
+
loadOptionsMethod: 'getModels',
|
|
79
|
+
allowArbitraryValues: true,
|
|
80
|
+
},
|
|
81
|
+
default: 'deepseek-v4.1-flash',
|
|
82
|
+
description: 'The model which will generate the completion. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
displayName: 'Options',
|
|
86
|
+
name: 'options',
|
|
87
|
+
placeholder: 'Add Option',
|
|
88
|
+
description: 'Additional options to add',
|
|
89
|
+
type: 'collection',
|
|
90
|
+
default: {},
|
|
91
|
+
options: [
|
|
92
|
+
{
|
|
93
|
+
displayName: 'Maximum Tokens',
|
|
94
|
+
name: 'maxTokens',
|
|
95
|
+
type: 'number',
|
|
96
|
+
default: 1024,
|
|
97
|
+
typeOptions: { minValue: 1 },
|
|
98
|
+
description: 'The maximum number of tokens to generate in the response',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
displayName: 'Reasoning Effort',
|
|
102
|
+
name: 'reasoningEffort',
|
|
103
|
+
type: 'options',
|
|
104
|
+
default: 'medium',
|
|
105
|
+
options: [
|
|
106
|
+
{ name: 'Extra High', value: 'xhigh' },
|
|
107
|
+
{ name: 'High', value: 'high' },
|
|
108
|
+
{ name: 'Low', value: 'low' },
|
|
109
|
+
{ name: 'Medium', value: 'medium' },
|
|
110
|
+
{ name: 'Minimal', value: 'minimal' },
|
|
111
|
+
{ name: 'None', value: 'none' },
|
|
112
|
+
],
|
|
113
|
+
description: 'How much the model reasons before it answers',
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
displayName: 'Sampling Temperature',
|
|
117
|
+
name: 'temperature',
|
|
118
|
+
type: 'number',
|
|
119
|
+
default: 0.7,
|
|
120
|
+
typeOptions: { maxValue: 2, minValue: 0, numberPrecision: 1 },
|
|
121
|
+
description: 'Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive.',
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
};
|
|
127
|
+
this.methods = {
|
|
128
|
+
loadOptions: {
|
|
129
|
+
async getModels() {
|
|
130
|
+
const models = await (0, models_1.fetchModels)(this);
|
|
131
|
+
return models
|
|
132
|
+
.filter(isChatModel)
|
|
133
|
+
.map(({ modelId, modelDisplayName, pricing, chat }) => ({
|
|
134
|
+
name: (chat === null || chat === void 0 ? void 0 : chat.tools) === false ? `${modelDisplayName} (no tool calling)` : modelDisplayName,
|
|
135
|
+
value: modelId,
|
|
136
|
+
description: pricing === null || pricing === void 0 ? void 0 : pricing.description,
|
|
137
|
+
}))
|
|
138
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
async supplyData(itemIndex) {
|
|
144
|
+
const model = this.getNodeParameter('model', itemIndex);
|
|
145
|
+
const options = this.getNodeParameter('options', itemIndex, {});
|
|
146
|
+
if (options.maxTokens !== undefined || options.reasoningEffort !== undefined) {
|
|
147
|
+
await assertSettingsSupported(this, model, options, itemIndex);
|
|
148
|
+
}
|
|
149
|
+
const credentials = await this.getCredentials('zeroGpuApi');
|
|
150
|
+
return (0, ai_node_sdk_1.supplyModel)(this, {
|
|
151
|
+
type: 'openai',
|
|
152
|
+
baseUrl: BASE_URL,
|
|
153
|
+
apiKey: credentials.apiKey,
|
|
154
|
+
model,
|
|
155
|
+
temperature: options.temperature,
|
|
156
|
+
maxTokens: options.maxTokens,
|
|
157
|
+
additionalParams: options.reasoningEffort
|
|
158
|
+
? { reasoning_effort: options.reasoningEffort }
|
|
159
|
+
: undefined,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
exports.ZeroGpuChatModel = ZeroGpuChatModel;
|
|
164
|
+
//# sourceMappingURL=ZeroGpuChatModel.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZeroGpuChatModel.node.js","sourceRoot":"","sources":["../../../nodes/ZeroGpuChatModel/ZeroGpuChatModel.node.ts"],"names":[],"mappings":";;;AAQA,+CAAuE;AACvE,kDAA+C;AAC/C,6CAAgF;AAEhF,MAAM,QAAQ,GAAG,2BAA2B,CAAC;AAE7C,MAAM,UAAU,GAAG,CAAC,iBAAiB,EAAE,eAAe,CAAC,CAAC;AAUxD,SAAS,WAAW,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,OAAO,EAAgB;IAC9E,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,IAAI,KAAK,IAAI,CAAC;IAE7C,OAAO,CACN,UAAU,CAAC,QAAQ,CAAC,eAAe,aAAf,eAAe,cAAf,eAAe,GAAI,EAAE,CAAC;QAC1C,QAAQ,KAAK,YAAY;QACzB,OAAO,KAAK,qBAAY,CACxB,CAAC;AACH,CAAC;AAGD,KAAK,UAAU,uBAAuB,CACrC,OAA6B,EAC7B,KAAa,EACb,OAAqB,EACrB,SAAiB;;IAEjB,IAAI,MAAsB,CAAC;IAC3B,IAAI,CAAC;QACJ,MAAM,GAAG,MAAM,IAAA,oBAAW,EAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QAER,OAAO;IACR,CAAC;IAED,MAAM,YAAY,GAAG,MAAA,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,CAAC,0CAAE,IAAI,CAAC;IAC3E,IAAI,CAAC,YAAY;QAAE,OAAO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AClE,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,CAAiB,CAAC;QAEhF,IAAI,OAAO,CAAC,SAAS,KAAK,SAAS,IAAI,OAAO,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;YAC9E,MAAM,uBAAuB,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QAChE,CAAC;QAED,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;QAE5D,OAAO,IAAA,yBAAW,EAAC,IAAI,EAAE;YACxB,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,QAAQ;YACjB,MAAM,EAAE,WAAW,CAAC,MAAgB;YACpC,KAAK;YACL,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,SAAS,EAAE,OAAO,CAAC,SAAS;YAE5B,gBAAgB,EAAE,OAAO,CAAC,eAAe;gBACxC,CAAC,CAAC,EAAE,gBAAgB,EAAE,OAAO,CAAC,eAAe,EAAE;gBAC/C,CAAC,CAAC,SAAS;SACZ,CAAC,CAAC;IACJ,CAAC;CACD;AAnID,4CAmIC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"node": "@zerogpu/n8n-nodes-zerogpu",
|
|
3
|
+
"nodeVersion": "1.0",
|
|
4
|
+
"codexVersion": "1.0",
|
|
5
|
+
"categories": ["Development"],
|
|
6
|
+
"resources": {
|
|
7
|
+
"credentialDocumentation": [
|
|
8
|
+
{
|
|
9
|
+
"url": "https://docs.zerogpu.ai/docs/quickstart"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"primaryDocumentation": [
|
|
13
|
+
{
|
|
14
|
+
"url": "https://github.com/zerogpu/n8n-nodes-zerogpu#readme"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ILoadOptionsFunctions, ISupplyDataFunctions } from 'n8n-workflow';
|
|
2
|
+
export declare const MODELS_URL = "https://api-dashboard.zerogpu.ai/api/models";
|
|
3
|
+
export declare const OCR_MODEL_ID = "unlimited-ocr";
|
|
4
|
+
export type ZeroGpuModel = {
|
|
5
|
+
modelId: string;
|
|
6
|
+
modelDisplayName: string;
|
|
7
|
+
taskDisplayName?: string | null;
|
|
8
|
+
taskType?: string | null;
|
|
9
|
+
modelUsecases?: Record<string, unknown> | null;
|
|
10
|
+
pricing?: {
|
|
11
|
+
description?: string;
|
|
12
|
+
} | null;
|
|
13
|
+
chat?: {
|
|
14
|
+
tools: boolean;
|
|
15
|
+
maxTokens: boolean;
|
|
16
|
+
reasoningEffort: boolean;
|
|
17
|
+
} | null;
|
|
18
|
+
};
|
|
19
|
+
export declare function fetchModels(context: ILoadOptionsFunctions | ISupplyDataFunctions): Promise<ZeroGpuModel[]>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OCR_MODEL_ID = exports.MODELS_URL = void 0;
|
|
4
|
+
exports.fetchModels = fetchModels;
|
|
5
|
+
exports.MODELS_URL = 'https://api-dashboard.zerogpu.ai/api/models';
|
|
6
|
+
exports.OCR_MODEL_ID = 'unlimited-ocr';
|
|
7
|
+
async function fetchModels(context) {
|
|
8
|
+
var _a;
|
|
9
|
+
const response = (await context.helpers.httpRequest({
|
|
10
|
+
method: 'GET',
|
|
11
|
+
url: exports.MODELS_URL,
|
|
12
|
+
json: true,
|
|
13
|
+
}));
|
|
14
|
+
return (_a = response.models) !== null && _a !== void 0 ? _a : [];
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../nodes/shared/models.ts"],"names":[],"mappings":";;;AAkBA,kCAUC;AA1BY,QAAA,UAAU,GAAG,6CAA6C,CAAC;AAG3D,QAAA,YAAY,GAAG,eAAe,CAAC;AAarC,KAAK,UAAU,WAAW,CAChC,OAAqD;;IAErD,MAAM,QAAQ,GAAG,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC;QACnD,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,kBAAU;QACf,IAAI,EAAE,IAAI;KACV,CAAC,CAAgC,CAAC;IAEnC,OAAO,MAAA,QAAQ,CAAC,MAAM,mCAAI,EAAE,CAAC;AAC9B,CAAC"}
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zerogpu/n8n-nodes-zerogpu",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Official ZeroGPU nodes for n8n. ZeroGPU is a compute-efficient inference provider for apps and agents — purpose-built small and nano language models on an edge network that run the repeatable tasks frontier models shouldn’t, ~10x faster and 50%+ cheaper. Auto-scaling, with zero GPU infrastructure. Plug in and you’re live.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://zerogpu.ai",
|
|
@@ -39,11 +39,13 @@
|
|
|
39
39
|
"n8n": {
|
|
40
40
|
"n8nNodesApiVersion": 1,
|
|
41
41
|
"strict": true,
|
|
42
|
+
"aiNodeSdkVersion": 1,
|
|
42
43
|
"credentials": [
|
|
43
44
|
"dist/credentials/ZeroGpuApi.credentials.js"
|
|
44
45
|
],
|
|
45
46
|
"nodes": [
|
|
46
|
-
"dist/nodes/ZeroGpu/ZeroGpu.node.js"
|
|
47
|
+
"dist/nodes/ZeroGpu/ZeroGpu.node.js",
|
|
48
|
+
"dist/nodes/ZeroGpuChatModel/ZeroGpuChatModel.node.js"
|
|
47
49
|
]
|
|
48
50
|
},
|
|
49
51
|
"devDependencies": {
|
|
@@ -54,6 +56,7 @@
|
|
|
54
56
|
"typescript": "5.9.2"
|
|
55
57
|
},
|
|
56
58
|
"peerDependencies": {
|
|
57
|
-
"n8n-workflow": "*"
|
|
59
|
+
"n8n-workflow": "*",
|
|
60
|
+
"@n8n/ai-node-sdk": "*"
|
|
58
61
|
}
|
|
59
62
|
}
|