n8n-nodes-vercel-ai-sdk-universal-temp 0.2.71 → 0.2.72

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.
Files changed (39) hide show
  1. package/package.json +5 -3
  2. package/dist/credentials/UniversalAi.credentials.d.ts +0 -7
  3. package/dist/credentials/UniversalAi.credentials.js +0 -33
  4. package/dist/credentials/UniversalAi.credentials.js.map +0 -1
  5. package/dist/nodes/DeepSeek/DeepSeek.node.d.ts +0 -10
  6. package/dist/nodes/DeepSeek/DeepSeek.node.js +0 -574
  7. package/dist/nodes/DeepSeek/DeepSeek.node.js.map +0 -1
  8. package/dist/nodes/DeepSeek/icons/deepseek.svg +0 -1
  9. package/dist/nodes/GoogleGenerativeAI/GoogleGenerativeAI.node.d.ts +0 -10
  10. package/dist/nodes/GoogleGenerativeAI/GoogleGenerativeAI.node.js +0 -845
  11. package/dist/nodes/GoogleGenerativeAI/GoogleGenerativeAI.node.js.map +0 -1
  12. package/dist/nodes/GoogleGenerativeAI/icons/GoogleGenerativeAI.svg +0 -1
  13. package/dist/nodes/Groq/Groq.node.d.ts +0 -10
  14. package/dist/nodes/Groq/Groq.node.js +0 -552
  15. package/dist/nodes/Groq/Groq.node.js.map +0 -1
  16. package/dist/nodes/Groq/icons/groq.svg +0 -1
  17. package/dist/nodes/UniversalAI/model-lists.d.ts +0 -55
  18. package/dist/nodes/UniversalAI/model-lists.js +0 -269
  19. package/dist/nodes/UniversalAI/model-lists.js.map +0 -1
  20. package/dist/nodes/UniversalAIEmbedding/UniversalEmbedding.node.d.ts +0 -10
  21. package/dist/nodes/UniversalAIEmbedding/UniversalEmbedding.node.js +0 -332
  22. package/dist/nodes/UniversalAIEmbedding/UniversalEmbedding.node.js.map +0 -1
  23. package/dist/nodes/UniversalAIImageGen/UniversalImageGen.node.d.ts +0 -10
  24. package/dist/nodes/UniversalAIImageGen/UniversalImageGen.node.js +0 -359
  25. package/dist/nodes/UniversalAIImageGen/UniversalImageGen.node.js.map +0 -1
  26. package/dist/nodes/shared/builders/descriptions.d.ts +0 -103
  27. package/dist/nodes/shared/builders/descriptions.js +0 -713
  28. package/dist/nodes/shared/builders/descriptions.js.map +0 -1
  29. package/dist/nodes/shared/letta/enhanced-wrapper.d.ts +0 -49
  30. package/dist/nodes/shared/letta/enhanced-wrapper.js +0 -349
  31. package/dist/nodes/shared/letta/enhanced-wrapper.js.map +0 -1
  32. package/dist/nodes/shared/letta/fallback-wrapper.d.ts +0 -56
  33. package/dist/nodes/shared/letta/fallback-wrapper.js +0 -321
  34. package/dist/nodes/shared/letta/fallback-wrapper.js.map +0 -1
  35. package/dist/nodes/shared/letta/wrapper.d.ts +0 -3
  36. package/dist/nodes/shared/letta/wrapper.js +0 -58
  37. package/dist/nodes/shared/letta/wrapper.js.map +0 -1
  38. package/dist/package.json +0 -82
  39. package/dist/tsconfig.tsbuildinfo +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-vercel-ai-sdk-universal-temp",
3
- "version": "0.2.71",
3
+ "version": "0.2.72",
4
4
  "description": "Universal AI SDK n8n nodes integration",
5
5
  "keywords": [
6
6
  "n8n-community-node-package"
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "main": "index.js",
17
17
  "scripts": {
18
- "build": "tsc && gulp build:icons",
18
+ "build": "bun run clean && tsc && gulp build:icons",
19
19
  "dev": "build && tsc --watch",
20
20
  "format": "prettier nodes credentials --write",
21
21
  "lint": "eslint nodes credentials package.json",
@@ -23,13 +23,15 @@
23
23
  "test": "bun test",
24
24
  "test:watch": "jest --watch",
25
25
  "test:coverage": "jest --coverage",
26
- "prepublishOnly": "bun run build"
26
+ "prepublishOnly": "bun run build",
27
+ "clean": "rm -rf dist"
27
28
  },
28
29
  "files": [
29
30
  "dist"
30
31
  ],
31
32
  "n8n": {
32
33
  "n8nNodesApiVersion": 1,
34
+ "strict": true,
33
35
  "credentials": [
34
36
  "dist/credentials/GoogleGenerativeAIApi.credentials.js",
35
37
  "dist/credentials/DeepSeekApi.credentials.js",
@@ -1,7 +0,0 @@
1
- import type { ICredentialType, INodeProperties } from 'n8n-workflow';
2
- export declare class UniversalAiApi implements ICredentialType {
3
- name: string;
4
- displayName: string;
5
- documentationUrl: string;
6
- properties: INodeProperties[];
7
- }
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UniversalAiApi = void 0;
4
- class UniversalAiApi {
5
- constructor() {
6
- this.name = 'universalAiApi';
7
- this.displayName = 'Universal AI API';
8
- this.documentationUrl = 'universal-ai';
9
- this.properties = [
10
- {
11
- displayName: 'API Key',
12
- name: 'apiKey',
13
- type: 'string',
14
- default: '',
15
- required: false,
16
- typeOptions: {
17
- password: true,
18
- },
19
- description: 'Optional API key for the AI provider',
20
- },
21
- {
22
- displayName: 'Base URL',
23
- name: 'baseURL',
24
- type: 'string',
25
- default: '',
26
- required: false,
27
- description: 'Optional custom base URL for the API endpoint',
28
- },
29
- ];
30
- }
31
- }
32
- exports.UniversalAiApi = UniversalAiApi;
33
- //# sourceMappingURL=UniversalAi.credentials.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UniversalAi.credentials.js","sourceRoot":"","sources":["../../credentials/UniversalAi.credentials.ts"],"names":[],"mappings":";;;AAKA,MAAa,cAAc;IAA3B;QACC,SAAI,GAAG,gBAAgB,CAAC;QACxB,gBAAW,GAAG,kBAAkB,CAAC;QACjC,qBAAgB,GAAG,cAAc,CAAC;QAClC,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,KAAK;gBACf,WAAW,EAAE;oBACZ,QAAQ,EAAE,IAAI;iBACd;gBACD,WAAW,EAAE,sCAAsC;aACnD;YACD;gBACC,WAAW,EAAE,UAAU;gBACvB,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,KAAK;gBACf,WAAW,EAAE,+CAA+C;aAC5D;SACD,CAAC;IACH,CAAC;CAAA;AAzBD,wCAyBC"}
@@ -1,10 +0,0 @@
1
- import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription, ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow';
2
- export declare class DeepSeek implements INodeType {
3
- description: INodeTypeDescription;
4
- methods: {
5
- loadOptions: {
6
- getModels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
7
- };
8
- };
9
- execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
10
- }
@@ -1,574 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DeepSeek = void 0;
7
- const n8n_workflow_1 = require("n8n-workflow");
8
- const deepseek_1 = require("@ai-sdk/deepseek");
9
- const ai_1 = require("ai");
10
- const zod_1 = require("zod");
11
- const ajv_1 = __importDefault(require("ajv"));
12
- async function buildInput(exec, itemIndex) {
13
- const inputType = exec.getNodeParameter('inputType', itemIndex);
14
- if (inputType === 'prompt') {
15
- const promptVal = exec.getNodeParameter('prompt', itemIndex);
16
- const systemVal = exec.getNodeParameter('system', itemIndex);
17
- return {
18
- prompt: promptVal,
19
- system: systemVal,
20
- };
21
- }
22
- else {
23
- const messageAsJson = exec.getNodeParameter('messageAsJson', itemIndex, false);
24
- if (messageAsJson) {
25
- const rawJson = exec.getNodeParameter('messagesJson', itemIndex);
26
- let arr;
27
- try {
28
- arr = JSON.parse(rawJson);
29
- }
30
- catch (error) {
31
- throw new n8n_workflow_1.NodeOperationError(exec.getNode(), `Invalid JSON in "Messages (JSON)" field: ${error.message}`);
32
- }
33
- const parseRes = zod_1.z
34
- .array(zod_1.z.object({
35
- role: zod_1.z.enum(['system', 'user', 'assistant']),
36
- content: zod_1.z.string(),
37
- }))
38
- .safeParse(arr);
39
- if (!parseRes.success) {
40
- throw new n8n_workflow_1.NodeOperationError(exec.getNode(), 'Messages must be an array of objects with role and content.');
41
- }
42
- const messages = parseRes.data.map((m) => ({
43
- role: m.role,
44
- content: m.content,
45
- }));
46
- return { messages };
47
- }
48
- else {
49
- const messagesUi = exec.getNodeParameter('messages.messagesUi', itemIndex, []);
50
- const messages = messagesUi.map((msg) => {
51
- const role = msg.role;
52
- return {
53
- role,
54
- content: role === 'system' ? msg.systemContent || '' : msg.content || '',
55
- };
56
- });
57
- return { messages };
58
- }
59
- }
60
- }
61
- function formatTextResult(result, includeRequestBody) {
62
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
63
- const out = {
64
- text: result.text,
65
- reasoning: result === null || result === void 0 ? void 0 : result.reasoning,
66
- finishReason: result.finishReason,
67
- usage: {
68
- promptTokens: (_a = result.usage) === null || _a === void 0 ? void 0 : _a.promptTokens,
69
- completionTokens: (_b = result.usage) === null || _b === void 0 ? void 0 : _b.completionTokens,
70
- totalTokens: (_c = result.usage) === null || _c === void 0 ? void 0 : _c.totalTokens,
71
- cacheMetrics: {
72
- promptCacheHitTokens: (_e = (_d = result.experimental_providerMetadata) === null || _d === void 0 ? void 0 : _d.deepseek) === null || _e === void 0 ? void 0 : _e.promptCacheHitTokens,
73
- promptCacheMissTokens: (_g = (_f = result.experimental_providerMetadata) === null || _f === void 0 ? void 0 : _f.deepseek) === null || _g === void 0 ? void 0 : _g.promptCacheMissTokens,
74
- },
75
- },
76
- response: {
77
- id: (_h = result.response) === null || _h === void 0 ? void 0 : _h.id,
78
- modelId: (_j = result.response) === null || _j === void 0 ? void 0 : _j.modelId,
79
- timestamp: (_k = result.response) === null || _k === void 0 ? void 0 : _k.timestamp,
80
- headers: (_l = result.response) === null || _l === void 0 ? void 0 : _l.headers,
81
- },
82
- warnings: result.warnings || [],
83
- };
84
- if (includeRequestBody) {
85
- out.request = { body: (_m = result.request) === null || _m === void 0 ? void 0 : _m.body };
86
- }
87
- return out;
88
- }
89
- function formatObjectResult(result, includeRequestBody) {
90
- var _a, _b, _c, _d, _e, _f, _g, _h;
91
- const out = {
92
- object: result.object,
93
- finishReason: result.finishReason,
94
- usage: {
95
- promptTokens: (_a = result.usage) === null || _a === void 0 ? void 0 : _a.promptTokens,
96
- completionTokens: (_b = result.usage) === null || _b === void 0 ? void 0 : _b.completionTokens,
97
- totalTokens: (_c = result.usage) === null || _c === void 0 ? void 0 : _c.totalTokens,
98
- },
99
- response: {
100
- id: (_d = result.response) === null || _d === void 0 ? void 0 : _d.id,
101
- modelId: (_e = result.response) === null || _e === void 0 ? void 0 : _e.modelId,
102
- timestamp: (_f = result.response) === null || _f === void 0 ? void 0 : _f.timestamp,
103
- headers: (_g = result.response) === null || _g === void 0 ? void 0 : _g.headers,
104
- },
105
- warnings: result.warnings || [],
106
- };
107
- if (includeRequestBody) {
108
- out.request = { body: (_h = result.request) === null || _h === void 0 ? void 0 : _h.body };
109
- }
110
- return out;
111
- }
112
- class DeepSeek {
113
- constructor() {
114
- this.description = {
115
- displayName: 'DeepSeek',
116
- name: 'deepSeek',
117
- icon: 'file:icons/deepseek.svg',
118
- group: ['transform'],
119
- version: 1,
120
- subtitle: '={{$parameter["operation"] + ": " + $parameter["model"]}}',
121
- description: 'Use DeepSeek models via Vercel AI SDK',
122
- defaults: {
123
- name: 'DeepSeek',
124
- },
125
- inputs: [{ type: "main" }],
126
- outputs: [{ type: "main" }],
127
- credentials: [
128
- {
129
- name: 'deepSeekApi',
130
- required: true,
131
- },
132
- ],
133
- properties: [
134
- {
135
- displayName: 'Model Name or ID',
136
- name: 'model',
137
- type: 'options',
138
- required: true,
139
- typeOptions: {
140
- loadOptionsMethod: 'getModels',
141
- },
142
- default: '',
143
- description: 'Select which DeepSeek model to use. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
144
- },
145
- {
146
- displayName: 'Operation',
147
- name: 'operation',
148
- type: 'options',
149
- required: true,
150
- noDataExpression: true,
151
- options: [
152
- {
153
- name: 'Generate Text',
154
- value: 'generateText',
155
- description: 'Generate text using simple prompt or chat messages',
156
- action: 'Generate text',
157
- },
158
- {
159
- name: 'Generate Object',
160
- value: 'generateObject',
161
- description: 'Generate a structured object based on a JSON schema',
162
- action: 'Generate object',
163
- },
164
- ],
165
- displayOptions: {
166
- show: {
167
- model: ['deepseek-chat'],
168
- },
169
- },
170
- default: 'generateText',
171
- description: 'Which type of output you want to generate',
172
- },
173
- {
174
- displayName: 'Operation',
175
- name: 'operation',
176
- type: 'options',
177
- required: true,
178
- noDataExpression: true,
179
- options: [
180
- {
181
- name: 'Generate Text',
182
- value: 'generateText',
183
- description: 'Generate text using simple prompt or chat messages',
184
- action: 'Generate text',
185
- },
186
- ],
187
- displayOptions: {
188
- show: {
189
- model: ['deepseek-reasoner'],
190
- },
191
- },
192
- default: 'generateText',
193
- description: 'Which type of output you want to generate',
194
- },
195
- {
196
- displayName: 'Input Type',
197
- name: 'inputType',
198
- type: 'options',
199
- required: true,
200
- options: [
201
- {
202
- name: 'Simple Prompt',
203
- value: 'prompt',
204
- description: 'Use a single prompt',
205
- },
206
- {
207
- name: 'Messages',
208
- value: 'messages',
209
- description: 'Use a conversation with multiple messages',
210
- },
211
- ],
212
- default: 'prompt',
213
- description: 'Choose how you want to provide input to the model',
214
- },
215
- {
216
- displayName: 'System',
217
- name: 'system',
218
- type: 'string',
219
- typeOptions: {
220
- rows: 4,
221
- },
222
- displayOptions: {
223
- show: {
224
- inputType: ['prompt'],
225
- },
226
- },
227
- default: 'You are a helpful assistant.',
228
- description: "System prompt that specifies the model's behavior",
229
- hint: "This field is optional, but can help guide the model's responses.",
230
- requiresDataPath: 'single',
231
- },
232
- {
233
- displayName: 'Prompt',
234
- name: 'prompt',
235
- type: 'string',
236
- typeOptions: {
237
- rows: 4,
238
- },
239
- displayOptions: {
240
- show: {
241
- inputType: ['prompt'],
242
- },
243
- },
244
- default: '',
245
- required: true,
246
- description: 'The single text prompt to generate a completion for',
247
- hint: 'You can drag data from previous nodes here using expressions.',
248
- requiresDataPath: 'single',
249
- },
250
- {
251
- displayName: 'Messages',
252
- name: 'messages',
253
- type: 'fixedCollection',
254
- typeOptions: {
255
- multipleValues: true,
256
- sortable: true,
257
- minValue: 1,
258
- },
259
- displayOptions: {
260
- show: {
261
- inputType: ['messages'],
262
- messageAsJson: [false],
263
- },
264
- },
265
- description: 'The messages for the conversation',
266
- default: {
267
- messagesUi: [
268
- {
269
- role: 'system',
270
- systemContent: 'You are a helpful assistant.',
271
- },
272
- {
273
- role: 'user',
274
- content: 'How can you help me?',
275
- },
276
- ],
277
- },
278
- required: true,
279
- options: [
280
- {
281
- name: 'messagesUi',
282
- displayName: 'Message',
283
- values: [
284
- {
285
- displayName: 'Role',
286
- name: 'role',
287
- type: 'options',
288
- options: [
289
- {
290
- name: 'Assistant',
291
- value: 'assistant',
292
- },
293
- {
294
- name: 'System',
295
- value: 'system',
296
- },
297
- {
298
- name: 'User',
299
- value: 'user',
300
- },
301
- ],
302
- default: 'user',
303
- required: true,
304
- },
305
- {
306
- displayName: 'System Content',
307
- name: 'systemContent',
308
- type: 'string',
309
- description: 'The text content if role is System',
310
- required: true,
311
- typeOptions: {
312
- rows: 4,
313
- },
314
- default: '',
315
- displayOptions: {
316
- show: {
317
- role: ['system'],
318
- },
319
- },
320
- requiresDataPath: 'single',
321
- },
322
- {
323
- displayName: 'Content',
324
- name: 'content',
325
- type: 'string',
326
- typeOptions: {
327
- rows: 4,
328
- },
329
- displayOptions: {
330
- show: {
331
- role: ['assistant', 'user'],
332
- },
333
- },
334
- default: '',
335
- description: 'The text content of the message',
336
- required: true,
337
- requiresDataPath: 'single',
338
- },
339
- ],
340
- },
341
- ],
342
- },
343
- {
344
- displayName: 'Messages as JSON',
345
- name: 'messageAsJson',
346
- type: 'boolean',
347
- default: false,
348
- description: 'Whether to input messages as a JSON array instead of using the UI',
349
- displayOptions: {
350
- show: {
351
- operation: ['generateText', 'generateObject'],
352
- inputType: ['messages'],
353
- },
354
- },
355
- },
356
- {
357
- displayName: 'Messages (JSON)',
358
- name: 'messagesJson',
359
- type: 'string',
360
- default: '=[{"role": "user", "content": "Hello!"}]',
361
- description: 'Enter an array of message objects in JSON format (role, content)',
362
- required: true,
363
- typeOptions: {
364
- rows: 4,
365
- },
366
- noDataExpression: false,
367
- requiresDataPath: 'single',
368
- displayOptions: {
369
- show: {
370
- operation: ['generateText', 'generateObject'],
371
- inputType: ['messages'],
372
- messageAsJson: [true],
373
- },
374
- },
375
- },
376
- {
377
- displayName: 'Schema Name',
378
- name: 'schemaName',
379
- type: 'string',
380
- default: '',
381
- description: 'Name of the output schema (optional)',
382
- hint: 'Some providers use this name for additional guidance when generating objects.',
383
- displayOptions: {
384
- show: {
385
- operation: ['generateObject'],
386
- model: ['deepseek-chat'],
387
- },
388
- },
389
- },
390
- {
391
- displayName: 'Schema Description',
392
- name: 'schemaDescription',
393
- type: 'string',
394
- default: '',
395
- description: 'Description of the output schema (optional)',
396
- hint: 'Some providers use this description for additional guidance when generating objects.',
397
- displayOptions: {
398
- show: {
399
- operation: ['generateObject'],
400
- model: ['deepseek-chat'],
401
- },
402
- },
403
- },
404
- {
405
- displayName: 'Schema',
406
- name: 'schema',
407
- type: 'json',
408
- displayOptions: {
409
- show: {
410
- operation: ['generateObject'],
411
- model: ['deepseek-chat'],
412
- },
413
- },
414
- default: `{\n\t"type": "object",\n\t"properties": {\n\t\t"sentiment": {\n\t\t"type": "string",\n\t\t"enum": ["positive","negative","neutral"],\n\t\t"description": "The overall sentiment of the text"\n\t\t},\n\t\t"score": {\n\t\t"type": "number",\n\t\t"minimum": -1,\n\t\t"maximum": 1,\n\t\t"description": "Sentiment score from -1 (negative) to 1 (positive)"\n\t\t},\n\t\t"text": {\n\t\t"type": "string",\n\t\t"description": "The text content to analyze"\n\t\t}\n\t}\n}`,
415
- required: true,
416
- description: 'JSON schema describing the structure and constraints of the object to generate',
417
- hint: 'For example, a schema describing sentiment analysis output.',
418
- requiresDataPath: 'single',
419
- },
420
- {
421
- displayName: 'Options',
422
- name: 'options',
423
- type: 'collection',
424
- placeholder: 'Add Option',
425
- default: {},
426
- options: [
427
- {
428
- displayName: 'Max Tokens',
429
- name: 'maxTokens',
430
- type: 'number',
431
- typeOptions: {
432
- minValue: 1,
433
- },
434
- default: 2048,
435
- description: 'The maximum number of tokens to generate',
436
- },
437
- {
438
- displayName: 'Temperature',
439
- name: 'temperature',
440
- type: 'number',
441
- typeOptions: {
442
- minValue: 0,
443
- maxValue: 2,
444
- numberPrecision: 2,
445
- },
446
- default: 0.7,
447
- description: 'Higher values produce more random outputs',
448
- },
449
- {
450
- displayName: 'Include Request Body',
451
- name: 'includeRequestBody',
452
- type: 'boolean',
453
- default: false,
454
- description: 'Whether to include the request body in the output',
455
- },
456
- ],
457
- },
458
- ],
459
- };
460
- this.methods = {
461
- loadOptions: {
462
- async getModels() {
463
- const credentials = await this.getCredentials('deepSeekApi');
464
- try {
465
- const response = await this.helpers.request({
466
- method: 'GET',
467
- url: 'https://api.deepseek.com/v1/models/list',
468
- headers: {
469
- Authorization: `Bearer ${credentials.apiKey}`,
470
- },
471
- json: true,
472
- });
473
- const returnData = [];
474
- if (response.data) {
475
- for (const model of response.data) {
476
- returnData.push({
477
- name: model.name,
478
- value: model.id,
479
- description: model.description || '',
480
- });
481
- }
482
- }
483
- return returnData.sort((a, b) => a.name.localeCompare(b.name));
484
- }
485
- catch (error) {
486
- return [
487
- {
488
- name: 'DeepSeek Chat',
489
- value: 'deepseek-chat',
490
- description: 'Chat model optimized for conversations and structured outputs',
491
- },
492
- {
493
- name: 'DeepSeek Reasoner',
494
- value: 'deepseek-reasoner',
495
- description: 'Model optimized for reasoning and problem-solving',
496
- },
497
- ].sort((a, b) => a.name.localeCompare(b.name));
498
- }
499
- },
500
- },
501
- };
502
- }
503
- async execute() {
504
- const items = this.getInputData();
505
- const returnData = [];
506
- const credentials = await this.getCredentials('deepSeekApi');
507
- if (!(credentials === null || credentials === void 0 ? void 0 : credentials.apiKey)) {
508
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'No API key provided in credentials');
509
- }
510
- const deepSeekProvider = (0, deepseek_1.createDeepSeek)({
511
- apiKey: credentials.apiKey,
512
- });
513
- for (let i = 0; i < items.length; i++) {
514
- try {
515
- const model = this.getNodeParameter('model', i);
516
- const operation = this.getNodeParameter('operation', i);
517
- const options = this.getNodeParameter('options', i, {});
518
- const input = await buildInput(this, i);
519
- if (operation === 'generateText') {
520
- const result = await (0, ai_1.generateText)({
521
- model: deepSeekProvider(model),
522
- messages: input.messages,
523
- maxTokens: options.maxTokens,
524
- temperature: options.temperature,
525
- prompt: input.prompt,
526
- system: input.system,
527
- });
528
- const formatted = formatTextResult(result, options.includeRequestBody);
529
- returnData.push({ json: formatted });
530
- }
531
- else if (operation === 'generateObject' && model === 'deepseek-chat') {
532
- const schemaName = this.getNodeParameter('schemaName', i, '');
533
- const schemaDescription = this.getNodeParameter('schemaDescription', i, '');
534
- const rawSchema = this.getNodeParameter('schema', i);
535
- let parsedSchema;
536
- try {
537
- parsedSchema = JSON.parse(rawSchema);
538
- }
539
- catch (err) {
540
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Schema is not valid JSON: ' + err.message);
541
- }
542
- const ajv = new ajv_1.default();
543
- if (!ajv.validateSchema(parsedSchema)) {
544
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid JSON Schema: ${ajv.errorsText(ajv.errors)}`);
545
- }
546
- const result = await (0, ai_1.generateObject)({
547
- model: deepSeekProvider(model),
548
- schema: (0, ai_1.jsonSchema)(parsedSchema),
549
- schemaName,
550
- schemaDescription,
551
- prompt: input.prompt,
552
- system: input.system,
553
- messages: input.messages,
554
- maxTokens: options.maxTokens,
555
- temperature: options.temperature,
556
- });
557
- const formatted = formatObjectResult(result, options.includeRequestBody);
558
- returnData.push({ json: formatted });
559
- }
560
- }
561
- catch (error) {
562
- if (this.continueOnFail()) {
563
- returnData.push({ json: { error: error.message } });
564
- }
565
- else {
566
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
567
- }
568
- }
569
- }
570
- return [returnData];
571
- }
572
- }
573
- exports.DeepSeek = DeepSeek;
574
- //# sourceMappingURL=DeepSeek.node.js.map