n8n-nodes-rooyai 1.0.5 → 1.0.7
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 +135 -55
- package/dist/RooyaiOpenRouter.credentials.js +6 -21
- package/package.json +4 -1
package/dist/RooyaiAgent.node.js
CHANGED
|
@@ -1,91 +1,171 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.RooyaiAgent = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
4
8
|
class RooyaiAgent {
|
|
5
9
|
constructor() {
|
|
6
10
|
this.description = {
|
|
7
|
-
displayName: 'Rooyai Agent',
|
|
11
|
+
displayName: 'Rooyai AI Agent',
|
|
8
12
|
name: 'rooyaiAgent',
|
|
9
13
|
icon: 'file:rooyai.svg',
|
|
10
14
|
group: ['transform'],
|
|
11
15
|
version: 1,
|
|
12
|
-
description: '
|
|
13
|
-
defaults: {
|
|
14
|
-
name: 'Rooyai Agent',
|
|
15
|
-
},
|
|
16
|
+
description: 'Chat with AI models via OpenRouter',
|
|
17
|
+
defaults: { name: 'Rooyai AI Agent' },
|
|
16
18
|
inputs: ['main'],
|
|
17
19
|
outputs: ['main'],
|
|
18
|
-
credentials: [
|
|
19
|
-
{
|
|
20
|
-
name: 'rooyaiAgentApi',
|
|
21
|
-
required: true,
|
|
22
|
-
},
|
|
23
|
-
],
|
|
20
|
+
credentials: [{ name: 'rooyaiOpenRouter', required: true }],
|
|
24
21
|
properties: [
|
|
25
22
|
{
|
|
26
23
|
displayName: 'Model',
|
|
27
24
|
name: 'model',
|
|
28
25
|
type: 'options',
|
|
29
|
-
typeOptions: {
|
|
30
|
-
loadOptionsMethod: 'getModels',
|
|
31
|
-
},
|
|
32
|
-
default: 'gpt-4',
|
|
33
26
|
options: [
|
|
34
|
-
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: 'GPT-3.5 Turbo',
|
|
40
|
-
value: 'gpt-3.5-turbo',
|
|
41
|
-
},
|
|
27
|
+
{ name: 'GPT-4o', value: 'openai/gpt-4o' },
|
|
28
|
+
{ name: 'GPT-4o Mini', value: 'openai/gpt-4o-mini' },
|
|
29
|
+
{ name: 'Claude 3.5 Sonnet', value: 'anthropic/claude-3.5-sonnet' },
|
|
30
|
+
{ name: 'Gemini Pro 1.5', value: 'google/gemini-pro-1.5' },
|
|
31
|
+
{ name: 'Llama 3.1 70B', value: 'meta-llama/llama-3.1-70b-instruct' },
|
|
42
32
|
],
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
default: 'openai/gpt-4o-mini',
|
|
34
|
+
description: 'Select AI model',
|
|
45
35
|
},
|
|
46
36
|
{
|
|
47
|
-
displayName: '
|
|
48
|
-
name: '
|
|
49
|
-
type: '
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
37
|
+
displayName: 'Messages',
|
|
38
|
+
name: 'messages',
|
|
39
|
+
type: 'fixedCollection',
|
|
40
|
+
typeOptions: { multipleValues: true },
|
|
41
|
+
default: {},
|
|
42
|
+
placeholder: 'Add Message',
|
|
43
|
+
options: [{
|
|
44
|
+
name: 'messageValues',
|
|
45
|
+
displayName: 'Message',
|
|
46
|
+
values: [
|
|
47
|
+
{
|
|
48
|
+
displayName: 'Role',
|
|
49
|
+
name: 'role',
|
|
50
|
+
type: 'options',
|
|
51
|
+
options: [
|
|
52
|
+
{ name: 'User', value: 'user' },
|
|
53
|
+
{ name: 'System', value: 'system' },
|
|
54
|
+
{ name: 'Assistant', value: 'assistant' },
|
|
55
|
+
],
|
|
56
|
+
default: 'user',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
displayName: 'Text',
|
|
60
|
+
name: 'text',
|
|
61
|
+
type: 'string',
|
|
62
|
+
typeOptions: { rows: 4 },
|
|
63
|
+
default: '',
|
|
64
|
+
description: 'Message content',
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
}],
|
|
54
68
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
69
|
+
{
|
|
70
|
+
displayName: 'Options',
|
|
71
|
+
name: 'options',
|
|
72
|
+
type: 'collection',
|
|
73
|
+
placeholder: 'Add Option',
|
|
74
|
+
default: {},
|
|
75
|
+
options: [
|
|
61
76
|
{
|
|
62
|
-
|
|
63
|
-
|
|
77
|
+
displayName: 'Temperature',
|
|
78
|
+
name: 'temperature',
|
|
79
|
+
type: 'number',
|
|
80
|
+
default: 0.7,
|
|
81
|
+
typeOptions: {
|
|
82
|
+
minValue: 0,
|
|
83
|
+
maxValue: 2,
|
|
84
|
+
numberStepSize: 0.1,
|
|
85
|
+
},
|
|
86
|
+
description: 'Controls randomness (0 = focused, 2 = creative)',
|
|
64
87
|
},
|
|
65
88
|
{
|
|
66
|
-
|
|
67
|
-
|
|
89
|
+
displayName: 'Max Tokens',
|
|
90
|
+
name: 'maxTokens',
|
|
91
|
+
type: 'number',
|
|
92
|
+
default: 2000,
|
|
93
|
+
description: 'Maximum response length',
|
|
68
94
|
},
|
|
69
|
-
]
|
|
95
|
+
],
|
|
70
96
|
},
|
|
71
|
-
|
|
97
|
+
{
|
|
98
|
+
displayName: 'Simplify Output',
|
|
99
|
+
name: 'simplifyOutput',
|
|
100
|
+
type: 'boolean',
|
|
101
|
+
default: true,
|
|
102
|
+
description: 'Whether to return only the message text',
|
|
103
|
+
},
|
|
104
|
+
],
|
|
72
105
|
};
|
|
73
106
|
}
|
|
74
107
|
async execute() {
|
|
108
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
75
109
|
const items = this.getInputData();
|
|
76
110
|
const returnData = [];
|
|
111
|
+
const credentials = await this.getCredentials('rooyaiOpenRouter');
|
|
77
112
|
for (let i = 0; i < items.length; i++) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
113
|
+
try {
|
|
114
|
+
const model = this.getNodeParameter('model', i);
|
|
115
|
+
const messagesInput = this.getNodeParameter('messages', i, {});
|
|
116
|
+
const options = this.getNodeParameter('options', i, {});
|
|
117
|
+
const simplifyOutput = this.getNodeParameter('simplifyOutput', i);
|
|
118
|
+
const messages = [];
|
|
119
|
+
if (messagesInput.messageValues && Array.isArray(messagesInput.messageValues)) {
|
|
120
|
+
for (const msg of messagesInput.messageValues) {
|
|
121
|
+
messages.push({
|
|
122
|
+
role: msg.role,
|
|
123
|
+
content: msg.text
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const response = await axios_1.default.post('https://openrouter.ai/api/v1/chat/completions', {
|
|
128
|
+
model,
|
|
129
|
+
messages,
|
|
130
|
+
temperature: options.temperature || 0.7,
|
|
131
|
+
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
|
+
});
|
|
140
|
+
if (simplifyOutput) {
|
|
141
|
+
returnData.push({
|
|
142
|
+
json: {
|
|
143
|
+
message: response.data.choices[0].message.content,
|
|
144
|
+
model: response.data.model,
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
returnData.push({ json: response.data });
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
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
|
+
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
|
+
if (this.continueOnFail()) {
|
|
157
|
+
returnData.push({
|
|
158
|
+
json: {
|
|
159
|
+
error: errorMsg,
|
|
160
|
+
status: errorStatus,
|
|
161
|
+
code: errorCode
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
throw new Error(`OpenRouter API Error (${errorStatus}): ${errorMsg}`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
89
169
|
}
|
|
90
170
|
return [returnData];
|
|
91
171
|
}
|
|
@@ -4,34 +4,19 @@ exports.RooyaiOpenRouter = void 0;
|
|
|
4
4
|
class RooyaiOpenRouter {
|
|
5
5
|
constructor() {
|
|
6
6
|
this.name = 'rooyaiOpenRouter';
|
|
7
|
-
this.displayName = 'Rooyai OpenRouter
|
|
8
|
-
this.documentationUrl = 'https://openrouter.ai/
|
|
7
|
+
this.displayName = 'Rooyai OpenRouter API';
|
|
8
|
+
this.documentationUrl = 'https://openrouter.ai/keys';
|
|
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
|
-
},
|
|
27
10
|
{
|
|
28
11
|
displayName: 'API Key',
|
|
29
12
|
name: 'apiKey',
|
|
30
13
|
type: 'string',
|
|
31
|
-
typeOptions: {
|
|
14
|
+
typeOptions: {
|
|
15
|
+
password: true,
|
|
16
|
+
},
|
|
32
17
|
default: '',
|
|
33
18
|
required: true,
|
|
34
|
-
description: '
|
|
19
|
+
description: 'The API Key from OpenRouter',
|
|
35
20
|
},
|
|
36
21
|
];
|
|
37
22
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-rooyai",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
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
|
]
|