n8n-nodes-rooyai 1.0.7 → 1.0.9

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 ADDED
@@ -0,0 +1,47 @@
1
+ # Rooyai Message a Model for n8n 🚀
2
+
3
+ The official **Rooyai** integration node for n8n. Seamlessly connect your workflows with top-tier AI models like **GPT-4o**, **Claude 3.5 Sonnet**, **Gemini 1.5 Pro**, and **Llama 3**.
4
+
5
+ ![Rooyai Banner](https://rooyai.com/assets/banner.png)
6
+
7
+ ## ✨ Features
8
+
9
+ - **Unified Access**: Switch between OpenAI and OpenRouter providers instantly.
10
+ - **Dynamic Models**: Always get the latest models available for your selected provider.
11
+ - **Advanced Control**: Fine-tune Temperature, Max Tokens, and System Prompts.
12
+ - **Rooyai Certified**: Built and maintained by the Rooyai team.
13
+
14
+ ## 📦 Installation
15
+
16
+ ### Automatic (Recommended)
17
+ 1. Open your n8n instance.
18
+ 2. Go to **Settings** > **Community Nodes**.
19
+ 3. Click **Install**.
20
+ 4. Type `n8n-nodes-rooyai`.
21
+ 5. Click Install!
22
+
23
+ ### Manual
24
+ ```bash
25
+ npm install n8n-nodes-rooyai
26
+
27
+ 🔑 Credentials Setup
28
+ Add a new Credential in n8n.
29
+
30
+ Search for "Rooyai API Account".
31
+
32
+ Choose your Provider (OpenAI or OpenRouter).
33
+
34
+ Paste your API Key.
35
+
36
+ 💡 Usage Example
37
+ Add the Rooyai Message a Model node.
38
+
39
+ Connect it to a Webhook or Trigger.
40
+
41
+ Select your Model (e.g., GPT-4o).
42
+
43
+ Enter your prompt in the Messages field.
44
+
45
+ Execute!
46
+
47
+ Developed with ❤️ by Rooyai.
@@ -8,39 +8,47 @@ const axios_1 = __importDefault(require("axios"));
8
8
  class RooyaiAgent {
9
9
  constructor() {
10
10
  this.description = {
11
- displayName: 'Rooyai AI Agent',
11
+ displayName: 'Rooyai Message a Model',
12
12
  name: '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: { name: 'Rooyai AI Agent' },
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: [{ name: 'rooyaiOpenRouter', required: true }],
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
- options: [
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' },
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: { multipleValues: true },
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
- minValue: 0,
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, _e, _f, _g;
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
- const response = await axios_1.default.post('https://openrouter.ai/api/v1/chat/completions', {
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(`OpenRouter API Error (${errorStatus}): ${errorMsg}`);
196
+ throw new Error(`API Error (${errorStatus}): ${errorMsg}`);
167
197
  }
168
198
  }
169
199
  }
@@ -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 API';
8
- this.documentationUrl = 'https://openrouter.ai/keys';
7
+ this.displayName = 'Rooyai API Account';
8
+ this.documentationUrl = 'https://rooyai.com';
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 the AI provider you want to use',
26
+ },
10
27
  {
11
28
  displayName: 'API Key',
12
29
  name: 'apiKey',
@@ -16,7 +33,7 @@ class RooyaiOpenRouter {
16
33
  },
17
34
  default: '',
18
35
  required: true,
19
- description: 'The API Key from OpenRouter',
36
+ description: 'The API Key for the selected provider',
20
37
  },
21
38
  ];
22
39
  }
package/package.json CHANGED
@@ -1,14 +1,29 @@
1
1
  {
2
2
  "name": "n8n-nodes-rooyai",
3
- "version": "1.0.7",
4
- "description": "Rooyai AI Agent for n8n",
3
+ "version": "1.0.9",
4
+ "description": "Rooyai Message a Model - Official n8n node for Rooyai AI services. Chat with GPT-4, Claude, Gemini, and Llama models directly.",
5
5
  "keywords": [
6
- "n8n-community-node-package"
6
+ "n8n-community-node-package",
7
+ "rooyai",
8
+ "ai",
9
+ "chat",
10
+ "llm",
11
+ "openai",
12
+ "openrouter",
13
+ "gpt-4",
14
+ "claude",
15
+ "automation"
7
16
  ],
8
17
  "license": "MIT",
9
18
  "author": {
10
19
  "name": "Rooyai",
11
- "email": "contact@rooyai.com"
20
+ "email": "contact@rooyai.com",
21
+ "url": "https://rooyai.com"
22
+ },
23
+ "homepage": "https://rooyai.com",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/rooyai/n8n-nodes-rooyai"
12
27
  },
13
28
  "community": {
14
29
  "author": "Rooyai"