n8n-nodes-ai-gateway 1.0.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 +85 -0
- package/dist/credentials/AiGatewayApi.credentials.d.ts +9 -0
- package/dist/credentials/AiGatewayApi.credentials.d.ts.map +1 -0
- package/dist/credentials/AiGatewayApi.credentials.js +99 -0
- package/dist/credentials/AiGatewayApi.credentials.js.map +1 -0
- package/dist/nodes/AiGateway/AiGateway.node.d.ts +6 -0
- package/dist/nodes/AiGateway/AiGateway.node.d.ts.map +1 -0
- package/dist/nodes/AiGateway/AiGateway.node.js +405 -0
- package/dist/nodes/AiGateway/AiGateway.node.js.map +1 -0
- package/dist/nodes/AiGateway/ai-gateway.svg +28 -0
- package/package.json +54 -0
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# n8n-nodes-ai-gateway
|
|
2
|
+
|
|
3
|
+
统一 AI 网关的 n8n 社区节点,支持智谱/美团/魔搭/蚂蚁百宝箱/硅基流动等国内 AI 厂商,以及任意 OpenAI 兼容 API。
|
|
4
|
+
|
|
5
|
+
## 功能
|
|
6
|
+
|
|
7
|
+
- ✅ **聊天 (Chat)** - 文本对话
|
|
8
|
+
- ✅ **图像生成 (Image)** - AI 生成图片
|
|
9
|
+
- ✅ **视频生成 (Video)** - AI 生成视频 (异步)
|
|
10
|
+
- ✅ **异步任务查询** - 查询视频等异步任务状态
|
|
11
|
+
- ✅ **蚂蚁百宝箱** - 专用接口
|
|
12
|
+
|
|
13
|
+
## 支持的厂商
|
|
14
|
+
|
|
15
|
+
| 厂商 | 类型 | 说明 |
|
|
16
|
+
|------|------|------|
|
|
17
|
+
| 智谱 GLM | 免费 | glm-4-flash, cogview-3-flash |
|
|
18
|
+
| 硅基流动 | 付费 | deepseek-ai/DeepSeek-V3 |
|
|
19
|
+
| 魔搭社区 | 免费 | Qwen/Qwen2.5-72B-Instruct |
|
|
20
|
+
| 美团 LongCat | 有限免费 | LongCat-Flash-Chat |
|
|
21
|
+
| 蚂蚁百宝箱 | 取决于应用 | 自定义应用 |
|
|
22
|
+
| DeepSeek | 付费 | deepseek-chat |
|
|
23
|
+
| Moonshot | 付费 | moonshot-v1-8k |
|
|
24
|
+
| 自定义 | - | 任意 OpenAI 兼容 API |
|
|
25
|
+
|
|
26
|
+
## 安装
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install n8n-nodes-ai-gateway
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
或在 n8n 中:
|
|
33
|
+
1. 设置 → Community Nodes
|
|
34
|
+
2. 安装 `n8n-nodes-ai-gateway`
|
|
35
|
+
|
|
36
|
+
## 配置
|
|
37
|
+
|
|
38
|
+
### 1. 创建凭据
|
|
39
|
+
|
|
40
|
+
在 n8n 中创建 **AI Gateway API** 凭据:
|
|
41
|
+
|
|
42
|
+
- **网关地址**: 你的 EdgeOne 云函数 URL
|
|
43
|
+
- **各厂商 API Key**: 按需配置
|
|
44
|
+
|
|
45
|
+
### 2. 使用节点
|
|
46
|
+
|
|
47
|
+
1. 添加 **AI Gateway** 节点
|
|
48
|
+
2. 选择操作类型和厂商
|
|
49
|
+
3. 输入消息/提示词
|
|
50
|
+
4. 运行
|
|
51
|
+
|
|
52
|
+
## 示例
|
|
53
|
+
|
|
54
|
+
### 智谱聊天
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
操作: 聊天 (Chat)
|
|
58
|
+
厂商: 智谱 GLM
|
|
59
|
+
模型: glm-4-flash
|
|
60
|
+
消息: 你好,请介绍一下自己
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 蚂蚁百宝箱
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
操作: 蚂蚁百宝箱
|
|
67
|
+
问题: 帮我分析这段文本...
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## 开发
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# 安装依赖
|
|
74
|
+
npm install
|
|
75
|
+
|
|
76
|
+
# 构建
|
|
77
|
+
npm run build
|
|
78
|
+
|
|
79
|
+
# 开发模式
|
|
80
|
+
npm run dev
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
MIT
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare class AiGatewayApi implements ICredentialType {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
documentationUrl: string;
|
|
6
|
+
properties: INodeProperties[];
|
|
7
|
+
test: ICredentialTestRequest;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=AiGatewayApi.credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AiGatewayApi.credentials.d.ts","sourceRoot":"","sources":["../../credentials/AiGatewayApi.credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,sBAAsB,EACtB,eAAe,EACf,eAAe,EAClB,MAAM,cAAc,CAAC;AAEtB,qBAAa,YAAa,YAAW,eAAe;IAChD,IAAI,SAAkB;IACtB,WAAW,SAAoB;IAC/B,gBAAgB,SAA0D;IAE1E,UAAU,EAAE,eAAe,EAAE,CAgF3B;IAGF,IAAI,EAAE,sBAAsB,CAM1B;CACL"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AiGatewayApi = void 0;
|
|
4
|
+
class AiGatewayApi {
|
|
5
|
+
name = 'aiGatewayApi';
|
|
6
|
+
displayName = 'AI Gateway API';
|
|
7
|
+
documentationUrl = 'https://github.com/DuanPeng1314/n8n-nodes-ai-gateway';
|
|
8
|
+
properties = [
|
|
9
|
+
// ============ 网关配置 ============
|
|
10
|
+
{
|
|
11
|
+
displayName: '网关地址 (Gateway URL)',
|
|
12
|
+
name: 'gatewayUrl',
|
|
13
|
+
type: 'string',
|
|
14
|
+
default: 'https://api1.dp7575.com.cn',
|
|
15
|
+
placeholder: 'https://your-gateway.edgeonefunctions.com',
|
|
16
|
+
description: 'EdgeOne 云函数的 URL 地址',
|
|
17
|
+
required: true,
|
|
18
|
+
},
|
|
19
|
+
// ============ 智谱 ============
|
|
20
|
+
{
|
|
21
|
+
displayName: '智谱 API Key',
|
|
22
|
+
name: 'zhipuApiKey',
|
|
23
|
+
type: 'string',
|
|
24
|
+
typeOptions: { password: true },
|
|
25
|
+
default: '',
|
|
26
|
+
description: '智谱 GLM API Key (可选)',
|
|
27
|
+
},
|
|
28
|
+
// ============ 硅基流动 ============
|
|
29
|
+
{
|
|
30
|
+
displayName: '硅基流动 API Key',
|
|
31
|
+
name: 'siliconflowApiKey',
|
|
32
|
+
type: 'string',
|
|
33
|
+
typeOptions: { password: true },
|
|
34
|
+
default: '',
|
|
35
|
+
description: '硅基流动 API Key (可选)',
|
|
36
|
+
},
|
|
37
|
+
// ============ 魔搭社区 ============
|
|
38
|
+
{
|
|
39
|
+
displayName: '魔搭社区 API Key',
|
|
40
|
+
name: 'modelscopeApiKey',
|
|
41
|
+
type: 'string',
|
|
42
|
+
typeOptions: { password: true },
|
|
43
|
+
default: '',
|
|
44
|
+
description: '魔搭社区 ModelScope API Key (可选)',
|
|
45
|
+
},
|
|
46
|
+
// ============ 美团 LongCat ============
|
|
47
|
+
{
|
|
48
|
+
displayName: '美团 LongCat API Key',
|
|
49
|
+
name: 'longcatApiKey',
|
|
50
|
+
type: 'string',
|
|
51
|
+
typeOptions: { password: true },
|
|
52
|
+
default: '',
|
|
53
|
+
description: '美团 LongCat API Key (可选)',
|
|
54
|
+
},
|
|
55
|
+
// ============ 蚂蚁百宝箱 ============
|
|
56
|
+
{
|
|
57
|
+
displayName: '蚂蚁百宝箱 App ID',
|
|
58
|
+
name: 'tboxAppId',
|
|
59
|
+
type: 'string',
|
|
60
|
+
default: '',
|
|
61
|
+
description: '蚂蚁百宝箱应用 ID (可选)',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
displayName: '蚂蚁百宝箱 Token',
|
|
65
|
+
name: 'tboxToken',
|
|
66
|
+
type: 'string',
|
|
67
|
+
typeOptions: { password: true },
|
|
68
|
+
default: '',
|
|
69
|
+
description: '蚂蚁百宝箱应用 Token (可选)',
|
|
70
|
+
},
|
|
71
|
+
// ============ 自定义 OpenAI 兼容 ============
|
|
72
|
+
{
|
|
73
|
+
displayName: '自定义 API Base URL',
|
|
74
|
+
name: 'customApiBase',
|
|
75
|
+
type: 'string',
|
|
76
|
+
default: '',
|
|
77
|
+
placeholder: 'https://api.openai.com/v1',
|
|
78
|
+
description: '任意 OpenAI 兼容 API 的 Base URL (可选)',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
displayName: '自定义 API Key',
|
|
82
|
+
name: 'customApiKey',
|
|
83
|
+
type: 'string',
|
|
84
|
+
typeOptions: { password: true },
|
|
85
|
+
default: '',
|
|
86
|
+
description: '自定义 API 的 Key (可选)',
|
|
87
|
+
},
|
|
88
|
+
];
|
|
89
|
+
// 测试凭据是否有效
|
|
90
|
+
test = {
|
|
91
|
+
request: {
|
|
92
|
+
baseURL: '={{$credentials.gatewayUrl}}',
|
|
93
|
+
url: '/health',
|
|
94
|
+
method: 'GET',
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
exports.AiGatewayApi = AiGatewayApi;
|
|
99
|
+
//# sourceMappingURL=AiGatewayApi.credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AiGatewayApi.credentials.js","sourceRoot":"","sources":["../../credentials/AiGatewayApi.credentials.ts"],"names":[],"mappings":";;;AAOA,MAAa,YAAY;IACrB,IAAI,GAAG,cAAc,CAAC;IACtB,WAAW,GAAG,gBAAgB,CAAC;IAC/B,gBAAgB,GAAG,sDAAsD,CAAC;IAE1E,UAAU,GAAsB;QAC5B,iCAAiC;QACjC;Y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,EAAE,IAAI,EAAE;YAC/B,OAAO,EAAE,EAAE;YACX,WAAW,EAAE,oBAAoB;SACpC;QACD,0CAA0C;QAC1C;YACI,WAAW,EAAE,kBAAkB;YAC/B,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,EAAE;YACX,WAAW,EAAE,2BAA2B;YACxC,WAAW,EAAE,kCAAkC;SAClD;QACD;YACI,WAAW,EAAE,aAAa;YAC1B,IAAI,EAAE,cAAc;YACpB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;YAC/B,OAAO,EAAE,EAAE;YACX,WAAW,EAAE,oBAAoB;SACpC;KACJ,CAAC;IAEF,WAAW;IACX,IAAI,GAA2B;QAC3B,OAAO,EAAE;YACL,OAAO,EAAE,8BAA8B;YACvC,GAAG,EAAE,SAAS;YACd,MAAM,EAAE,KAAK;SAChB;KACJ,CAAC;CACL;AA/FD,oCA+FC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class AiGateway implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=AiGateway.node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AiGateway.node.d.ts","sourceRoot":"","sources":["../../../nodes/AiGateway/AiGateway.node.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,EACT,oBAAoB,EAEvB,MAAM,cAAc,CAAC;AAoBtB,qBAAa,SAAU,YAAW,SAAS;IACvC,WAAW,EAAE,oBAAoB,CA8N/B;IAEI,OAAO,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;CAwL1E"}
|
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AiGateway = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
// 根据 provider 获取对应的 API Key
|
|
6
|
+
function getApiKeyForProvider(credentials, provider) {
|
|
7
|
+
const keyMap = {
|
|
8
|
+
zhipu: credentials.zhipuApiKey,
|
|
9
|
+
siliconflow: credentials.siliconflowApiKey,
|
|
10
|
+
modelscope: credentials.modelscopeApiKey,
|
|
11
|
+
longcat: credentials.longcatApiKey,
|
|
12
|
+
custom: credentials.customApiKey,
|
|
13
|
+
deepseek: credentials.customApiKey,
|
|
14
|
+
moonshot: credentials.customApiKey,
|
|
15
|
+
dashscope: credentials.customApiKey,
|
|
16
|
+
spark: credentials.customApiKey,
|
|
17
|
+
openrouter: credentials.customApiKey,
|
|
18
|
+
gemini: credentials.customApiKey,
|
|
19
|
+
};
|
|
20
|
+
return keyMap[provider] || '';
|
|
21
|
+
}
|
|
22
|
+
class AiGateway {
|
|
23
|
+
description = {
|
|
24
|
+
displayName: 'AI Gateway',
|
|
25
|
+
name: 'aiGateway',
|
|
26
|
+
icon: 'file:ai-gateway.svg',
|
|
27
|
+
group: ['transform'],
|
|
28
|
+
version: 1,
|
|
29
|
+
subtitle: '={{$parameter["operation"] + ": " + $parameter["provider"]}}',
|
|
30
|
+
description: '统一 AI 网关 - 支持智谱/美团/魔搭/蚂蚁百宝箱/硅基流动等国内 AI 厂商,以及任意 OpenAI 兼容 API',
|
|
31
|
+
defaults: {
|
|
32
|
+
name: 'AI Gateway',
|
|
33
|
+
},
|
|
34
|
+
inputs: ['main'],
|
|
35
|
+
outputs: ['main'],
|
|
36
|
+
credentials: [
|
|
37
|
+
{
|
|
38
|
+
name: 'aiGatewayApi',
|
|
39
|
+
required: true,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
properties: [
|
|
43
|
+
// ============ 操作选择 ============
|
|
44
|
+
{
|
|
45
|
+
displayName: '操作',
|
|
46
|
+
name: 'operation',
|
|
47
|
+
type: 'options',
|
|
48
|
+
noDataExpression: true,
|
|
49
|
+
options: [
|
|
50
|
+
{ name: '聊天 (Chat)', value: 'chat' },
|
|
51
|
+
{ name: '图像生成 (Image)', value: 'image' },
|
|
52
|
+
{ name: '视频生成 (Video)', value: 'video' },
|
|
53
|
+
{ name: '查询异步任务', value: 'asyncQuery' },
|
|
54
|
+
{ name: '蚂蚁百宝箱', value: 'tbox' },
|
|
55
|
+
],
|
|
56
|
+
default: 'chat',
|
|
57
|
+
description: '选择操作类型',
|
|
58
|
+
},
|
|
59
|
+
// ============ 厂商选择 ============
|
|
60
|
+
{
|
|
61
|
+
displayName: '厂商 (Provider)',
|
|
62
|
+
name: 'provider',
|
|
63
|
+
type: 'options',
|
|
64
|
+
displayOptions: {
|
|
65
|
+
show: { operation: ['chat', 'image', 'video'] },
|
|
66
|
+
},
|
|
67
|
+
options: [
|
|
68
|
+
{ name: '智谱 GLM', value: 'zhipu' },
|
|
69
|
+
{ name: '硅基流动', value: 'siliconflow' },
|
|
70
|
+
{ name: '魔搭社区', value: 'modelscope' },
|
|
71
|
+
{ name: '美团 LongCat', value: 'longcat' },
|
|
72
|
+
{ name: 'DeepSeek', value: 'deepseek' },
|
|
73
|
+
{ name: 'Moonshot', value: 'moonshot' },
|
|
74
|
+
{ name: '阿里云百炼', value: 'dashscope' },
|
|
75
|
+
{ name: '讯飞星火', value: 'spark' },
|
|
76
|
+
{ name: 'OpenRouter', value: 'openrouter' },
|
|
77
|
+
{ name: 'Google Gemini', value: 'gemini' },
|
|
78
|
+
{ name: '自定义 (Custom)', value: 'custom' },
|
|
79
|
+
],
|
|
80
|
+
default: 'zhipu',
|
|
81
|
+
description: '选择 AI 厂商',
|
|
82
|
+
},
|
|
83
|
+
// ============ 模型 ============
|
|
84
|
+
{
|
|
85
|
+
displayName: '模型',
|
|
86
|
+
name: 'model',
|
|
87
|
+
type: 'string',
|
|
88
|
+
displayOptions: {
|
|
89
|
+
show: { operation: ['chat', 'image', 'video'] },
|
|
90
|
+
},
|
|
91
|
+
default: 'glm-4-flash',
|
|
92
|
+
description: '模型名称,例如: glm-4-flash, deepseek-ai/DeepSeek-V3',
|
|
93
|
+
},
|
|
94
|
+
// ============ 聊天参数 ============
|
|
95
|
+
{
|
|
96
|
+
displayName: '消息内容',
|
|
97
|
+
name: 'userMessage',
|
|
98
|
+
type: 'string',
|
|
99
|
+
typeOptions: { rows: 4 },
|
|
100
|
+
displayOptions: {
|
|
101
|
+
show: { operation: ['chat'] },
|
|
102
|
+
},
|
|
103
|
+
default: '',
|
|
104
|
+
placeholder: '输入要发送给 AI 的消息...',
|
|
105
|
+
description: '用户消息内容',
|
|
106
|
+
required: true,
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
displayName: '系统提示词',
|
|
110
|
+
name: 'systemPrompt',
|
|
111
|
+
type: 'string',
|
|
112
|
+
typeOptions: { rows: 3 },
|
|
113
|
+
displayOptions: {
|
|
114
|
+
show: { operation: ['chat'] },
|
|
115
|
+
},
|
|
116
|
+
default: '',
|
|
117
|
+
placeholder: '你是一个有帮助的助手...',
|
|
118
|
+
description: '可选的系统提示词',
|
|
119
|
+
},
|
|
120
|
+
// ============ 图像生成参数 ============
|
|
121
|
+
{
|
|
122
|
+
displayName: '图像提示词',
|
|
123
|
+
name: 'imagePrompt',
|
|
124
|
+
type: 'string',
|
|
125
|
+
typeOptions: { rows: 3 },
|
|
126
|
+
displayOptions: {
|
|
127
|
+
show: { operation: ['image'] },
|
|
128
|
+
},
|
|
129
|
+
default: '',
|
|
130
|
+
placeholder: '描述你想生成的图像...',
|
|
131
|
+
description: '图像生成提示词',
|
|
132
|
+
required: true,
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
displayName: '图像尺寸',
|
|
136
|
+
name: 'imageSize',
|
|
137
|
+
type: 'options',
|
|
138
|
+
displayOptions: {
|
|
139
|
+
show: { operation: ['image'] },
|
|
140
|
+
},
|
|
141
|
+
options: [
|
|
142
|
+
{ name: '1024x1024', value: '1024x1024' },
|
|
143
|
+
{ name: '768x1024', value: '768x1024' },
|
|
144
|
+
{ name: '1024x768', value: '1024x768' },
|
|
145
|
+
{ name: '512x512', value: '512x512' },
|
|
146
|
+
],
|
|
147
|
+
default: '1024x1024',
|
|
148
|
+
},
|
|
149
|
+
// ============ 视频生成参数 ============
|
|
150
|
+
{
|
|
151
|
+
displayName: '视频提示词',
|
|
152
|
+
name: 'videoPrompt',
|
|
153
|
+
type: 'string',
|
|
154
|
+
typeOptions: { rows: 3 },
|
|
155
|
+
displayOptions: {
|
|
156
|
+
show: { operation: ['video'] },
|
|
157
|
+
},
|
|
158
|
+
default: '',
|
|
159
|
+
placeholder: '描述你想生成的视频...',
|
|
160
|
+
description: '视频生成提示词',
|
|
161
|
+
required: true,
|
|
162
|
+
},
|
|
163
|
+
// ============ 异步查询参数 ============
|
|
164
|
+
{
|
|
165
|
+
displayName: '任务 ID',
|
|
166
|
+
name: 'taskId',
|
|
167
|
+
type: 'string',
|
|
168
|
+
displayOptions: {
|
|
169
|
+
show: { operation: ['asyncQuery'] },
|
|
170
|
+
},
|
|
171
|
+
default: '',
|
|
172
|
+
description: '异步任务的 ID',
|
|
173
|
+
required: true,
|
|
174
|
+
},
|
|
175
|
+
// ============ 蚂蚁百宝箱参数 ============
|
|
176
|
+
{
|
|
177
|
+
displayName: '问题内容',
|
|
178
|
+
name: 'tboxQuery',
|
|
179
|
+
type: 'string',
|
|
180
|
+
typeOptions: { rows: 3 },
|
|
181
|
+
displayOptions: {
|
|
182
|
+
show: { operation: ['tbox'] },
|
|
183
|
+
},
|
|
184
|
+
default: '',
|
|
185
|
+
placeholder: '输入问题...',
|
|
186
|
+
description: '发送给蚂蚁百宝箱的问题',
|
|
187
|
+
required: true,
|
|
188
|
+
},
|
|
189
|
+
// ============ 高级选项 ============
|
|
190
|
+
{
|
|
191
|
+
displayName: '高级选项',
|
|
192
|
+
name: 'advancedOptions',
|
|
193
|
+
type: 'collection',
|
|
194
|
+
placeholder: '添加选项',
|
|
195
|
+
default: {},
|
|
196
|
+
options: [
|
|
197
|
+
{
|
|
198
|
+
displayName: 'Temperature',
|
|
199
|
+
name: 'temperature',
|
|
200
|
+
type: 'number',
|
|
201
|
+
typeOptions: { minValue: 0, maxValue: 2 },
|
|
202
|
+
default: 0.7,
|
|
203
|
+
description: '控制输出的随机性 (0-2)',
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
displayName: 'Max Tokens',
|
|
207
|
+
name: 'maxTokens',
|
|
208
|
+
type: 'number',
|
|
209
|
+
default: 1000,
|
|
210
|
+
description: '最大输出 token 数',
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
displayName: 'Top P',
|
|
214
|
+
name: 'topP',
|
|
215
|
+
type: 'number',
|
|
216
|
+
typeOptions: { minValue: 0, maxValue: 1 },
|
|
217
|
+
default: 1,
|
|
218
|
+
description: '核采样参数',
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
displayName: '覆盖 API Key',
|
|
222
|
+
name: 'overrideApiKey',
|
|
223
|
+
type: 'string',
|
|
224
|
+
typeOptions: { password: true },
|
|
225
|
+
default: '',
|
|
226
|
+
description: '可选,覆盖凭据中的 API Key',
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
displayName: '覆盖 API Base',
|
|
230
|
+
name: 'overrideApiBase',
|
|
231
|
+
type: 'string',
|
|
232
|
+
default: '',
|
|
233
|
+
description: '可选,覆盖模型名称',
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
displayName: '实际模型名',
|
|
237
|
+
name: 'actualModel',
|
|
238
|
+
type: 'string',
|
|
239
|
+
default: '',
|
|
240
|
+
description: '可选,发送给 API 的实际模型名(用于模型名映射)',
|
|
241
|
+
},
|
|
242
|
+
],
|
|
243
|
+
},
|
|
244
|
+
],
|
|
245
|
+
};
|
|
246
|
+
async execute() {
|
|
247
|
+
const items = this.getInputData();
|
|
248
|
+
const returnData = [];
|
|
249
|
+
const credentials = await this.getCredentials('aiGatewayApi');
|
|
250
|
+
for (let i = 0; i < items.length; i++) {
|
|
251
|
+
try {
|
|
252
|
+
const operation = this.getNodeParameter('operation', i);
|
|
253
|
+
const gatewayUrl = credentials.gatewayUrl.replace(/\/$/, '');
|
|
254
|
+
const advancedOptions = this.getNodeParameter('advancedOptions', i, {});
|
|
255
|
+
let response;
|
|
256
|
+
if (operation === 'chat') {
|
|
257
|
+
const provider = this.getNodeParameter('provider', i);
|
|
258
|
+
const model = this.getNodeParameter('model', i);
|
|
259
|
+
const userMessage = this.getNodeParameter('userMessage', i);
|
|
260
|
+
const systemPrompt = this.getNodeParameter('systemPrompt', i, '');
|
|
261
|
+
// 获取 API Key
|
|
262
|
+
let apiKey = advancedOptions.overrideApiKey || '';
|
|
263
|
+
if (!apiKey) {
|
|
264
|
+
apiKey = getApiKeyForProvider(credentials, provider);
|
|
265
|
+
}
|
|
266
|
+
// 构建 messages
|
|
267
|
+
const messages = [];
|
|
268
|
+
if (systemPrompt) {
|
|
269
|
+
messages.push({ role: 'system', content: systemPrompt });
|
|
270
|
+
}
|
|
271
|
+
messages.push({ role: 'user', content: userMessage });
|
|
272
|
+
// 构建请求体
|
|
273
|
+
const body = {
|
|
274
|
+
provider,
|
|
275
|
+
model,
|
|
276
|
+
messages,
|
|
277
|
+
api_key: apiKey,
|
|
278
|
+
};
|
|
279
|
+
if (advancedOptions.temperature !== undefined) {
|
|
280
|
+
body.temperature = advancedOptions.temperature;
|
|
281
|
+
}
|
|
282
|
+
if (advancedOptions.maxTokens !== undefined) {
|
|
283
|
+
body.max_tokens = advancedOptions.maxTokens;
|
|
284
|
+
}
|
|
285
|
+
if (advancedOptions.topP !== undefined) {
|
|
286
|
+
body.top_p = advancedOptions.topP;
|
|
287
|
+
}
|
|
288
|
+
if (advancedOptions.overrideApiBase) {
|
|
289
|
+
body.api_base = advancedOptions.overrideApiBase;
|
|
290
|
+
}
|
|
291
|
+
if (advancedOptions.actualModel) {
|
|
292
|
+
body.actual_model = advancedOptions.actualModel;
|
|
293
|
+
}
|
|
294
|
+
response = await this.helpers.httpRequest({
|
|
295
|
+
method: 'POST',
|
|
296
|
+
url: `${gatewayUrl}/v1/chat/completions`,
|
|
297
|
+
body,
|
|
298
|
+
json: true,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
else if (operation === 'image') {
|
|
302
|
+
const provider = this.getNodeParameter('provider', i);
|
|
303
|
+
const model = this.getNodeParameter('model', i, 'cogview-3-flash');
|
|
304
|
+
const prompt = this.getNodeParameter('imagePrompt', i);
|
|
305
|
+
const size = this.getNodeParameter('imageSize', i);
|
|
306
|
+
let apiKey = advancedOptions.overrideApiKey || '';
|
|
307
|
+
if (!apiKey) {
|
|
308
|
+
apiKey = getApiKeyForProvider(credentials, provider);
|
|
309
|
+
}
|
|
310
|
+
response = await this.helpers.httpRequest({
|
|
311
|
+
method: 'POST',
|
|
312
|
+
url: `${gatewayUrl}/v1/images/generations`,
|
|
313
|
+
body: {
|
|
314
|
+
provider,
|
|
315
|
+
model,
|
|
316
|
+
prompt,
|
|
317
|
+
size,
|
|
318
|
+
api_key: apiKey,
|
|
319
|
+
},
|
|
320
|
+
json: true,
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
else if (operation === 'video') {
|
|
324
|
+
const provider = this.getNodeParameter('provider', i);
|
|
325
|
+
const model = this.getNodeParameter('model', i, 'cogvideox-flash');
|
|
326
|
+
const prompt = this.getNodeParameter('videoPrompt', i);
|
|
327
|
+
let apiKey = advancedOptions.overrideApiKey || '';
|
|
328
|
+
if (!apiKey) {
|
|
329
|
+
apiKey = getApiKeyForProvider(credentials, provider);
|
|
330
|
+
}
|
|
331
|
+
response = await this.helpers.httpRequest({
|
|
332
|
+
method: 'POST',
|
|
333
|
+
url: `${gatewayUrl}/v1/videos/generations`,
|
|
334
|
+
body: {
|
|
335
|
+
provider,
|
|
336
|
+
model,
|
|
337
|
+
prompt,
|
|
338
|
+
api_key: apiKey,
|
|
339
|
+
},
|
|
340
|
+
json: true,
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
else if (operation === 'asyncQuery') {
|
|
344
|
+
const taskId = this.getNodeParameter('taskId', i);
|
|
345
|
+
const provider = 'zhipu'; // 默认智谱
|
|
346
|
+
let apiKey = advancedOptions.overrideApiKey || credentials.zhipuApiKey || '';
|
|
347
|
+
response = await this.helpers.httpRequest({
|
|
348
|
+
method: 'GET',
|
|
349
|
+
url: `${gatewayUrl}/v1/async-result/${taskId}`,
|
|
350
|
+
headers: {
|
|
351
|
+
'Authorization': `Bearer ${apiKey}`,
|
|
352
|
+
},
|
|
353
|
+
json: true,
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
else if (operation === 'tbox') {
|
|
357
|
+
const query = this.getNodeParameter('tboxQuery', i);
|
|
358
|
+
const appId = credentials.tboxAppId;
|
|
359
|
+
const appToken = credentials.tboxToken;
|
|
360
|
+
if (!appId || !appToken) {
|
|
361
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), '蚂蚁百宝箱需要配置 App ID 和 Token', { itemIndex: i });
|
|
362
|
+
}
|
|
363
|
+
response = await this.helpers.httpRequest({
|
|
364
|
+
method: 'POST',
|
|
365
|
+
url: `${gatewayUrl}/api/tbox`,
|
|
366
|
+
body: {
|
|
367
|
+
app_id: appId,
|
|
368
|
+
app_token: appToken,
|
|
369
|
+
query,
|
|
370
|
+
},
|
|
371
|
+
json: true,
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
// 处理响应
|
|
375
|
+
if (response.error) {
|
|
376
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), response.error.message || 'API 返回错误', { itemIndex: i });
|
|
377
|
+
}
|
|
378
|
+
// 提取 AI 回复内容
|
|
379
|
+
let output = response;
|
|
380
|
+
if (response.choices && response.choices[0]) {
|
|
381
|
+
output = {
|
|
382
|
+
...response,
|
|
383
|
+
// 便捷字段
|
|
384
|
+
content: response.choices[0].message?.content || '',
|
|
385
|
+
role: response.choices[0].message?.role || 'assistant',
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
returnData.push({ json: output });
|
|
389
|
+
}
|
|
390
|
+
catch (error) {
|
|
391
|
+
if (this.continueOnFail()) {
|
|
392
|
+
returnData.push({
|
|
393
|
+
json: { error: error.message },
|
|
394
|
+
pairedItem: { item: i },
|
|
395
|
+
});
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
throw error;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return [returnData];
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
exports.AiGateway = AiGateway;
|
|
405
|
+
//# sourceMappingURL=AiGateway.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AiGateway.node.js","sourceRoot":"","sources":["../../../nodes/AiGateway/AiGateway.node.ts"],"names":[],"mappings":";;;AAAA,+CAMsB;AAEtB,4BAA4B;AAC5B,SAAS,oBAAoB,CAAC,WAAgB,EAAE,QAAgB;IAC5D,MAAM,MAAM,GAA8B;QACtC,KAAK,EAAE,WAAW,CAAC,WAAW;QAC9B,WAAW,EAAE,WAAW,CAAC,iBAAiB;QAC1C,UAAU,EAAE,WAAW,CAAC,gBAAgB;QACxC,OAAO,EAAE,WAAW,CAAC,aAAa;QAClC,MAAM,EAAE,WAAW,CAAC,YAAY;QAChC,QAAQ,EAAE,WAAW,CAAC,YAAY;QAClC,QAAQ,EAAE,WAAW,CAAC,YAAY;QAClC,SAAS,EAAE,WAAW,CAAC,YAAY;QACnC,KAAK,EAAE,WAAW,CAAC,YAAY;QAC/B,UAAU,EAAE,WAAW,CAAC,YAAY;QACpC,MAAM,EAAE,WAAW,CAAC,YAAY;KACnC,CAAC;IACF,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;AAClC,CAAC;AAED,MAAa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,CAAC,OAAO,EAAE,EACd,QAAQ,CAAC,KAAK,CAAC,OAAO,IAAI,UAAU,EACpC,EAAE,SAAS,EAAE,CAAC,EAAE,CACnB,CAAC;gBACN,CAAC;gBAED,aAAa;gBACb,IAAI,MAAM,GAAQ,QAAQ,CAAC;gBAC3B,IAAI,QAAQ,CAAC,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;oBAC1C,MAAM,GAAG;wBACL,GAAG,QAAQ;wBACX,OAAO;wBACP,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE;wBACnD,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI,IAAI,WAAW;qBACzD,CAAC;gBACN,CAAC;gBAED,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;YAEtC,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBAClB,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;oBACxB,UAAU,CAAC,IAAI,CAAC;wBACZ,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE;wBAC9B,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;qBAC1B,CAAC,CAAC;oBACH,SAAS;gBACb,CAAC;gBACD,MAAM,KAAK,CAAC;YAChB,CAAC;QACL,CAAC;QAED,OAAO,CAAC,UAAU,CAAC,CAAC;IACxB,CAAC;CACJ;AAzZD,8BAyZC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
4
|
+
<stop offset="0%" style="stop-color:#667eea;stop-opacity:1" />
|
|
5
|
+
<stop offset="100%" style="stop-color:#764ba2;stop-opacity:1" />
|
|
6
|
+
</linearGradient>
|
|
7
|
+
</defs>
|
|
8
|
+
<!-- Background -->
|
|
9
|
+
<rect x="5" y="5" width="90" height="90" rx="15" fill="url(#grad1)"/>
|
|
10
|
+
<!-- AI Brain Icon -->
|
|
11
|
+
<g fill="white">
|
|
12
|
+
<!-- Brain outline -->
|
|
13
|
+
<path d="M50,20 C35,20 25,32 25,45 C25,52 28,58 33,62 L33,70 C33,75 37,78 42,78 L58,78 C63,78 67,75 67,70 L67,62 C72,58 75,52 75,45 C75,32 65,20 50,20 Z" fill="none" stroke="white" stroke-width="3"/>
|
|
14
|
+
<!-- Neural connections -->
|
|
15
|
+
<circle cx="38" cy="40" r="4"/>
|
|
16
|
+
<circle cx="50" cy="35" r="4"/>
|
|
17
|
+
<circle cx="62" cy="40" r="4"/>
|
|
18
|
+
<circle cx="42" cy="52" r="4"/>
|
|
19
|
+
<circle cx="58" cy="52" r="4"/>
|
|
20
|
+
<line x1="38" y1="40" x2="50" y2="35" stroke="white" stroke-width="2"/>
|
|
21
|
+
<line x1="50" y1="35" x2="62" y2="40" stroke="white" stroke-width="2"/>
|
|
22
|
+
<line x1="38" y1="40" x2="42" y2="52" stroke="white" stroke-width="2"/>
|
|
23
|
+
<line x1="62" y1="40" x2="58" y2="52" stroke="white" stroke-width="2"/>
|
|
24
|
+
<line x1="42" y1="52" x2="58" y2="52" stroke="white" stroke-width="2"/>
|
|
25
|
+
<!-- Gateway arrow -->
|
|
26
|
+
<path d="M45,85 L50,90 L55,85 M50,90 L50,75" fill="none" stroke="white" stroke-width="3" stroke-linecap="round"/>
|
|
27
|
+
</g>
|
|
28
|
+
</svg>
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "n8n-nodes-ai-gateway",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "n8n 社区节点 - 统一 AI 网关,支持智谱/美团/魔搭/蚂蚁百宝箱/硅基流动等国内 AI 厂商,以及任意 OpenAI 兼容 API",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"n8n-community-node-package",
|
|
7
|
+
"n8n",
|
|
8
|
+
"ai",
|
|
9
|
+
"openai",
|
|
10
|
+
"zhipu",
|
|
11
|
+
"glm",
|
|
12
|
+
"siliconflow",
|
|
13
|
+
"modelscope",
|
|
14
|
+
"tbox",
|
|
15
|
+
"china-ai"
|
|
16
|
+
],
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"homepage": "https://github.com/DuanPeng1314/n8n-nodes-ai-gateway",
|
|
19
|
+
"author": {
|
|
20
|
+
"name": "DuanPeng1314"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "https://github.com/DuanPeng1314/n8n-nodes-ai-gateway.git"
|
|
25
|
+
},
|
|
26
|
+
"main": "dist/index.js",
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsc && gulp build:icons",
|
|
29
|
+
"dev": "tsc --watch",
|
|
30
|
+
"lint": "eslint . --ext .ts",
|
|
31
|
+
"prepublishOnly": "npm run build"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist"
|
|
35
|
+
],
|
|
36
|
+
"n8n": {
|
|
37
|
+
"n8nNodesApiVersion": 1,
|
|
38
|
+
"credentials": [
|
|
39
|
+
"dist/credentials/AiGatewayApi.credentials.js"
|
|
40
|
+
],
|
|
41
|
+
"nodes": [
|
|
42
|
+
"dist/nodes/AiGateway/AiGateway.node.js"
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "^20.10.0",
|
|
47
|
+
"gulp": "^4.0.2",
|
|
48
|
+
"n8n-workflow": "^1.0.0",
|
|
49
|
+
"typescript": "^5.9.3"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"n8n-workflow": "*"
|
|
53
|
+
}
|
|
54
|
+
}
|