@tiger16601/n8n-nodes-fastgpt 1.1.13 → 1.1.15
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.
|
@@ -14,51 +14,12 @@ exports.chatOperations = [
|
|
|
14
14
|
},
|
|
15
15
|
},
|
|
16
16
|
options: [
|
|
17
|
-
|
|
18
|
-
name: "客服对话",
|
|
19
|
-
value: "客服对话",
|
|
20
|
-
action: "客服对话",
|
|
21
|
-
description: "Create one or more completions for a given text",
|
|
22
|
-
routing: {
|
|
23
|
-
request: {
|
|
24
|
-
method: "POST",
|
|
25
|
-
url: "/v1/chat/completions",
|
|
26
|
-
body: {
|
|
27
|
-
stream: false,
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
output: {
|
|
31
|
-
postReceive: [GenericFunctions_1.sendErrorPostReceive],
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
// NEW: 纯文本对话 - 纯文本消息
|
|
36
|
-
{
|
|
37
|
-
name: "纯文本对话",
|
|
38
|
-
value: "纯文本对话",
|
|
39
|
-
action: "纯文本对话",
|
|
40
|
-
description: "请求对话Agent进行纯文本对话,使用固定消息格式。",
|
|
41
|
-
routing: {
|
|
42
|
-
request: {
|
|
43
|
-
method: "POST",
|
|
44
|
-
// NEW: 纯文本对话端点
|
|
45
|
-
url: "/v1/chat/completions",
|
|
46
|
-
body: {
|
|
47
|
-
stream: false,
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
output: {
|
|
51
|
-
postReceive: [GenericFunctions_1.sendErrorPostReceive],
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
// NEW: 多模态对话 - 支持图片/文件
|
|
17
|
+
// NEW: 多模态对话 - 纯文本消息
|
|
56
18
|
{
|
|
57
19
|
name: "多模态对话",
|
|
58
20
|
value: "多模态对话",
|
|
59
21
|
action: "多模态对话",
|
|
60
|
-
description:
|
|
61
|
-
"请求对话Agent进行多模态对话,支持上传图片(image_url)和文件(file_url)。",
|
|
22
|
+
description: "请求对话Agent进行多模态对话,使用固定消息格式。",
|
|
62
23
|
routing: {
|
|
63
24
|
request: {
|
|
64
25
|
method: "POST",
|
|
@@ -87,7 +48,6 @@ exports.chatOperations = [
|
|
|
87
48
|
url: "/v1/chat/completions",
|
|
88
49
|
body: {
|
|
89
50
|
stream: false,
|
|
90
|
-
detail: true,
|
|
91
51
|
},
|
|
92
52
|
},
|
|
93
53
|
output: {
|
|
@@ -328,7 +288,7 @@ exports.chatOperations = [
|
|
|
328
288
|
},
|
|
329
289
|
},
|
|
330
290
|
],
|
|
331
|
-
default: "
|
|
291
|
+
default: "多模态对话",
|
|
332
292
|
},
|
|
333
293
|
];
|
|
334
294
|
const completeOperations = [
|
|
@@ -340,13 +300,7 @@ const completeOperations = [
|
|
|
340
300
|
required: true,
|
|
341
301
|
displayOptions: {
|
|
342
302
|
show: {
|
|
343
|
-
operation: [
|
|
344
|
-
"客服对话",
|
|
345
|
-
"纯文本对话",
|
|
346
|
-
"多模态对话",
|
|
347
|
-
"交互节点继续运行",
|
|
348
|
-
"请求插件",
|
|
349
|
-
],
|
|
303
|
+
operation: ["多模态对话", "交互节点继续运行", "请求插件"],
|
|
350
304
|
resource: ["chat"],
|
|
351
305
|
},
|
|
352
306
|
},
|
|
@@ -368,7 +322,7 @@ const completeOperations = [
|
|
|
368
322
|
displayOptions: {
|
|
369
323
|
show: {
|
|
370
324
|
resource: ["chat"],
|
|
371
|
-
operation: ["
|
|
325
|
+
operation: ["多模态对话", "交互节点继续运行"],
|
|
372
326
|
},
|
|
373
327
|
},
|
|
374
328
|
required: true,
|
|
@@ -400,10 +354,34 @@ const completeOperations = [
|
|
|
400
354
|
default: "user",
|
|
401
355
|
},
|
|
402
356
|
{
|
|
403
|
-
displayName: "
|
|
357
|
+
displayName: "文本内容",
|
|
404
358
|
name: "content",
|
|
405
359
|
type: "string",
|
|
406
360
|
default: "",
|
|
361
|
+
description: "纯文本消息内容",
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
displayName: "图片链接(可选)",
|
|
365
|
+
name: "imageUrl",
|
|
366
|
+
type: "string",
|
|
367
|
+
default: "",
|
|
368
|
+
description: "填写图片URL,会自动以image_url格式拼接",
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
displayName: "文档链接(可选)",
|
|
372
|
+
name: "fileUrl",
|
|
373
|
+
type: "string",
|
|
374
|
+
default: "",
|
|
375
|
+
description:
|
|
376
|
+
"填写文档URL(支持txt/md/html/word/pdf/ppt/csv/excel)",
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
displayName: "文档名称",
|
|
380
|
+
name: "fileName",
|
|
381
|
+
type: "string",
|
|
382
|
+
default: "",
|
|
383
|
+
description:
|
|
384
|
+
"当填写文档链接时,需要填写文档名称(带后缀)",
|
|
407
385
|
},
|
|
408
386
|
],
|
|
409
387
|
},
|
|
@@ -412,7 +390,63 @@ const completeOperations = [
|
|
|
412
390
|
send: {
|
|
413
391
|
type: "body",
|
|
414
392
|
property: "messages",
|
|
415
|
-
|
|
393
|
+
// NEW: 自动处理纯文本与多模态格式
|
|
394
|
+
preSend: [
|
|
395
|
+
async function (requestOptions) {
|
|
396
|
+
const messages = this.getNodeParameter("prompt");
|
|
397
|
+
if (messages && messages.messages) {
|
|
398
|
+
requestOptions.body.messages =
|
|
399
|
+
messages.messages.map(function (msg) {
|
|
400
|
+
const hasImage =
|
|
401
|
+
msg.imageUrl &&
|
|
402
|
+
String(msg.imageUrl).trim();
|
|
403
|
+
const hasFile =
|
|
404
|
+
msg.fileUrl &&
|
|
405
|
+
String(msg.fileUrl).trim();
|
|
406
|
+
if (hasImage || hasFile) {
|
|
407
|
+
const contentArr = [];
|
|
408
|
+
if (
|
|
409
|
+
msg.content &&
|
|
410
|
+
String(msg.content).trim()
|
|
411
|
+
) {
|
|
412
|
+
contentArr.push({
|
|
413
|
+
type: "text",
|
|
414
|
+
text: String(
|
|
415
|
+
msg.content,
|
|
416
|
+
).trim(),
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
if (hasImage) {
|
|
420
|
+
contentArr.push({
|
|
421
|
+
type: "image_url",
|
|
422
|
+
image_url: {
|
|
423
|
+
url: String(
|
|
424
|
+
msg.imageUrl,
|
|
425
|
+
).trim(),
|
|
426
|
+
},
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
if (hasFile) {
|
|
430
|
+
contentArr.push({
|
|
431
|
+
type: "file_url",
|
|
432
|
+
name: msg.fileName || "",
|
|
433
|
+
url: String(msg.fileUrl).trim(),
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
return {
|
|
437
|
+
role: msg.role,
|
|
438
|
+
content: contentArr,
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
return {
|
|
442
|
+
role: msg.role,
|
|
443
|
+
content: msg.content || "",
|
|
444
|
+
};
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
return requestOptions;
|
|
448
|
+
},
|
|
449
|
+
],
|
|
416
450
|
},
|
|
417
451
|
},
|
|
418
452
|
},
|
|
@@ -427,7 +461,7 @@ const completeOperations = [
|
|
|
427
461
|
displayOptions: {
|
|
428
462
|
show: {
|
|
429
463
|
resource: ["chat"],
|
|
430
|
-
operation: ["
|
|
464
|
+
operation: ["多模态对话", "请求插件"],
|
|
431
465
|
},
|
|
432
466
|
},
|
|
433
467
|
placeholder: "添加变量",
|
|
@@ -467,12 +501,7 @@ const completeOperations = [
|
|
|
467
501
|
default: false,
|
|
468
502
|
displayOptions: {
|
|
469
503
|
show: {
|
|
470
|
-
operation: [
|
|
471
|
-
"客服对话",
|
|
472
|
-
"纯文本对话",
|
|
473
|
-
"多模态对话",
|
|
474
|
-
"交互节点继续运行",
|
|
475
|
-
],
|
|
504
|
+
operation: ["多模态对话", "交互节点继续运行"],
|
|
476
505
|
resource: ["chat"],
|
|
477
506
|
},
|
|
478
507
|
},
|
|
@@ -483,35 +512,13 @@ const completeOperations = [
|
|
|
483
512
|
},
|
|
484
513
|
},
|
|
485
514
|
},
|
|
486
|
-
// NEW: 响应对话项ID -
|
|
515
|
+
// NEW: 响应对话项ID - 用于多模态对话
|
|
487
516
|
{
|
|
488
517
|
displayName: "响应对话项ID",
|
|
489
518
|
name: "responseChatItemId",
|
|
490
519
|
type: "string",
|
|
491
520
|
default: "",
|
|
492
521
|
description: "指定响应对话项的ID,用于跟踪对话项(选填)",
|
|
493
|
-
displayOptions: {
|
|
494
|
-
show: {
|
|
495
|
-
operation: ["纯文本对话", "多模态对话"],
|
|
496
|
-
resource: ["chat"],
|
|
497
|
-
},
|
|
498
|
-
},
|
|
499
|
-
routing: {
|
|
500
|
-
send: {
|
|
501
|
-
type: "body",
|
|
502
|
-
property: "responseChatItemId",
|
|
503
|
-
},
|
|
504
|
-
},
|
|
505
|
-
},
|
|
506
|
-
// NEW: 多模态对话消息 - 支持文本/图片/文件
|
|
507
|
-
{
|
|
508
|
-
displayName: "Agent对话消息",
|
|
509
|
-
name: "agentMessages",
|
|
510
|
-
type: "json",
|
|
511
|
-
default: '[{"role":"user","content":""}]',
|
|
512
|
-
required: true,
|
|
513
|
-
description:
|
|
514
|
-
'消息列表,JSON格式。content支持字符串或数组(可包含text/image_url/file_url类型)。示例:[{"role":"user","content":[{"type":"text","text":"导演是谁"},{"type":"image_url","image_url":{"url":"图片链接"}}]}]',
|
|
515
522
|
displayOptions: {
|
|
516
523
|
show: {
|
|
517
524
|
operation: ["多模态对话"],
|
|
@@ -521,25 +528,7 @@ const completeOperations = [
|
|
|
521
528
|
routing: {
|
|
522
529
|
send: {
|
|
523
530
|
type: "body",
|
|
524
|
-
property: "
|
|
525
|
-
// NEW: 确保messages以JSON数组形式发送
|
|
526
|
-
preSend: [
|
|
527
|
-
async function (requestOptions) {
|
|
528
|
-
const messagesValue =
|
|
529
|
-
this.getNodeParameter("agentMessages");
|
|
530
|
-
if (typeof messagesValue === "string") {
|
|
531
|
-
try {
|
|
532
|
-
requestOptions.body.messages =
|
|
533
|
-
JSON.parse(messagesValue);
|
|
534
|
-
} catch (e) {
|
|
535
|
-
requestOptions.body.messages = [];
|
|
536
|
-
}
|
|
537
|
-
} else {
|
|
538
|
-
requestOptions.body.messages = messagesValue;
|
|
539
|
-
}
|
|
540
|
-
return requestOptions;
|
|
541
|
-
},
|
|
542
|
-
],
|
|
531
|
+
property: "responseChatItemId",
|
|
543
532
|
},
|
|
544
533
|
},
|
|
545
534
|
},
|
|
@@ -550,12 +539,7 @@ const completeOperations = [
|
|
|
550
539
|
default: true,
|
|
551
540
|
displayOptions: {
|
|
552
541
|
show: {
|
|
553
|
-
operation: [
|
|
554
|
-
"客服对话",
|
|
555
|
-
"纯文本对话",
|
|
556
|
-
"多模态对话",
|
|
557
|
-
"交互节点继续运行",
|
|
558
|
-
],
|
|
542
|
+
operation: ["多模态对话", "交互节点继续运行"],
|
|
559
543
|
resource: ["chat"],
|
|
560
544
|
},
|
|
561
545
|
},
|