n8n-nodes-rooyai 1.0.0 → 1.0.2
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/RooyaiAgent.node.js
CHANGED
|
@@ -10,49 +10,33 @@ class RooyaiAgent {
|
|
|
10
10
|
this.description = {
|
|
11
11
|
displayName: 'Rooyai AI Agent',
|
|
12
12
|
name: 'rooyaiAgent',
|
|
13
|
-
icon: '
|
|
13
|
+
icon: 'file:rooyai.svg',
|
|
14
14
|
group: ['transform'],
|
|
15
15
|
version: 1,
|
|
16
|
-
description: 'Chat with AI models via OpenRouter',
|
|
17
|
-
defaults: {
|
|
18
|
-
name: 'Rooyai AI Agent',
|
|
19
|
-
},
|
|
16
|
+
description: 'Chat with AI models via OpenRouter or OpenAI',
|
|
17
|
+
defaults: { name: 'Rooyai AI Agent' },
|
|
20
18
|
inputs: ['main'],
|
|
21
19
|
outputs: ['main'],
|
|
22
|
-
credentials: [
|
|
23
|
-
{
|
|
24
|
-
name: 'rooyaiOpenRouter',
|
|
25
|
-
required: true,
|
|
26
|
-
},
|
|
27
|
-
],
|
|
20
|
+
credentials: [{ name: 'rooyaiOpenRouter', required: true }],
|
|
28
21
|
properties: [
|
|
29
22
|
{
|
|
30
23
|
displayName: 'Model',
|
|
31
24
|
name: 'model',
|
|
32
25
|
type: 'options',
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
{ name: 'Gemini Pro 1.5', value: 'google/gemini-pro-1.5' },
|
|
39
|
-
{ name: 'Llama 3.1 70B', value: 'meta-llama/llama-3.1-70b-instruct' },
|
|
40
|
-
{ name: 'Mistral Large', value: 'mistralai/mistral-large' },
|
|
41
|
-
],
|
|
42
|
-
default: 'openai/gpt-4o-mini',
|
|
43
|
-
description: 'Select the AI model',
|
|
26
|
+
typeOptions: {
|
|
27
|
+
loadOptionsMethod: 'getModels',
|
|
28
|
+
},
|
|
29
|
+
default: '',
|
|
30
|
+
description: 'Select AI model',
|
|
44
31
|
},
|
|
45
32
|
{
|
|
46
33
|
displayName: 'Messages',
|
|
47
34
|
name: 'messages',
|
|
48
35
|
type: 'fixedCollection',
|
|
49
|
-
typeOptions: {
|
|
50
|
-
multipleValues: true,
|
|
51
|
-
},
|
|
36
|
+
typeOptions: { multipleValues: true },
|
|
52
37
|
default: {},
|
|
53
38
|
placeholder: 'Add Message',
|
|
54
|
-
options: [
|
|
55
|
-
{
|
|
39
|
+
options: [{
|
|
56
40
|
name: 'messageValues',
|
|
57
41
|
displayName: 'Message',
|
|
58
42
|
values: [
|
|
@@ -71,14 +55,12 @@ class RooyaiAgent {
|
|
|
71
55
|
displayName: 'Text',
|
|
72
56
|
name: 'text',
|
|
73
57
|
type: 'string',
|
|
74
|
-
typeOptions: {
|
|
75
|
-
rows: 4,
|
|
76
|
-
},
|
|
58
|
+
typeOptions: { rows: 4 },
|
|
77
59
|
default: '',
|
|
60
|
+
description: 'Message content',
|
|
78
61
|
},
|
|
79
62
|
],
|
|
80
|
-
},
|
|
81
|
-
],
|
|
63
|
+
}],
|
|
82
64
|
},
|
|
83
65
|
{
|
|
84
66
|
displayName: 'Options',
|
|
@@ -97,12 +79,14 @@ class RooyaiAgent {
|
|
|
97
79
|
maxValue: 2,
|
|
98
80
|
numberStepSize: 0.1,
|
|
99
81
|
},
|
|
82
|
+
description: 'Controls randomness (0 = focused, 2 = creative)',
|
|
100
83
|
},
|
|
101
84
|
{
|
|
102
85
|
displayName: 'Max Tokens',
|
|
103
86
|
name: 'maxTokens',
|
|
104
87
|
type: 'number',
|
|
105
88
|
default: 2000,
|
|
89
|
+
description: 'Maximum response length',
|
|
106
90
|
},
|
|
107
91
|
],
|
|
108
92
|
},
|
|
@@ -111,14 +95,46 @@ class RooyaiAgent {
|
|
|
111
95
|
name: 'simplifyOutput',
|
|
112
96
|
type: 'boolean',
|
|
113
97
|
default: true,
|
|
98
|
+
description: 'Whether to return only the message text',
|
|
114
99
|
},
|
|
115
100
|
],
|
|
116
101
|
};
|
|
102
|
+
this.methods = {
|
|
103
|
+
loadOptions: {
|
|
104
|
+
async getModels() {
|
|
105
|
+
const credentials = await this.getCredentials('rooyaiOpenRouter');
|
|
106
|
+
const providerType = credentials.providerType;
|
|
107
|
+
if (providerType === 'openrouter') {
|
|
108
|
+
return [
|
|
109
|
+
{ name: 'GPT-4o', value: 'openai/gpt-4o' },
|
|
110
|
+
{ name: 'GPT-4o Mini', value: 'openai/gpt-4o-mini' },
|
|
111
|
+
{ name: 'Claude 3.5 Sonnet', value: 'anthropic/claude-3.5-sonnet' },
|
|
112
|
+
{ name: 'Claude 3 Opus', value: 'anthropic/claude-3-opus' },
|
|
113
|
+
{ name: 'Gemini Pro 1.5', value: 'google/gemini-pro-1.5' },
|
|
114
|
+
{ name: 'Llama 3.1 70B', value: 'meta-llama/llama-3.1-70b-instruct' },
|
|
115
|
+
{ name: 'Mistral Large', value: 'mistralai/mistral-large' },
|
|
116
|
+
{ name: 'DeepSeek V3', value: 'deepseek/deepseek-chat' },
|
|
117
|
+
];
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
return [
|
|
121
|
+
{ name: 'GPT-4o', value: 'gpt-4o' },
|
|
122
|
+
{ name: 'GPT-4o Mini', value: 'gpt-4o-mini' },
|
|
123
|
+
{ name: 'GPT-4 Turbo', value: 'gpt-4-turbo' },
|
|
124
|
+
{ name: 'GPT-3.5 Turbo', value: 'gpt-3.5-turbo' },
|
|
125
|
+
{ name: 'GPT-4', value: 'gpt-4' },
|
|
126
|
+
];
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
};
|
|
117
131
|
}
|
|
118
132
|
async execute() {
|
|
133
|
+
var _a, _b, _c, _d;
|
|
119
134
|
const items = this.getInputData();
|
|
120
135
|
const returnData = [];
|
|
121
136
|
const credentials = await this.getCredentials('rooyaiOpenRouter');
|
|
137
|
+
const providerType = credentials.providerType;
|
|
122
138
|
for (let i = 0; i < items.length; i++) {
|
|
123
139
|
try {
|
|
124
140
|
const model = this.getNodeParameter('model', i);
|
|
@@ -128,25 +144,28 @@ class RooyaiAgent {
|
|
|
128
144
|
const messages = [];
|
|
129
145
|
if (messagesInput.messageValues && Array.isArray(messagesInput.messageValues)) {
|
|
130
146
|
for (const msg of messagesInput.messageValues) {
|
|
131
|
-
messages.push({
|
|
132
|
-
role: msg.role,
|
|
133
|
-
content: msg.text,
|
|
134
|
-
});
|
|
147
|
+
messages.push({ role: msg.role, content: msg.text });
|
|
135
148
|
}
|
|
136
149
|
}
|
|
137
|
-
|
|
150
|
+
let apiUrl = '';
|
|
151
|
+
let headers = {
|
|
152
|
+
'Authorization': `Bearer ${credentials.apiKey}`,
|
|
153
|
+
'Content-Type': 'application/json',
|
|
154
|
+
};
|
|
155
|
+
if (providerType === 'openrouter') {
|
|
156
|
+
apiUrl = 'https://openrouter.ai/api/v1/chat/completions';
|
|
157
|
+
headers['HTTP-Referer'] = 'https://rooyai.com';
|
|
158
|
+
headers['X-Title'] = 'Rooyai AI Agent';
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
apiUrl = 'https://api.openai.com/v1/chat/completions';
|
|
162
|
+
}
|
|
163
|
+
const response = await axios_1.default.post(apiUrl, {
|
|
138
164
|
model,
|
|
139
165
|
messages,
|
|
140
166
|
temperature: options.temperature || 0.7,
|
|
141
167
|
max_tokens: options.maxTokens || 2000,
|
|
142
|
-
}, {
|
|
143
|
-
headers: {
|
|
144
|
-
'Authorization': `Bearer ${credentials.apiKey}`,
|
|
145
|
-
'Content-Type': 'application/json',
|
|
146
|
-
'HTTP-Referer': 'https://rooyai.com',
|
|
147
|
-
'X-Title': 'Rooyai AI',
|
|
148
|
-
},
|
|
149
|
-
});
|
|
168
|
+
}, { headers });
|
|
150
169
|
if (simplifyOutput) {
|
|
151
170
|
returnData.push({
|
|
152
171
|
json: {
|
|
@@ -160,11 +179,29 @@ class RooyaiAgent {
|
|
|
160
179
|
}
|
|
161
180
|
}
|
|
162
181
|
catch (error) {
|
|
182
|
+
const errorMsg = ((_c = (_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) || error.message;
|
|
183
|
+
const errorStatus = (_d = error.response) === null || _d === void 0 ? void 0 : _d.status;
|
|
184
|
+
let hint = '';
|
|
185
|
+
if (errorStatus === 401) {
|
|
186
|
+
hint = 'Invalid API Key. Check your credential.';
|
|
187
|
+
}
|
|
188
|
+
else if (errorStatus === 429) {
|
|
189
|
+
hint = 'Rate limit exceeded.';
|
|
190
|
+
}
|
|
191
|
+
else if (errorStatus === 402) {
|
|
192
|
+
hint = 'Insufficient credits.';
|
|
193
|
+
}
|
|
163
194
|
if (this.continueOnFail()) {
|
|
164
|
-
returnData.push({
|
|
195
|
+
returnData.push({
|
|
196
|
+
json: {
|
|
197
|
+
error: errorMsg,
|
|
198
|
+
status: errorStatus,
|
|
199
|
+
hint: hint || 'Unknown error',
|
|
200
|
+
},
|
|
201
|
+
});
|
|
165
202
|
}
|
|
166
203
|
else {
|
|
167
|
-
throw
|
|
204
|
+
throw new Error(`API Error (${errorStatus}): ${errorMsg}. ${hint}`);
|
|
168
205
|
}
|
|
169
206
|
}
|
|
170
207
|
}
|
|
@@ -4,9 +4,26 @@ exports.RooyaiOpenRouter = void 0;
|
|
|
4
4
|
class RooyaiOpenRouter {
|
|
5
5
|
constructor() {
|
|
6
6
|
this.name = 'rooyaiOpenRouter';
|
|
7
|
-
this.displayName = 'Rooyai OpenRouter
|
|
7
|
+
this.displayName = 'Rooyai OpenRouter account';
|
|
8
8
|
this.documentationUrl = 'https://openrouter.ai/docs';
|
|
9
9
|
this.properties = [
|
|
10
|
+
{
|
|
11
|
+
displayName: 'Provider Type',
|
|
12
|
+
name: 'providerType',
|
|
13
|
+
type: 'options',
|
|
14
|
+
options: [
|
|
15
|
+
{
|
|
16
|
+
name: 'OpenRouter',
|
|
17
|
+
value: 'openrouter',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'OpenAI',
|
|
21
|
+
value: 'openai',
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
default: 'openrouter',
|
|
25
|
+
description: 'Select AI provider',
|
|
26
|
+
},
|
|
10
27
|
{
|
|
11
28
|
displayName: 'API Key',
|
|
12
29
|
name: 'apiKey',
|
|
@@ -14,7 +31,7 @@ class RooyaiOpenRouter {
|
|
|
14
31
|
typeOptions: { password: true },
|
|
15
32
|
default: '',
|
|
16
33
|
required: true,
|
|
17
|
-
description: 'Your
|
|
34
|
+
description: 'Your API Key',
|
|
18
35
|
},
|
|
19
36
|
];
|
|
20
37
|
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-rooyai",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Rooyai AI Agent for n8n
|
|
5
|
-
"keywords": [
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "Rooyai AI Agent for n8n",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"n8n-community-node-package"
|
|
7
|
+
],
|
|
6
8
|
"license": "MIT",
|
|
7
|
-
"author": "Rooyai",
|
|
8
9
|
"main": "index.js",
|
|
9
10
|
"scripts": {
|
|
10
|
-
"build": "tsc"
|
|
11
|
-
"prepublishOnly": "npm run build"
|
|
11
|
+
"build": "tsc"
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
14
14
|
"dist"
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
]
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@types/node": "^20.0.0",
|
|
26
25
|
"n8n-workflow": "^1.0.0",
|
|
27
26
|
"typescript": "^5.0.0"
|
|
28
27
|
},
|