n8n-nodes-rooyai 1.0.6 → 1.0.8
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
|
@@ -13,34 +13,42 @@ class RooyaiAgent {
|
|
|
13
13
|
icon: 'file:rooyai.svg',
|
|
14
14
|
group: ['transform'],
|
|
15
15
|
version: 1,
|
|
16
|
-
description: 'Chat with AI models via OpenRouter',
|
|
17
|
-
defaults: {
|
|
16
|
+
description: 'Chat with AI models via OpenRouter or OpenAI',
|
|
17
|
+
defaults: {
|
|
18
|
+
name: 'Rooyai AI Agent',
|
|
19
|
+
},
|
|
18
20
|
inputs: ['main'],
|
|
19
21
|
outputs: ['main'],
|
|
20
|
-
credentials: [
|
|
22
|
+
credentials: [
|
|
23
|
+
{
|
|
24
|
+
name: 'rooyaiOpenRouter',
|
|
25
|
+
required: true,
|
|
26
|
+
},
|
|
27
|
+
],
|
|
21
28
|
properties: [
|
|
22
29
|
{
|
|
23
30
|
displayName: 'Model',
|
|
24
31
|
name: 'model',
|
|
25
32
|
type: 'options',
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
default: 'openai/gpt-4o-mini',
|
|
34
|
-
description: 'Select AI model',
|
|
33
|
+
typeOptions: {
|
|
34
|
+
loadOptionsMethod: 'getModels',
|
|
35
|
+
loadOptionsDependsOn: ['rooyaiOpenRouter.providerType'],
|
|
36
|
+
},
|
|
37
|
+
default: '',
|
|
38
|
+
description: 'Select AI model based on provider',
|
|
39
|
+
required: true,
|
|
35
40
|
},
|
|
36
41
|
{
|
|
37
42
|
displayName: 'Messages',
|
|
38
43
|
name: 'messages',
|
|
39
44
|
type: 'fixedCollection',
|
|
40
|
-
typeOptions: {
|
|
45
|
+
typeOptions: {
|
|
46
|
+
multipleValues: true,
|
|
47
|
+
},
|
|
41
48
|
default: {},
|
|
42
49
|
placeholder: 'Add Message',
|
|
43
|
-
options: [
|
|
50
|
+
options: [
|
|
51
|
+
{
|
|
44
52
|
name: 'messageValues',
|
|
45
53
|
displayName: 'Message',
|
|
46
54
|
values: [
|
|
@@ -64,7 +72,8 @@ class RooyaiAgent {
|
|
|
64
72
|
description: 'Message content',
|
|
65
73
|
},
|
|
66
74
|
],
|
|
67
|
-
}
|
|
75
|
+
},
|
|
76
|
+
],
|
|
68
77
|
},
|
|
69
78
|
{
|
|
70
79
|
displayName: 'Options',
|
|
@@ -78,12 +87,8 @@ class RooyaiAgent {
|
|
|
78
87
|
name: 'temperature',
|
|
79
88
|
type: 'number',
|
|
80
89
|
default: 0.7,
|
|
81
|
-
typeOptions: {
|
|
82
|
-
|
|
83
|
-
maxValue: 2,
|
|
84
|
-
numberStepSize: 0.1,
|
|
85
|
-
},
|
|
86
|
-
description: 'Controls randomness (0 = focused, 2 = creative)',
|
|
90
|
+
typeOptions: { minValue: 0, maxValue: 2, numberStepSize: 0.1 },
|
|
91
|
+
description: 'Controls randomness',
|
|
87
92
|
},
|
|
88
93
|
{
|
|
89
94
|
displayName: 'Max Tokens',
|
|
@@ -103,12 +108,41 @@ class RooyaiAgent {
|
|
|
103
108
|
},
|
|
104
109
|
],
|
|
105
110
|
};
|
|
111
|
+
this.methods = {
|
|
112
|
+
loadOptions: {
|
|
113
|
+
async getModels() {
|
|
114
|
+
const credentials = await this.getCredentials('rooyaiOpenRouter');
|
|
115
|
+
const providerType = credentials.providerType;
|
|
116
|
+
if (providerType === 'openai') {
|
|
117
|
+
return [
|
|
118
|
+
{ name: 'GPT-4o', value: 'gpt-4o' },
|
|
119
|
+
{ name: 'GPT-4o Mini', value: 'gpt-4o-mini' },
|
|
120
|
+
{ name: 'GPT-4 Turbo', value: 'gpt-4-turbo' },
|
|
121
|
+
{ name: 'GPT-3.5 Turbo', value: 'gpt-3.5-turbo' },
|
|
122
|
+
{ name: 'GPT-4', value: 'gpt-4' },
|
|
123
|
+
];
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
return [
|
|
127
|
+
{ name: 'GPT-4o (OpenRouter)', value: 'openai/gpt-4o' },
|
|
128
|
+
{ name: 'GPT-4o Mini (OpenRouter)', value: 'openai/gpt-4o-mini' },
|
|
129
|
+
{ name: 'Claude 3.5 Sonnet', value: 'anthropic/claude-3.5-sonnet' },
|
|
130
|
+
{ name: 'Gemini Pro 1.5', value: 'google/gemini-pro-1.5' },
|
|
131
|
+
{ name: 'Llama 3.1 70B', value: 'meta-llama/llama-3.1-70b-instruct' },
|
|
132
|
+
{ name: 'DeepSeek V3', value: 'deepseek/deepseek-chat' },
|
|
133
|
+
];
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
};
|
|
106
138
|
}
|
|
107
139
|
async execute() {
|
|
108
|
-
var _a, _b, _c, _d
|
|
140
|
+
var _a, _b, _c, _d;
|
|
109
141
|
const items = this.getInputData();
|
|
110
142
|
const returnData = [];
|
|
111
143
|
const credentials = await this.getCredentials('rooyaiOpenRouter');
|
|
144
|
+
const providerType = credentials.providerType;
|
|
145
|
+
const apiKey = credentials.apiKey;
|
|
112
146
|
for (let i = 0; i < items.length; i++) {
|
|
113
147
|
try {
|
|
114
148
|
const model = this.getNodeParameter('model', i);
|
|
@@ -118,31 +152,34 @@ class RooyaiAgent {
|
|
|
118
152
|
const messages = [];
|
|
119
153
|
if (messagesInput.messageValues && Array.isArray(messagesInput.messageValues)) {
|
|
120
154
|
for (const msg of messagesInput.messageValues) {
|
|
121
|
-
messages.push({
|
|
122
|
-
role: msg.role,
|
|
123
|
-
content: msg.text
|
|
124
|
-
});
|
|
155
|
+
messages.push({ role: msg.role, content: msg.text });
|
|
125
156
|
}
|
|
126
157
|
}
|
|
127
|
-
|
|
158
|
+
let apiUrl = '';
|
|
159
|
+
let headers = {
|
|
160
|
+
'Authorization': `Bearer ${apiKey}`,
|
|
161
|
+
'Content-Type': 'application/json',
|
|
162
|
+
};
|
|
163
|
+
if (providerType === 'openai') {
|
|
164
|
+
apiUrl = 'https://api.openai.com/v1/chat/completions';
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
apiUrl = 'https://openrouter.ai/api/v1/chat/completions';
|
|
168
|
+
headers['HTTP-Referer'] = 'https://rooyai.com';
|
|
169
|
+
headers['X-Title'] = 'Rooyai AI Agent';
|
|
170
|
+
}
|
|
171
|
+
const response = await axios_1.default.post(apiUrl, {
|
|
128
172
|
model,
|
|
129
173
|
messages,
|
|
130
174
|
temperature: options.temperature || 0.7,
|
|
131
175
|
max_tokens: options.maxTokens || 2000,
|
|
132
|
-
}, {
|
|
133
|
-
headers: {
|
|
134
|
-
'Authorization': `Bearer ${credentials.apiKey}`,
|
|
135
|
-
'Content-Type': 'application/json',
|
|
136
|
-
'HTTP-Referer': 'https://rooyai.com',
|
|
137
|
-
'X-Title': 'Rooyai AI Agent',
|
|
138
|
-
},
|
|
139
|
-
});
|
|
176
|
+
}, { headers });
|
|
140
177
|
if (simplifyOutput) {
|
|
141
178
|
returnData.push({
|
|
142
179
|
json: {
|
|
143
180
|
message: response.data.choices[0].message.content,
|
|
144
181
|
model: response.data.model,
|
|
145
|
-
}
|
|
182
|
+
},
|
|
146
183
|
});
|
|
147
184
|
}
|
|
148
185
|
else {
|
|
@@ -152,18 +189,11 @@ class RooyaiAgent {
|
|
|
152
189
|
catch (error) {
|
|
153
190
|
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;
|
|
154
191
|
const errorStatus = (_d = error.response) === null || _d === void 0 ? void 0 : _d.status;
|
|
155
|
-
const errorCode = (_g = (_f = (_e = error.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.error) === null || _g === void 0 ? void 0 : _g.code;
|
|
156
192
|
if (this.continueOnFail()) {
|
|
157
|
-
returnData.push({
|
|
158
|
-
json: {
|
|
159
|
-
error: errorMsg,
|
|
160
|
-
status: errorStatus,
|
|
161
|
-
code: errorCode
|
|
162
|
-
}
|
|
163
|
-
});
|
|
193
|
+
returnData.push({ json: { error: errorMsg, status: errorStatus } });
|
|
164
194
|
}
|
|
165
195
|
else {
|
|
166
|
-
throw new Error(`
|
|
196
|
+
throw new Error(`API Error (${errorStatus}): ${errorMsg}`);
|
|
167
197
|
}
|
|
168
198
|
}
|
|
169
199
|
}
|
|
@@ -4,8 +4,8 @@ exports.RooyaiOpenRouter = void 0;
|
|
|
4
4
|
class RooyaiOpenRouter {
|
|
5
5
|
constructor() {
|
|
6
6
|
this.name = 'rooyaiOpenRouter';
|
|
7
|
-
this.displayName = 'Rooyai
|
|
8
|
-
this.documentationUrl = 'https://
|
|
7
|
+
this.displayName = 'Rooyai API Account';
|
|
8
|
+
this.documentationUrl = 'https://rooyai.com';
|
|
9
9
|
this.properties = [
|
|
10
10
|
{
|
|
11
11
|
displayName: 'Provider Type',
|
|
@@ -22,16 +22,18 @@ class RooyaiOpenRouter {
|
|
|
22
22
|
},
|
|
23
23
|
],
|
|
24
24
|
default: 'openrouter',
|
|
25
|
-
description: 'Select AI provider',
|
|
25
|
+
description: 'Select the AI provider you want to use',
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
28
|
displayName: 'API Key',
|
|
29
29
|
name: 'apiKey',
|
|
30
30
|
type: 'string',
|
|
31
|
-
typeOptions: {
|
|
31
|
+
typeOptions: {
|
|
32
|
+
password: true,
|
|
33
|
+
},
|
|
32
34
|
default: '',
|
|
33
35
|
required: true,
|
|
34
|
-
description: '
|
|
36
|
+
description: 'The API Key for the selected provider',
|
|
35
37
|
},
|
|
36
38
|
];
|
|
37
39
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-rooyai",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "Rooyai AI Agent for n8n",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package"
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
"main": "index.js",
|
|
17
17
|
"n8n": {
|
|
18
18
|
"n8nNodesApiVersion": 1,
|
|
19
|
+
"credentials": [
|
|
20
|
+
"dist/RooyaiOpenRouter.credentials.js"
|
|
21
|
+
],
|
|
19
22
|
"nodes": [
|
|
20
23
|
"dist/RooyaiAgent.node.js"
|
|
21
24
|
]
|