n8n-nodes-rooyai 1.0.4 → 1.0.5

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.
@@ -1,23 +1,26 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.RooyaiAgent = void 0;
7
- const axios_1 = __importDefault(require("axios"));
8
4
  class RooyaiAgent {
9
5
  constructor() {
10
6
  this.description = {
11
- displayName: 'Rooyai AI Agent',
7
+ displayName: 'Rooyai Agent',
12
8
  name: 'rooyaiAgent',
13
9
  icon: 'file:rooyai.svg',
14
10
  group: ['transform'],
15
11
  version: 1,
16
- description: 'Chat with AI models via OpenRouter or OpenAI',
17
- defaults: { name: 'Rooyai AI Agent' },
12
+ description: 'Rooyai Automation Agent Node',
13
+ defaults: {
14
+ name: 'Rooyai Agent',
15
+ },
18
16
  inputs: ['main'],
19
17
  outputs: ['main'],
20
- credentials: [{ name: 'rooyaiOpenRouter', required: true }],
18
+ credentials: [
19
+ {
20
+ name: 'rooyaiAgentApi',
21
+ required: true,
22
+ },
23
+ ],
21
24
  properties: [
22
25
  {
23
26
  displayName: 'Model',
@@ -26,184 +29,63 @@ class RooyaiAgent {
26
29
  typeOptions: {
27
30
  loadOptionsMethod: 'getModels',
28
31
  },
29
- default: '',
30
- description: 'Select AI model',
31
- },
32
- {
33
- displayName: 'Messages',
34
- name: 'messages',
35
- type: 'fixedCollection',
36
- typeOptions: { multipleValues: true },
37
- default: {},
38
- placeholder: 'Add Message',
39
- options: [{
40
- name: 'messageValues',
41
- displayName: 'Message',
42
- values: [
43
- {
44
- displayName: 'Role',
45
- name: 'role',
46
- type: 'options',
47
- options: [
48
- { name: 'User', value: 'user' },
49
- { name: 'System', value: 'system' },
50
- { name: 'Assistant', value: 'assistant' },
51
- ],
52
- default: 'user',
53
- },
54
- {
55
- displayName: 'Text',
56
- name: 'text',
57
- type: 'string',
58
- typeOptions: { rows: 4 },
59
- default: '',
60
- description: 'Message content',
61
- },
62
- ],
63
- }],
64
- },
65
- {
66
- displayName: 'Options',
67
- name: 'options',
68
- type: 'collection',
69
- placeholder: 'Add Option',
70
- default: {},
32
+ default: 'gpt-4',
71
33
  options: [
72
34
  {
73
- displayName: 'Temperature',
74
- name: 'temperature',
75
- type: 'number',
76
- default: 0.7,
77
- typeOptions: {
78
- minValue: 0,
79
- maxValue: 2,
80
- numberStepSize: 0.1,
81
- },
82
- description: 'Controls randomness (0 = focused, 2 = creative)',
35
+ name: 'GPT-4',
36
+ value: 'gpt-4',
83
37
  },
84
38
  {
85
- displayName: 'Max Tokens',
86
- name: 'maxTokens',
87
- type: 'number',
88
- default: 2000,
89
- description: 'Maximum response length',
39
+ name: 'GPT-3.5 Turbo',
40
+ value: 'gpt-3.5-turbo',
90
41
  },
91
42
  ],
43
+ description: 'Choose the AI model',
44
+ required: true,
92
45
  },
93
46
  {
94
- displayName: 'Simplify Output',
95
- name: 'simplifyOutput',
96
- type: 'boolean',
97
- default: true,
98
- description: 'Whether to return only the message text',
47
+ displayName: 'Message',
48
+ name: 'message',
49
+ type: 'string',
50
+ default: '',
51
+ placeholder: 'Hello AI',
52
+ description: 'The message to send',
53
+ required: true,
99
54
  },
100
55
  ],
101
56
  };
102
57
  this.methods = {
103
58
  loadOptions: {
104
59
  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
- }
60
+ return [
61
+ {
62
+ name: 'GPT-4',
63
+ value: 'gpt-4',
64
+ },
65
+ {
66
+ name: 'GPT-3.5 Turbo',
67
+ value: 'gpt-3.5-turbo',
68
+ },
69
+ ];
128
70
  },
129
71
  },
130
72
  };
131
73
  }
132
74
  async execute() {
133
- var _a, _b, _c, _d;
134
75
  const items = this.getInputData();
135
76
  const returnData = [];
136
- const credentials = await this.getCredentials('rooyaiOpenRouter');
137
- const providerType = credentials.providerType;
138
77
  for (let i = 0; i < items.length; i++) {
139
- try {
140
- const model = this.getNodeParameter('model', i);
141
- const messagesInput = this.getNodeParameter('messages', i, {});
142
- const options = this.getNodeParameter('options', i, {});
143
- const simplifyOutput = this.getNodeParameter('simplifyOutput', i);
144
- const messages = [];
145
- if (messagesInput.messageValues && Array.isArray(messagesInput.messageValues)) {
146
- for (const msg of messagesInput.messageValues) {
147
- messages.push({ role: msg.role, content: msg.text });
148
- }
149
- }
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, {
164
- model,
165
- messages,
166
- temperature: options.temperature || 0.7,
167
- max_tokens: options.maxTokens || 2000,
168
- }, { headers });
169
- if (simplifyOutput) {
170
- returnData.push({
171
- json: {
172
- message: response.data.choices[0].message.content,
173
- model: response.data.model,
174
- },
175
- });
176
- }
177
- else {
178
- returnData.push({ json: response.data });
179
- }
180
- }
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
- }
194
- if (this.continueOnFail()) {
195
- returnData.push({
196
- json: {
197
- error: errorMsg,
198
- status: errorStatus,
199
- hint: hint || 'Unknown error',
200
- },
201
- });
202
- }
203
- else {
204
- throw new Error(`API Error (${errorStatus}): ${errorMsg}. ${hint}`);
205
- }
206
- }
78
+ const model = this.getNodeParameter('model', i);
79
+ const message = this.getNodeParameter('message', i);
80
+ // Logic placeholder
81
+ const responseData = {
82
+ message: `Received: ${message}`,
83
+ model: model,
84
+ status: 'success'
85
+ };
86
+ returnData.push({
87
+ json: responseData,
88
+ });
207
89
  }
208
90
  return [returnData];
209
91
  }
@@ -0,0 +1,10 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="60" height="60" viewBox="0 0 60 60">
2
+ <defs>
3
+ <linearGradient id="grad" x1="0%" y1="0%" x2="100%" y2="100%">
4
+ <stop offset="0%" style="stop-color:#6B7BD6;stop-opacity:1" />
5
+ <stop offset="100%" style="stop-color:#7B68EE;stop-opacity:1" />
6
+ </linearGradient>
7
+ </defs>
8
+ <circle cx="30" cy="30" r="26" fill="url(#grad)"/>
9
+ <text x="30" y="40" font-family="Arial, sans-serif" font-size="28" font-weight="bold" fill="#FFFFFF" text-anchor="middle">R</text>
10
+ </svg>
package/package.json CHANGED
@@ -1,29 +1,48 @@
1
1
  {
2
2
  "name": "n8n-nodes-rooyai",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Rooyai AI Agent for n8n",
5
5
  "keywords": [
6
6
  "n8n-community-node-package"
7
7
  ],
8
8
  "license": "MIT",
9
- "main": "index.js",
10
- "scripts": {
11
- "build": "tsc"
9
+ "author": {
10
+ "name": "Rooyai",
11
+ "email": "contact@rooyai.com"
12
12
  },
13
- "files": [
14
- "dist"
15
- ],
13
+ "community": {
14
+ "author": "Rooyai"
15
+ },
16
+ "main": "index.js",
16
17
  "n8n": {
17
- "credentials": [
18
- "dist/RooyaiOpenRouter.credentials.js"
19
- ],
18
+ "n8nNodesApiVersion": 1,
20
19
  "nodes": [
21
20
  "dist/RooyaiAgent.node.js"
22
21
  ]
23
22
  },
23
+ "scripts": {
24
+ "build": "tsc --outDir dist && copyfiles -f rooyai.svg dist",
25
+ "dev": "tsc --watch",
26
+ "format": "prettier --write '**/*.ts'",
27
+ "lint": "eslint src --ext .ts",
28
+ "lintfix": "eslint src --ext .ts --fix",
29
+ "prepublishOnly": "npm run build"
30
+ },
31
+ "files": [
32
+ "dist"
33
+ ],
24
34
  "devDependencies": {
25
- "n8n-workflow": "^1.0.0",
26
- "typescript": "^5.0.0"
35
+ "@types/express": "^4.17.6",
36
+ "@types/request-promise-native": "^1.0.17",
37
+ "@typescript-eslint/parser": "^5.45.0",
38
+ "copyfiles": "^2.4.1",
39
+ "eslint": "^8.29.0",
40
+ "eslint-plugin-n8n-nodes-base": "^1.11.0",
41
+ "gulp": "^4.0.2",
42
+ "n8n-core": "^0.141.0",
43
+ "n8n-workflow": "^0.141.0",
44
+ "prettier": "^2.8.0",
45
+ "typescript": "^4.9.3"
27
46
  },
28
47
  "dependencies": {
29
48
  "axios": "^1.6.0"