@n8n/n8n-nodes-langchain 0.12.2 → 0.14.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/dist/build.tsbuildinfo +1 -1
- package/dist/credentials/AzureOpenAiApi.credentials.d.ts +8 -0
- package/dist/credentials/AzureOpenAiApi.credentials.js +44 -0
- package/dist/credentials/AzureOpenAiApi.credentials.js.map +1 -0
- package/dist/known/credentials.json +8 -0
- package/dist/known/nodes.json +12 -0
- package/dist/methods/defined.json +5 -1
- package/dist/methods/referenced.json +5 -1
- package/dist/nodes/agents/Agent/agents/ConversationalAgent/execute.js +3 -3
- package/dist/nodes/agents/Agent/agents/ConversationalAgent/execute.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/ReActAgent/execute.js +2 -2
- package/dist/nodes/agents/Agent/agents/ReActAgent/execute.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/SqlAgent/other/handlers/mysql.d.ts +1 -1
- package/dist/nodes/agents/Agent/agents/SqlAgent/other/handlers/mysql.js +1 -1
- package/dist/nodes/agents/Agent/agents/SqlAgent/other/handlers/mysql.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/SqlAgent/other/handlers/postgres.d.ts +1 -1
- package/dist/nodes/agents/Agent/agents/SqlAgent/other/handlers/postgres.js +1 -1
- package/dist/nodes/agents/Agent/agents/SqlAgent/other/handlers/postgres.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/SqlAgent/other/handlers/sqlite.d.ts +1 -1
- package/dist/nodes/agents/Agent/agents/SqlAgent/other/handlers/sqlite.js +1 -1
- package/dist/nodes/agents/Agent/agents/SqlAgent/other/handlers/sqlite.js.map +1 -1
- package/dist/nodes/agents/OpenAiAssistant/OpenAiAssistant.node.js +1 -0
- package/dist/nodes/agents/OpenAiAssistant/OpenAiAssistant.node.js.map +1 -1
- package/dist/nodes/chains/ChainLLM/ChainLlm.node.js +2 -2
- package/dist/nodes/chains/ChainLLM/ChainLlm.node.js.map +1 -1
- package/dist/nodes/code/Code.node.js +2 -4
- package/dist/nodes/code/Code.node.js.map +1 -1
- package/dist/nodes/embeddings/EmbeddingsAzureOpenAi/EmbeddingsAzureOpenAi.node.d.ts +5 -0
- package/dist/nodes/embeddings/EmbeddingsAzureOpenAi/EmbeddingsAzureOpenAi.node.js +106 -0
- package/dist/nodes/embeddings/EmbeddingsAzureOpenAi/EmbeddingsAzureOpenAi.node.js.map +1 -0
- package/dist/nodes/embeddings/EmbeddingsAzureOpenAi/azure.svg +1 -0
- package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.d.ts +5 -0
- package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js +141 -0
- package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js.map +1 -0
- package/dist/nodes/llms/LmChatAzureOpenAi/azure.svg +1 -0
- package/dist/nodes/output_parser/OutputParserStructured/OutputParserStructured.node.js +1 -1
- package/dist/nodes/output_parser/OutputParserStructured/OutputParserStructured.node.js.map +1 -1
- package/dist/nodes/tools/ToolCode/ToolCode.node.js +14 -7
- package/dist/nodes/tools/ToolCode/ToolCode.node.js.map +1 -1
- package/dist/nodes/tools/ToolWorkflow/ToolWorkflow.node.js +26 -9
- package/dist/nodes/tools/ToolWorkflow/ToolWorkflow.node.js.map +1 -1
- package/dist/nodes/trigger/ChatTrigger/ChatTrigger.node.js.map +1 -1
- package/dist/nodes/vector_store/shared/createVectorStoreNode.js +2 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/OpenAi.node.d.ts +10 -0
- package/dist/nodes/vendors/OpenAi/OpenAi.node.js +20 -0
- package/dist/nodes/vendors/OpenAi/OpenAi.node.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/create.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/create.operation.js +211 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/create.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/deleteAssistant.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/deleteAssistant.operation.js +30 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/deleteAssistant.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/index.d.ts +8 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/index.js +88 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/index.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/list.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/list.operation.js +68 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/list.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/message.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/message.operation.js +149 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/message.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/update.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/update.operation.js +148 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/update.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/audio/generate.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/audio/generate.operation.js +168 -0
- package/dist/nodes/vendors/OpenAi/actions/audio/generate.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/audio/index.d.ts +6 -0
- package/dist/nodes/vendors/OpenAi/actions/audio/index.js +82 -0
- package/dist/nodes/vendors/OpenAi/actions/audio/index.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/audio/transcribe.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/audio/transcribe.operation.js +87 -0
- package/dist/nodes/vendors/OpenAi/actions/audio/transcribe.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/audio/translate.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/audio/translate.operation.js +77 -0
- package/dist/nodes/vendors/OpenAi/actions/audio/translate.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/descriptions.d.ts +3 -0
- package/dist/nodes/vendors/OpenAi/actions/descriptions.js +53 -0
- package/dist/nodes/vendors/OpenAi/actions/descriptions.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/file/deleteFile.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/file/deleteFile.operation.js +59 -0
- package/dist/nodes/vendors/OpenAi/actions/file/deleteFile.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/file/index.d.ts +6 -0
- package/dist/nodes/vendors/OpenAi/actions/file/index.js +70 -0
- package/dist/nodes/vendors/OpenAi/actions/file/index.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/file/list.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/file/list.operation.js +58 -0
- package/dist/nodes/vendors/OpenAi/actions/file/list.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/file/upload.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/file/upload.operation.js +91 -0
- package/dist/nodes/vendors/OpenAi/actions/file/upload.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/image/analyze.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/image/analyze.operation.js +194 -0
- package/dist/nodes/vendors/OpenAi/actions/image/analyze.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/image/generate.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/image/generate.operation.js +227 -0
- package/dist/nodes/vendors/OpenAi/actions/image/generate.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/image/index.d.ts +5 -0
- package/dist/nodes/vendors/OpenAi/actions/image/index.js +61 -0
- package/dist/nodes/vendors/OpenAi/actions/image/index.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/node.type.d.ts +10 -0
- package/dist/nodes/vendors/OpenAi/actions/node.type.js +3 -0
- package/dist/nodes/vendors/OpenAi/actions/node.type.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/router.d.ts +2 -0
- package/dist/nodes/vendors/OpenAi/actions/router.js +81 -0
- package/dist/nodes/vendors/OpenAi/actions/router.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/text/classify.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/text/classify.operation.js +79 -0
- package/dist/nodes/vendors/OpenAi/actions/text/classify.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/text/index.d.ts +5 -0
- package/dist/nodes/vendors/OpenAi/actions/text/index.js +61 -0
- package/dist/nodes/vendors/OpenAi/actions/text/index.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/text/message.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/text/message.operation.js +239 -0
- package/dist/nodes/vendors/OpenAi/actions/text/message.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/versionDescription.d.ts +2 -0
- package/dist/nodes/vendors/OpenAi/actions/versionDescription.js +137 -0
- package/dist/nodes/vendors/OpenAi/actions/versionDescription.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/helpers/interfaces.d.ts +55 -0
- package/dist/nodes/vendors/OpenAi/helpers/interfaces.js +3 -0
- package/dist/nodes/vendors/OpenAi/helpers/interfaces.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/helpers/utils.d.ts +5 -0
- package/dist/nodes/vendors/OpenAi/helpers/utils.js +36 -0
- package/dist/nodes/vendors/OpenAi/helpers/utils.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/methods/index.d.ts +2 -0
- package/dist/nodes/vendors/OpenAi/methods/index.js +29 -0
- package/dist/nodes/vendors/OpenAi/methods/index.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/methods/listSearch.d.ts +4 -0
- package/dist/nodes/vendors/OpenAi/methods/listSearch.js +101 -0
- package/dist/nodes/vendors/OpenAi/methods/listSearch.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/methods/loadOptions.d.ts +2 -0
- package/dist/nodes/vendors/OpenAi/methods/loadOptions.js +17 -0
- package/dist/nodes/vendors/OpenAi/methods/loadOptions.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/openAi.svg +1 -0
- package/dist/nodes/vendors/OpenAi/transport/index.d.ts +10 -0
- package/dist/nodes/vendors/OpenAi/transport/index.js +20 -0
- package/dist/nodes/vendors/OpenAi/transport/index.js.map +1 -0
- package/dist/types/credentials.json +1 -0
- package/dist/types/nodes.json +30 -27
- package/dist/utils/helpers.d.ts +3 -0
- package/dist/utils/helpers.js +7 -1
- package/dist/utils/helpers.js.map +1 -1
- package/dist/utils/logWrapper.js +30 -16
- package/dist/utils/logWrapper.js.map +1 -1
- package/dist/utils/sharedFields.js +3 -1
- package/dist/utils/sharedFields.js.map +1 -1
- package/package.json +14 -8
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.execute = exports.description = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const transport_1 = require("../../transport");
|
|
6
|
+
const properties = [
|
|
7
|
+
{
|
|
8
|
+
displayName: 'Text Input',
|
|
9
|
+
name: 'text',
|
|
10
|
+
type: 'string',
|
|
11
|
+
placeholder: "e.g. What's in this image?",
|
|
12
|
+
default: "What's in this image?",
|
|
13
|
+
typeOptions: {
|
|
14
|
+
rows: 2,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
displayName: 'Input Type',
|
|
19
|
+
name: 'inputType',
|
|
20
|
+
type: 'options',
|
|
21
|
+
default: 'url',
|
|
22
|
+
options: [
|
|
23
|
+
{
|
|
24
|
+
name: 'Image URL(s)',
|
|
25
|
+
value: 'url',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'Binary File(s)',
|
|
29
|
+
value: 'base64',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
displayName: 'URL(s)',
|
|
35
|
+
name: 'imageUrls',
|
|
36
|
+
type: 'string',
|
|
37
|
+
placeholder: 'e.g. https://example.com/image.jpeg',
|
|
38
|
+
description: 'URL(s) of the image(s) to analyze, multiple URLs can be added separated by comma',
|
|
39
|
+
default: '',
|
|
40
|
+
displayOptions: {
|
|
41
|
+
show: {
|
|
42
|
+
inputType: ['url'],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
displayName: 'Input Data Field Name',
|
|
48
|
+
name: 'binaryPropertyName',
|
|
49
|
+
type: 'string',
|
|
50
|
+
default: 'data',
|
|
51
|
+
placeholder: 'e.g. data',
|
|
52
|
+
hint: 'The name of the input field containing the binary file data to be processed',
|
|
53
|
+
description: 'Name of the binary property which contains the image(s)',
|
|
54
|
+
displayOptions: {
|
|
55
|
+
show: {
|
|
56
|
+
inputType: ['base64'],
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
displayName: 'Simplify Output',
|
|
62
|
+
name: 'simplify',
|
|
63
|
+
type: 'boolean',
|
|
64
|
+
default: true,
|
|
65
|
+
description: 'Whether to simplify the response or not',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
displayName: 'Options',
|
|
69
|
+
name: 'options',
|
|
70
|
+
placeholder: 'Add Option',
|
|
71
|
+
type: 'collection',
|
|
72
|
+
default: {},
|
|
73
|
+
options: [
|
|
74
|
+
{
|
|
75
|
+
displayName: 'Detail',
|
|
76
|
+
name: 'detail',
|
|
77
|
+
type: 'options',
|
|
78
|
+
default: 'auto',
|
|
79
|
+
options: [
|
|
80
|
+
{
|
|
81
|
+
name: 'Auto',
|
|
82
|
+
value: 'auto',
|
|
83
|
+
description: 'Model will look at the image input size and decide if it should use the low or high setting',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: 'Low',
|
|
87
|
+
value: 'low',
|
|
88
|
+
description: 'Return faster responses and consume fewer tokens',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: 'High',
|
|
92
|
+
value: 'high',
|
|
93
|
+
description: 'Return more detailed responses, consumes more tokens',
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
displayName: 'Length of Description (Max Tokens)',
|
|
99
|
+
description: 'Fewer tokens will result in shorter, less detailed image description',
|
|
100
|
+
name: 'maxTokens',
|
|
101
|
+
type: 'number',
|
|
102
|
+
default: 300,
|
|
103
|
+
typeOptions: {
|
|
104
|
+
minValue: 1,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
];
|
|
110
|
+
const displayOptions = {
|
|
111
|
+
show: {
|
|
112
|
+
operation: ['analyze'],
|
|
113
|
+
resource: ['image'],
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
exports.description = (0, n8n_workflow_1.updateDisplayOptions)(displayOptions, properties);
|
|
117
|
+
async function execute(i) {
|
|
118
|
+
const model = 'gpt-4-vision-preview';
|
|
119
|
+
const text = this.getNodeParameter('text', i, '');
|
|
120
|
+
const inputType = this.getNodeParameter('inputType', i);
|
|
121
|
+
const options = this.getNodeParameter('options', i, {});
|
|
122
|
+
const content = [
|
|
123
|
+
{
|
|
124
|
+
type: 'text',
|
|
125
|
+
text,
|
|
126
|
+
},
|
|
127
|
+
];
|
|
128
|
+
const detail = options.detail || 'auto';
|
|
129
|
+
if (inputType === 'url') {
|
|
130
|
+
const imageUrls = this.getNodeParameter('imageUrls', i)
|
|
131
|
+
.split(',')
|
|
132
|
+
.map((url) => url.trim());
|
|
133
|
+
for (const url of imageUrls) {
|
|
134
|
+
content.push({
|
|
135
|
+
type: 'image_url',
|
|
136
|
+
image_url: {
|
|
137
|
+
url,
|
|
138
|
+
detail,
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i)
|
|
145
|
+
.split(',')
|
|
146
|
+
.map((propertyName) => propertyName.trim());
|
|
147
|
+
for (const propertyName of binaryPropertyName) {
|
|
148
|
+
const binaryData = this.helpers.assertBinaryData(i, propertyName);
|
|
149
|
+
let fileBase64;
|
|
150
|
+
if (binaryData.id) {
|
|
151
|
+
const chunkSize = 256 * 1024;
|
|
152
|
+
const stream = await this.helpers.getBinaryStream(binaryData.id, chunkSize);
|
|
153
|
+
const buffer = await this.helpers.binaryToBuffer(stream);
|
|
154
|
+
fileBase64 = buffer.toString('base64');
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
fileBase64 = binaryData.data;
|
|
158
|
+
}
|
|
159
|
+
if (!binaryData) {
|
|
160
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'No binary data exists on item!');
|
|
161
|
+
}
|
|
162
|
+
content.push({
|
|
163
|
+
type: 'image_url',
|
|
164
|
+
image_url: {
|
|
165
|
+
url: `data:${binaryData.mimeType};base64,${fileBase64}`,
|
|
166
|
+
detail,
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const body = {
|
|
172
|
+
model,
|
|
173
|
+
messages: [
|
|
174
|
+
{
|
|
175
|
+
role: 'user',
|
|
176
|
+
content,
|
|
177
|
+
},
|
|
178
|
+
],
|
|
179
|
+
max_tokens: options.maxTokens || 300,
|
|
180
|
+
};
|
|
181
|
+
let response = await transport_1.apiRequest.call(this, 'POST', '/chat/completions', { body });
|
|
182
|
+
const simplify = this.getNodeParameter('simplify', i);
|
|
183
|
+
if (simplify && response.choices) {
|
|
184
|
+
response = { content: response.choices[0].message.content };
|
|
185
|
+
}
|
|
186
|
+
return [
|
|
187
|
+
{
|
|
188
|
+
json: response,
|
|
189
|
+
pairedItem: { item: i },
|
|
190
|
+
},
|
|
191
|
+
];
|
|
192
|
+
}
|
|
193
|
+
exports.execute = execute;
|
|
194
|
+
//# sourceMappingURL=analyze.operation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyze.operation.js","sourceRoot":"","sources":["../../../../../../nodes/vendors/OpenAi/actions/image/analyze.operation.ts"],"names":[],"mappings":";;;AAMA,+CAAwE;AACxE,+CAA6C;AAE7C,MAAM,UAAU,GAAsB;IACrC;QACC,WAAW,EAAE,YAAY;QACzB,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,4BAA4B;QACzC,OAAO,EAAE,uBAAuB;QAChC,WAAW,EAAE;YACZ,IAAI,EAAE,CAAC;SACP;KACD;IACD;QACC,WAAW,EAAE,YAAY;QACzB,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,KAAK;QACd,OAAO,EAAE;YACR;gBACC,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,KAAK;aACZ;YACD;gBACC,IAAI,EAAE,gBAAgB;gBACtB,KAAK,EAAE,QAAQ;aACf;SACD;KACD;IACD;QACC,WAAW,EAAE,QAAQ;QACrB,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,qCAAqC;QAClD,WAAW,EAAE,kFAAkF;QAC/F,OAAO,EAAE,EAAE;QACX,cAAc,EAAE;YACf,IAAI,EAAE;gBACL,SAAS,EAAE,CAAC,KAAK,CAAC;aAClB;SACD;KACD;IACD;QACC,WAAW,EAAE,uBAAuB;QACpC,IAAI,EAAE,oBAAoB;QAC1B,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,MAAM;QACf,WAAW,EAAE,WAAW;QACxB,IAAI,EAAE,6EAA6E;QACnF,WAAW,EAAE,yDAAyD;QACtE,cAAc,EAAE;YACf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,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7D,CAAC;IAED,OAAO;QACN;YACC,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;SACvB;KACD,CAAC;AACH,CAAC;AAtFD,0BAsFC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { INodeProperties, IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
|
2
|
+
export declare const description: {
|
|
3
|
+
displayOptions: import("n8n-workflow").IDisplayOptions;
|
|
4
|
+
displayName: string;
|
|
5
|
+
name: string;
|
|
6
|
+
type: import("n8n-workflow").NodePropertyTypes;
|
|
7
|
+
typeOptions?: import("n8n-workflow").INodePropertyTypeOptions | undefined;
|
|
8
|
+
default: import("n8n-workflow").NodeParameterValueType;
|
|
9
|
+
description?: string | undefined;
|
|
10
|
+
hint?: string | undefined;
|
|
11
|
+
options?: (INodeProperties | import("n8n-workflow").INodePropertyOptions | import("n8n-workflow").INodePropertyCollection)[] | undefined;
|
|
12
|
+
placeholder?: string | undefined;
|
|
13
|
+
isNodeSetting?: boolean | undefined;
|
|
14
|
+
noDataExpression?: boolean | undefined;
|
|
15
|
+
required?: boolean | undefined;
|
|
16
|
+
routing?: import("n8n-workflow").INodePropertyRouting | undefined;
|
|
17
|
+
credentialTypes?: ("extends:oAuth2Api" | "extends:oAuth1Api" | "has:authenticate" | "has:genericAuth")[] | undefined;
|
|
18
|
+
extractValue?: import("n8n-workflow").INodePropertyValueExtractorRegex | undefined;
|
|
19
|
+
modes?: import("n8n-workflow").INodePropertyMode[] | undefined;
|
|
20
|
+
requiresDataPath?: "single" | "multiple" | undefined;
|
|
21
|
+
doNotInherit?: boolean | undefined;
|
|
22
|
+
validateType?: import("n8n-workflow").FieldType | undefined;
|
|
23
|
+
ignoreValidationDuringExecution?: boolean | undefined;
|
|
24
|
+
}[];
|
|
25
|
+
export declare function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]>;
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.execute = exports.description = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const transport_1 = require("../../transport");
|
|
6
|
+
const properties = [
|
|
7
|
+
{
|
|
8
|
+
displayName: 'Model',
|
|
9
|
+
name: 'model',
|
|
10
|
+
type: 'options',
|
|
11
|
+
default: 'dall-e-3',
|
|
12
|
+
description: 'The model to use for image generation',
|
|
13
|
+
options: [
|
|
14
|
+
{
|
|
15
|
+
name: 'DALL-E-2',
|
|
16
|
+
value: 'dall-e-2',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'DALL-E-3',
|
|
20
|
+
value: 'dall-e-3',
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
displayName: 'Prompt',
|
|
26
|
+
name: 'prompt',
|
|
27
|
+
type: 'string',
|
|
28
|
+
placeholder: 'e.g. A cute cat eating a dinosaur',
|
|
29
|
+
description: 'A text description of the desired image(s). The maximum length is 1000 characters for dall-e-2 and 4000 characters for dall-e-3.',
|
|
30
|
+
default: '',
|
|
31
|
+
typeOptions: {
|
|
32
|
+
rows: 2,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
displayName: 'Options',
|
|
37
|
+
name: 'options',
|
|
38
|
+
placeholder: 'Add Option',
|
|
39
|
+
type: 'collection',
|
|
40
|
+
default: {},
|
|
41
|
+
options: [
|
|
42
|
+
{
|
|
43
|
+
displayName: 'Number of Images',
|
|
44
|
+
name: 'n',
|
|
45
|
+
default: 1,
|
|
46
|
+
description: 'Number of images to generate',
|
|
47
|
+
type: 'number',
|
|
48
|
+
typeOptions: {
|
|
49
|
+
minValue: 1,
|
|
50
|
+
maxValue: 10,
|
|
51
|
+
},
|
|
52
|
+
displayOptions: {
|
|
53
|
+
show: {
|
|
54
|
+
'/model': ['dall-e-2'],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
displayName: 'Quality',
|
|
60
|
+
name: 'quality',
|
|
61
|
+
type: 'options',
|
|
62
|
+
description: 'The quality of the image that will be generated, HD creates images with finer details and greater consistency across the image',
|
|
63
|
+
options: [
|
|
64
|
+
{
|
|
65
|
+
name: 'HD',
|
|
66
|
+
value: 'hd',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'Standard',
|
|
70
|
+
value: 'standard',
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
displayOptions: {
|
|
74
|
+
show: {
|
|
75
|
+
'/model': ['dall-e-3'],
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
default: 'standard',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
displayName: 'Resolution',
|
|
82
|
+
name: 'size',
|
|
83
|
+
type: 'options',
|
|
84
|
+
options: [
|
|
85
|
+
{
|
|
86
|
+
name: '256x256',
|
|
87
|
+
value: '256x256',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: '512x512',
|
|
91
|
+
value: '512x512',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: '1024x1024',
|
|
95
|
+
value: '1024x1024',
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
displayOptions: {
|
|
99
|
+
show: {
|
|
100
|
+
'/model': ['dall-e-2'],
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
default: '1024x1024',
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
displayName: 'Resolution',
|
|
107
|
+
name: 'size',
|
|
108
|
+
type: 'options',
|
|
109
|
+
options: [
|
|
110
|
+
{
|
|
111
|
+
name: '1024x1024',
|
|
112
|
+
value: '1024x1024',
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: '1792x1024',
|
|
116
|
+
value: '1792x1024',
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: '1024x1792',
|
|
120
|
+
value: '1024x1792',
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
displayOptions: {
|
|
124
|
+
show: {
|
|
125
|
+
'/model': ['dall-e-3'],
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
default: '1024x1024',
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
displayName: 'Style',
|
|
132
|
+
name: 'style',
|
|
133
|
+
type: 'options',
|
|
134
|
+
options: [
|
|
135
|
+
{
|
|
136
|
+
name: 'Natural',
|
|
137
|
+
value: 'natural',
|
|
138
|
+
description: 'Produce more natural looking images',
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
name: 'Vivid',
|
|
142
|
+
value: 'vivid',
|
|
143
|
+
description: 'Lean towards generating hyper-real and dramatic images',
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
displayOptions: {
|
|
147
|
+
show: {
|
|
148
|
+
'/model': ['dall-e-3'],
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
default: 'vivid',
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
displayName: 'Respond with Image URL(s)',
|
|
155
|
+
name: 'returnImageUrls',
|
|
156
|
+
type: 'boolean',
|
|
157
|
+
default: false,
|
|
158
|
+
description: 'Whether to return image URL(s) instead of binary file(s)',
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
displayName: 'Put Output in Field',
|
|
162
|
+
name: 'binaryPropertyOutput',
|
|
163
|
+
type: 'string',
|
|
164
|
+
default: 'data',
|
|
165
|
+
hint: 'The name of the output field to put the binary file data in',
|
|
166
|
+
displayOptions: {
|
|
167
|
+
show: {
|
|
168
|
+
returnImageUrls: [false],
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
},
|
|
174
|
+
];
|
|
175
|
+
const displayOptions = {
|
|
176
|
+
show: {
|
|
177
|
+
operation: ['generate'],
|
|
178
|
+
resource: ['image'],
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
exports.description = (0, n8n_workflow_1.updateDisplayOptions)(displayOptions, properties);
|
|
182
|
+
async function execute(i) {
|
|
183
|
+
const model = this.getNodeParameter('model', i);
|
|
184
|
+
const prompt = this.getNodeParameter('prompt', i);
|
|
185
|
+
const options = this.getNodeParameter('options', i, {});
|
|
186
|
+
let response_format = 'b64_json';
|
|
187
|
+
let binaryPropertyOutput = 'data';
|
|
188
|
+
if (options.returnImageUrls) {
|
|
189
|
+
response_format = 'url';
|
|
190
|
+
}
|
|
191
|
+
if (options.binaryPropertyOutput) {
|
|
192
|
+
binaryPropertyOutput = options.binaryPropertyOutput;
|
|
193
|
+
delete options.binaryPropertyOutput;
|
|
194
|
+
}
|
|
195
|
+
delete options.returnImageUrls;
|
|
196
|
+
const body = {
|
|
197
|
+
prompt,
|
|
198
|
+
model,
|
|
199
|
+
response_format,
|
|
200
|
+
...options,
|
|
201
|
+
};
|
|
202
|
+
const { data } = await transport_1.apiRequest.call(this, 'POST', '/images/generations', { body });
|
|
203
|
+
if (response_format === 'url') {
|
|
204
|
+
return (data || []).map((entry) => ({
|
|
205
|
+
json: entry,
|
|
206
|
+
pairedItem: { item: i },
|
|
207
|
+
}));
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
const returnData = [];
|
|
211
|
+
for (const entry of data) {
|
|
212
|
+
const binaryData = await this.helpers.prepareBinaryData(Buffer.from(entry.b64_json, 'base64'), 'data');
|
|
213
|
+
returnData.push({
|
|
214
|
+
json: Object.assign({}, binaryData, {
|
|
215
|
+
data: undefined,
|
|
216
|
+
}),
|
|
217
|
+
binary: {
|
|
218
|
+
[binaryPropertyOutput]: binaryData,
|
|
219
|
+
},
|
|
220
|
+
pairedItem: { item: i },
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
return returnData;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
exports.execute = execute;
|
|
227
|
+
//# sourceMappingURL=generate.operation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.operation.js","sourceRoot":"","sources":["../../../../../../nodes/vendors/OpenAi/actions/image/generate.operation.ts"],"names":[],"mappings":";;;AAMA,+CAAoD;AACpD,+CAA6C;AAE7C,MAAM,UAAU,GAAsB;IACrC;QACC,WAAW,EAAE,OAAO;QACpB,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,UAAU;QACnB,WAAW,EAAE,uCAAuC;QACpD,OAAO,EAAE;YACR;gBACC,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,UAAU;aACjB;YACD;gBACC,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,UAAU;aACjB;SACD;KACD;IACD;QACC,WAAW,EAAE,QAAQ;QACrB,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,mCAAmC;QAChD,WAAW,EACV,kIAAkI;QACnI,OAAO,EAAE,EAAE;QACX,WAAW,EAAE;YACZ,IAAI,EAAE,CAAC;SACP;KACD;IACD;QACC,WAAW,EAAE,SAAS;QACtB,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,YAAY;QACzB,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,EAAE;QACX,OAAO,EAAE;YACR;gBACC,WAAW,EAAE,kBAAkB;gBAC/B,IAAI,EAAE,GAAG;gBACT,OAAO,EAAE,CAAC;gBACV,WAAW,EAAE,8BAA8B;gBAC3C,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE;oBACZ,QAAQ,EAAE,CAAC;oBACX,QAAQ,EAAE,EAAE;iBACZ;gBACD,cAAc,EAAE;oBACf,IAAI,EAAE;wBACL,QAAQ,EAAE,CAAC,UAAU,CAAC;qBACtB;iBACD;aACD;YACD;gBACC,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE,SAAS;gBACf,IAAI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E,CAAC,EAAE;aACvB,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,UAAU,CAAC;IACnB,CAAC;AACF,CAAC;AArDD,0BAqDC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.description = exports.analyze = exports.generate = void 0;
|
|
27
|
+
const generate = __importStar(require("./generate.operation"));
|
|
28
|
+
exports.generate = generate;
|
|
29
|
+
const analyze = __importStar(require("./analyze.operation"));
|
|
30
|
+
exports.analyze = analyze;
|
|
31
|
+
exports.description = [
|
|
32
|
+
{
|
|
33
|
+
displayName: 'Operation',
|
|
34
|
+
name: 'operation',
|
|
35
|
+
type: 'options',
|
|
36
|
+
noDataExpression: true,
|
|
37
|
+
options: [
|
|
38
|
+
{
|
|
39
|
+
name: 'Analyze Image',
|
|
40
|
+
value: 'analyze',
|
|
41
|
+
action: 'Analyze image',
|
|
42
|
+
description: 'Take in images and answer questions about them',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: 'Generate an Image',
|
|
46
|
+
value: 'generate',
|
|
47
|
+
action: 'Generate an image',
|
|
48
|
+
description: 'Creates an image from a text prompt',
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
default: 'generate',
|
|
52
|
+
displayOptions: {
|
|
53
|
+
show: {
|
|
54
|
+
resource: ['image'],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
...generate.description,
|
|
59
|
+
...analyze.description,
|
|
60
|
+
];
|
|
61
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../nodes/vendors/OpenAi/actions/image/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,+DAAiD;AAGxC,4BAAQ;AAFjB,6DAA+C;AAE5B,0BAAO;AAEb,QAAA,WAAW,GAAsB;IAC7C;QACC,WAAW,EAAE,WAAW;QACxB,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,SAAS;QACf,gBAAgB,EAAE,IAAI;QACtB,OAAO,EAAE;YACR;gBACC,IAAI,EAAE,eAAe;gBACrB,KAAK,EAAE,SAAS;gBAChB,MAAM,EAAE,eAAe;gBACvB,WAAW,EAAE,gDAAgD;aAC7D;YACD;gBACC,IAAI,EAAE,mBAAmB;gBACzB,KAAK,EAAE,UAAU;gBACjB,MAAM,EAAE,mBAAmB;gBAC3B,WAAW,EAAE,qCAAqC;aAClD;SACD;QACD,OAAO,EAAE,UAAU;QACnB,cAAc,EAAE;YACf,IAAI,EAAE;gBACL,QAAQ,EAAE,CAAC,OAAO,CAAC;aACnB;SACD;KACD;IACD,GAAG,QAAQ,CAAC,WAAW;IACvB,GAAG,OAAO,CAAC,WAAW;CACtB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AllEntities } from 'n8n-workflow';
|
|
2
|
+
type NodeMap = {
|
|
3
|
+
assistant: 'message' | 'create' | 'deleteAssistant' | 'list' | 'update';
|
|
4
|
+
audio: 'generate' | 'transcribe' | 'translate';
|
|
5
|
+
file: 'upload' | 'deleteFile' | 'list';
|
|
6
|
+
image: 'generate' | 'analyze';
|
|
7
|
+
text: 'message' | 'classify';
|
|
8
|
+
};
|
|
9
|
+
export type OpenAiType = AllEntities<NodeMap>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.type.js","sourceRoot":"","sources":["../../../../../nodes/vendors/OpenAi/actions/node.type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.router = void 0;
|
|
27
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
28
|
+
const assistant = __importStar(require("./assistant"));
|
|
29
|
+
const audio = __importStar(require("./audio"));
|
|
30
|
+
const file = __importStar(require("./file"));
|
|
31
|
+
const image = __importStar(require("./image"));
|
|
32
|
+
const text = __importStar(require("./text"));
|
|
33
|
+
async function router() {
|
|
34
|
+
const returnData = [];
|
|
35
|
+
const items = this.getInputData();
|
|
36
|
+
const resource = this.getNodeParameter('resource', 0);
|
|
37
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
38
|
+
const openAiTypeData = {
|
|
39
|
+
resource,
|
|
40
|
+
operation,
|
|
41
|
+
};
|
|
42
|
+
let execute;
|
|
43
|
+
switch (openAiTypeData.resource) {
|
|
44
|
+
case 'assistant':
|
|
45
|
+
execute = assistant[openAiTypeData.operation].execute;
|
|
46
|
+
break;
|
|
47
|
+
case 'audio':
|
|
48
|
+
execute = audio[openAiTypeData.operation].execute;
|
|
49
|
+
break;
|
|
50
|
+
case 'file':
|
|
51
|
+
execute = file[openAiTypeData.operation].execute;
|
|
52
|
+
break;
|
|
53
|
+
case 'image':
|
|
54
|
+
execute = image[openAiTypeData.operation].execute;
|
|
55
|
+
break;
|
|
56
|
+
case 'text':
|
|
57
|
+
execute = text[openAiTypeData.operation].execute;
|
|
58
|
+
break;
|
|
59
|
+
default:
|
|
60
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The operation "${operation}" is not supported!`);
|
|
61
|
+
}
|
|
62
|
+
for (let i = 0; i < items.length; i++) {
|
|
63
|
+
try {
|
|
64
|
+
const responseData = await execute.call(this, i);
|
|
65
|
+
returnData.push(...responseData);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (this.continueOnFail()) {
|
|
69
|
+
returnData.push({ json: { error: error.message }, pairedItem: { item: i } });
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, {
|
|
73
|
+
itemIndex: i,
|
|
74
|
+
description: error.description,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return [returnData];
|
|
79
|
+
}
|
|
80
|
+
exports.router = router;
|
|
81
|
+
//# sourceMappingURL=router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../../../../nodes/vendors/OpenAi/actions/router.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAmG;AAEnG,uDAAyC;AACzC,+CAAiC;AACjC,6CAA+B;AAC/B,+CAAiC;AACjC,6CAA+B;AAIxB,KAAK,UAAU,MAAM;IAC3B,MAAM,UAAU,GAAyB,EAAE,CAAC;IAE5C,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;IAClC,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAa,UAAU,EAAE,CAAC,CAAC,CAAC;IAClE,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IAExD,MAAM,cAAc,GAAG;QACtB,QAAQ;QACR,SAAS;KACK,CAAC;IAEhB,IAAI,OAAO,CAAC;IACZ,QAAQ,cAAc,CAAC,QAAQ,EAAE,CAAC;QACjC,KAAK,WAAW;YACf,OAAO,GAAG,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC;YACtD,MAAM;QACP,KAAK,OAAO;YACX,OAAO,GAAG,KAAK,CAAC,cAAc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