-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflux-workflow-replacement.json
More file actions
328 lines (328 loc) · 10.7 KB
/
Copy pathflux-workflow-replacement.json
File metadata and controls
328 lines (328 loc) · 10.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
{
"name": "flux",
"nodes": [
{
"parameters": {
"path": "flux",
"responseMode": "responseNode",
"options": {}
},
"id": "b851267c-ad34-49a2-b42c-a63d8bf55265",
"name": "GET请求",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [
-60,
480
],
"webhookId": "a5a9106f-2389-4b29-8423-8c0d94717ed2"
},
{
"parameters": {
"method": "POST",
"url": "https://api.siliconflow.cn/v1/chat/completions",
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"model\": \"Qwen/Qwen2.5-7B-Instruct\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a professional AI image generation prompt optimizer. Please convert the user's simple description into a detailed, professional FLUX image generation prompt. Requirements: 1. Keep the original meaning unchanged 2. Add artistic style, lighting effects, composition details 3. Output in English 4. The prompt should be specific and expressive 5. Control the length between 100-200 words\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Please optimize this image description: {{ $('GET请求').item.json.query.prompt }}\"\n }\n ],\n \"max_tokens\": 300,\n \"temperature\": 0.7\n}",
"options": {}
},
"id": "prompt-enhancer",
"name": "提示词优化",
"type": "n8n-nodes-base.httpRequest",
"position": [
100,
480
],
"typeVersion": 4.2,
"credentials": {
"httpBearerAuth": {
"id": "eIOKreIsFPd1CJQy",
"name": "Bearer Auth account"
}
},
"onError": "continueErrorOutput"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "06e13542-cb9a-4a81-823e-07c913ba79f9",
"leftValue": "={{ $('GET请求').item.json.query.seed }}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
300,
480
],
"id": "382d2192-26db-4a13-9f35-6ff21c9d7ea8",
"name": "Seed值有无"
},
{
"parameters": {
"method": "POST",
"url": "https://api.siliconflow.cn/v1/images/generations",
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"prompt_enhancement\": false,\n \"prompt\": \"{{ $('提示词优化').item.json.choices[0].message.content }}\",\n \"image_size\": \"{{ $ifEmpty($('GET请求').item.json.query.width,1024) }}x{{ $ifEmpty($('GET请求').item.json.query.height,1024) }}\",\n \"model\": \"black-forest-labs/FLUX.1-dev\",\n \"seed\": {{ $('GET请求').item.json.query.seed }}\n}",
"options": {}
},
"id": "76de81c8-f5a9-4f61-9321-f91a63c1ed21",
"name": "调用 硅基流动 推理 API",
"type": "n8n-nodes-base.httpRequest",
"position": [
500,
380
],
"notesInFlow": true,
"typeVersion": 4.2,
"retryOnFail": false,
"credentials": {
"httpBearerAuth": {
"id": "eIOKreIsFPd1CJQy",
"name": "Bearer Auth account"
}
},
"onError": "continueErrorOutput",
"notes": "使用优化后的提示词"
},
{
"parameters": {
"method": "POST",
"url": "https://api.siliconflow.cn/v1/images/generations",
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"prompt_enhancement\": false,\n \"prompt\": \"{{ $('提示词优化').item.json.choices[0].message.content }}\",\n \"image_size\": \"{{ $ifEmpty($('GET请求').item.json.query.width,1024) }}x{{ $ifEmpty($('GET请求').item.json.query.height,1024) }}\",\n \"model\": \"black-forest-labs/FLUX.1-dev\"\n}",
"options": {}
},
"id": "b5684a8e-46fb-4687-9445-ebbf6fdfc978",
"name": "调用 硅基流动 推理 API1",
"type": "n8n-nodes-base.httpRequest",
"position": [
500,
580
],
"notesInFlow": true,
"typeVersion": 4.2,
"retryOnFail": false,
"credentials": {
"httpBearerAuth": {
"id": "eIOKreIsFPd1CJQy",
"name": "Bearer Auth account"
}
},
"onError": "continueErrorOutput",
"notes": "使用优化后的提示词"
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={\n \"success\": true,\n \"originalPrompt\": \"{{ $('GET请求').item.json.query.prompt }}\",\n \"enhancedPrompt\": \"{{ $('提示词优化').item.json.choices[0].message.content }}\",\n \"imageUrl\": \"{{ $json.images[0].url }}\",\n \"parameters\": {\n \"width\": {{ $ifEmpty($('GET请求').item.json.query.width,1024) }},\n \"height\": {{ $ifEmpty($('GET请求').item.json.query.height,1024) }},\n \"seed\": {{ $ifEmpty($('GET请求').item.json.query.seed,'null') }},\n \"model\": \"black-forest-labs/FLUX.1-dev\"\n }\n}",
"options": {}
},
"id": "2ddb9610-15a2-4391-9dbf-22145bfbee25",
"name": "成功响应",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.1,
"position": [
700,
380
]
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={\n \"success\": true,\n \"originalPrompt\": \"{{ $('GET请求').item.json.query.prompt }}\",\n \"enhancedPrompt\": \"{{ $('提示词优化').item.json.choices[0].message.content }}\",\n \"imageUrl\": \"{{ $json.images[0].url }}\",\n \"parameters\": {\n \"width\": {{ $ifEmpty($('GET请求').item.json.query.width,1024) }},\n \"height\": {{ $ifEmpty($('GET请求').item.json.query.height,1024) }},\n \"seed\": null,\n \"model\": \"black-forest-labs/FLUX.1-dev\"\n }\n}",
"options": {}
},
"id": "10f661a3-dc44-4d7a-9feb-da921ca207c2",
"name": "成功响应1",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.1,
"position": [
700,
580
]
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={\n \"success\": false,\n \"error\": \"提示词优化失败:{{ $json.error.message || '未知错误' }}\",\n \"step\": \"prompt_enhancement\"\n}",
"options": {}
},
"id": "prompt-error",
"name": "提示词优化错误",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
300,
600
],
"typeVersion": 1.1
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={\n \"success\": false,\n \"error\": \"硅基流动调用失败:{{ $json.error.message || '未知错误' }}\",\n \"step\": \"image_generation\",\n \"enhancedPrompt\": \"{{ $('提示词优化').item.json.choices[0].message.content }}\"\n}",
"options": {}
},
"id": "60feb16f-d4f6-40fc-96ab-ce36bef6109b",
"name": "回复错误1",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
700,
280
],
"typeVersion": 1.1
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={\n \"success\": false,\n \"error\": \"硅基流动调用失败:{{ $json.error.message || '未知错误' }}\",\n \"step\": \"image_generation\",\n \"enhancedPrompt\": \"{{ $('提示词优化').item.json.choices[0].message.content }}\"\n}",
"options": {}
},
"id": "b4da27a4-4e4b-407b-8190-f961a7025f10",
"name": "回复错误",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
700,
680
],
"typeVersion": 1.1
},
{
"parameters": {
"content": "## 增强版 FLUX 图像生成工作流\n\n新增功能:\n1. 智能提示词优化 - 使用 Qwen2.5-7B 模型\n2. JSON 响应格式 - 便于前端集成\n3. 完整错误处理 - 分步骤错误信息\n4. 优化后提示词返回 - 用户可查看优化结果\n\n配合前端网页使用,提供完整的图像生成体验。",
"height": 160,
"width": 400
},
"id": "bbc5bcfa-5803-4cb7-b9d1-ae63cb288f19",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-60,
200
]
}
],
"pinData": {},
"connections": {
"GET请求": {
"main": [
[
{
"node": "提示词优化",
"type": "main",
"index": 0
}
]
]
},
"提示词优化": {
"main": [
[
{
"node": "Seed值有无",
"type": "main",
"index": 0
}
],
[
{
"node": "提示词优化错误",
"type": "main",
"index": 0
}
]
]
},
"Seed值有无": {
"main": [
[
{
"node": "调用 硅基流动 推理 API",
"type": "main",
"index": 0
}
],
[
{
"node": "调用 硅基流动 推理 API1",
"type": "main",
"index": 0
}
]
]
},
"调用 硅基流动 推理 API": {
"main": [
[
{
"node": "成功响应",
"type": "main",
"index": 0
}
],
[
{
"node": "回复错误1",
"type": "main",
"index": 0
}
]
]
},
"调用 硅基流动 推理 API1": {
"main": [
[
{
"node": "成功响应1",
"type": "main",
"index": 0
}
],
[
{
"node": "回复错误",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "756f2410-34bf-4004-bdfa-6c58f7e5c85e",
"meta": {
"instanceId": "e11d00c2718992a58214a52e1f2f24c680abf6d1e56d9580c9a7fb8d725c63d8"
},
"id": "psYBQPv4NpIaPNlE",
"tags": []
}