n8n-nodes-rooyai-model 1.0.2 → 1.0.4
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/RooyaiAccount.credentials.d.ts +6 -0
- package/dist/RooyaiAccount.credentials.js +20 -0
- package/dist/RooyaiChatModel.node.d.ts +5 -0
- package/dist/RooyaiChatModel.node.js +89 -0
- package/dist/RooyaiOpenAI.credentials.d.ts +6 -0
- package/dist/RooyaiOpenAI.credentials.js +20 -0
- package/dist/RooyaiOpenRouter.credentials.d.ts +6 -0
- package/dist/RooyaiOpenRouter.credentials.js +20 -0
- package/package.json +16 -4
- package/RooyaiAccount.credentials.ts +0 -16
- package/RooyaiChatModel.node.ts +0 -85
- package/RooyaiOpenAI.credentials.ts +0 -16
- package/RooyaiOpenRouter.credentials.ts +0 -16
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RooyaiAccount = void 0;
|
|
4
|
+
class RooyaiAccount {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = 'rooyaiAccount';
|
|
7
|
+
this.displayName = 'Rooyai Account';
|
|
8
|
+
this.properties = [
|
|
9
|
+
{
|
|
10
|
+
displayName: 'Account Token',
|
|
11
|
+
name: 'token',
|
|
12
|
+
type: 'string',
|
|
13
|
+
typeOptions: { password: true },
|
|
14
|
+
default: '',
|
|
15
|
+
required: true,
|
|
16
|
+
},
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.RooyaiAccount = RooyaiAccount;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { INodeType, INodeTypeDescription, ISupplyDataFunctions, SupplyData } from 'n8n-workflow';
|
|
2
|
+
export declare class RooyaiChatModel implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RooyaiChatModel = void 0;
|
|
4
|
+
const openai_1 = require("@langchain/openai");
|
|
5
|
+
class RooyaiChatModel {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.description = {
|
|
8
|
+
displayName: 'Rooyai Chat Model',
|
|
9
|
+
name: 'rooyaiChatModel',
|
|
10
|
+
icon: 'file:rooyai.svg',
|
|
11
|
+
group: ['transform'],
|
|
12
|
+
version: 1,
|
|
13
|
+
description: 'Rooyai AI Chat Model compatible with Agents',
|
|
14
|
+
defaults: {
|
|
15
|
+
name: 'Rooyai Chat Model',
|
|
16
|
+
},
|
|
17
|
+
codex: {
|
|
18
|
+
categories: ['AI'],
|
|
19
|
+
subcategories: {
|
|
20
|
+
AI: ['Language Models', 'Chat Models'],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
inputs: [],
|
|
24
|
+
// 🔥 التعديل هنا: الاسم ده هو الصح 100% 🔥
|
|
25
|
+
outputs: ['ai_languageModel'],
|
|
26
|
+
credentials: [
|
|
27
|
+
{ name: 'rooyaiAccount', required: true },
|
|
28
|
+
{ name: 'rooyaiOpenAI', required: false },
|
|
29
|
+
{ name: 'rooyaiOpenRouter', required: false },
|
|
30
|
+
],
|
|
31
|
+
properties: [
|
|
32
|
+
{
|
|
33
|
+
displayName: 'Provider',
|
|
34
|
+
name: 'provider',
|
|
35
|
+
type: 'options',
|
|
36
|
+
options: [
|
|
37
|
+
{ name: 'OpenAI', value: 'openai' },
|
|
38
|
+
{ name: 'OpenRouter', value: 'openrouter' },
|
|
39
|
+
],
|
|
40
|
+
default: 'openrouter',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
displayName: 'Model',
|
|
44
|
+
name: 'model',
|
|
45
|
+
type: 'string',
|
|
46
|
+
default: 'gpt-4o',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
displayName: 'Temperature',
|
|
50
|
+
name: 'temperature',
|
|
51
|
+
type: 'number',
|
|
52
|
+
default: 0.7,
|
|
53
|
+
typeOptions: { minValue: 0, maxValue: 2, numberStepSize: 0.1 },
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
async supplyData(itemIndex) {
|
|
59
|
+
const credentials = await this.getCredentials('rooyaiAccount');
|
|
60
|
+
const provider = this.getNodeParameter('provider', itemIndex);
|
|
61
|
+
const modelName = this.getNodeParameter('model', itemIndex);
|
|
62
|
+
const temperature = this.getNodeParameter('temperature', itemIndex);
|
|
63
|
+
let apiKey = '';
|
|
64
|
+
if (provider === 'openrouter') {
|
|
65
|
+
const creds = await this.getCredentials('rooyaiOpenRouter');
|
|
66
|
+
apiKey = creds.apiKey;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
const creds = await this.getCredentials('rooyaiOpenAI');
|
|
70
|
+
apiKey = creds.apiKey;
|
|
71
|
+
}
|
|
72
|
+
const model = new openai_1.ChatOpenAI({
|
|
73
|
+
openAIApiKey: apiKey,
|
|
74
|
+
configuration: {
|
|
75
|
+
baseURL: 'http://35.226.94.120:3000/v1',
|
|
76
|
+
defaultHeaders: {
|
|
77
|
+
'x-rooyai-token': credentials.token,
|
|
78
|
+
'x-rooyai-provider': provider,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
modelName: modelName,
|
|
82
|
+
temperature: temperature,
|
|
83
|
+
});
|
|
84
|
+
return {
|
|
85
|
+
response: model,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.RooyaiChatModel = RooyaiChatModel;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RooyaiOpenAI = void 0;
|
|
4
|
+
class RooyaiOpenAI {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = 'rooyaiOpenAI';
|
|
7
|
+
this.displayName = 'Rooyai OpenAI';
|
|
8
|
+
this.properties = [
|
|
9
|
+
{
|
|
10
|
+
displayName: 'API Key',
|
|
11
|
+
name: 'apiKey',
|
|
12
|
+
type: 'string',
|
|
13
|
+
typeOptions: { password: true },
|
|
14
|
+
default: '',
|
|
15
|
+
required: true,
|
|
16
|
+
},
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.RooyaiOpenAI = RooyaiOpenAI;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RooyaiOpenRouter = void 0;
|
|
4
|
+
class RooyaiOpenRouter {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = 'rooyaiOpenRouter';
|
|
7
|
+
this.displayName = 'Rooyai OpenRouter';
|
|
8
|
+
this.properties = [
|
|
9
|
+
{
|
|
10
|
+
displayName: 'API Key',
|
|
11
|
+
name: 'apiKey',
|
|
12
|
+
type: 'string',
|
|
13
|
+
typeOptions: { password: true },
|
|
14
|
+
default: '',
|
|
15
|
+
required: true,
|
|
16
|
+
},
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.RooyaiOpenRouter = RooyaiOpenRouter;
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-rooyai-model",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Rooyai AI Model Integration for n8n",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package"
|
|
7
7
|
],
|
|
8
|
-
"author": "Rooyai",
|
|
9
8
|
"license": "MIT",
|
|
9
|
+
"author": "Rooyai",
|
|
10
|
+
"main": "index.js",
|
|
10
11
|
"n8n": {
|
|
11
12
|
"credentials": [
|
|
12
13
|
"dist/RooyaiAccount.credentials.js",
|
|
@@ -17,8 +18,19 @@
|
|
|
17
18
|
"dist/RooyaiChatModel.node.js"
|
|
18
19
|
]
|
|
19
20
|
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc",
|
|
23
|
+
"prepublishOnly": "npm run build"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
20
28
|
"devDependencies": {
|
|
21
|
-
"n8n-workflow": "
|
|
22
|
-
"typescript": "
|
|
29
|
+
"n8n-workflow": "^1.120.4",
|
|
30
|
+
"typescript": "^5.9.3"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@langchain/core": "^1.1.12",
|
|
34
|
+
"@langchain/openai": "^1.2.1"
|
|
23
35
|
}
|
|
24
36
|
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
|
-
|
|
3
|
-
export class RooyaiAccount implements ICredentialType {
|
|
4
|
-
name = 'rooyaiAccount';
|
|
5
|
-
displayName = 'Rooyai Account';
|
|
6
|
-
properties: INodeProperties[] = [
|
|
7
|
-
{
|
|
8
|
-
displayName: 'Account Token',
|
|
9
|
-
name: 'token',
|
|
10
|
-
type: 'string',
|
|
11
|
-
typeOptions: { password: true },
|
|
12
|
-
default: '',
|
|
13
|
-
required: true,
|
|
14
|
-
},
|
|
15
|
-
];
|
|
16
|
-
}
|
package/RooyaiChatModel.node.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IExecuteFunctions,
|
|
3
|
-
INodeExecutionData,
|
|
4
|
-
INodeType,
|
|
5
|
-
INodeTypeDescription,
|
|
6
|
-
} from 'n8n-workflow';
|
|
7
|
-
|
|
8
|
-
export class RooyaiChatModel implements INodeType {
|
|
9
|
-
description: INodeTypeDescription = {
|
|
10
|
-
displayName: 'Rooyai Chat Model',
|
|
11
|
-
name: 'rooyaiChatModel',
|
|
12
|
-
icon: 'file:rooyai.svg',
|
|
13
|
-
group: ['transform'],
|
|
14
|
-
version: 1,
|
|
15
|
-
description: 'Rooyai AI Chat Model',
|
|
16
|
-
defaults: { name: 'Rooyai Chat Model' },
|
|
17
|
-
inputs: ['main'],
|
|
18
|
-
outputs: ['main'],
|
|
19
|
-
credentials: [
|
|
20
|
-
{ name: 'rooyaiAccount', required: true },
|
|
21
|
-
{ name: 'rooyaiOpenAI', required: false },
|
|
22
|
-
{ name: 'rooyaiOpenRouter', required: false },
|
|
23
|
-
],
|
|
24
|
-
properties: [
|
|
25
|
-
{
|
|
26
|
-
displayName: 'Provider',
|
|
27
|
-
name: 'provider',
|
|
28
|
-
type: 'options',
|
|
29
|
-
options: [
|
|
30
|
-
{ name: 'OpenAI', value: 'openai' },
|
|
31
|
-
{ name: 'OpenRouter', value: 'openrouter' },
|
|
32
|
-
],
|
|
33
|
-
default: 'openrouter',
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
displayName: 'Model',
|
|
37
|
-
name: 'model',
|
|
38
|
-
type: 'string',
|
|
39
|
-
default: 'gpt-4o',
|
|
40
|
-
displayOptions: { show: { provider: ['openai'] } },
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
displayName: 'Model',
|
|
44
|
-
name: 'model',
|
|
45
|
-
type: 'string',
|
|
46
|
-
default: 'openai/gpt-4o',
|
|
47
|
-
displayOptions: { show: { provider: ['openrouter'] } },
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
displayName: 'Messages',
|
|
51
|
-
name: 'messages',
|
|
52
|
-
type: 'string',
|
|
53
|
-
default: '',
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
|
59
|
-
const items = this.getInputData();
|
|
60
|
-
const credentials = await this.getCredentials('rooyaiAccount');
|
|
61
|
-
const provider = this.getNodeParameter('provider', 0) as string;
|
|
62
|
-
|
|
63
|
-
let providerCreds;
|
|
64
|
-
if (provider === 'openai') {
|
|
65
|
-
providerCreds = await this.getCredentials('rooyaiOpenAI');
|
|
66
|
-
} else {
|
|
67
|
-
providerCreds = await this.getCredentials('rooyaiOpenRouter');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const response = await this.helpers.request({
|
|
71
|
-
method: 'POST',
|
|
72
|
-
url: 'http://35.226.94.120:3000/v1/chat/completions',
|
|
73
|
-
body: {
|
|
74
|
-
token: credentials.token,
|
|
75
|
-
provider,
|
|
76
|
-
apiKey: providerCreds.apiKey,
|
|
77
|
-
model: this.getNodeParameter('model', 0),
|
|
78
|
-
messages: [{ role: 'user', content: this.getNodeParameter('messages', 0) }],
|
|
79
|
-
},
|
|
80
|
-
json: true,
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
return [[{ json: response }]];
|
|
84
|
-
}
|
|
85
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
|
-
|
|
3
|
-
export class RooyaiOpenAI implements ICredentialType {
|
|
4
|
-
name = 'rooyaiOpenAI';
|
|
5
|
-
displayName = 'Rooyai OpenAI';
|
|
6
|
-
properties: INodeProperties[] = [
|
|
7
|
-
{
|
|
8
|
-
displayName: 'API Key',
|
|
9
|
-
name: 'apiKey',
|
|
10
|
-
type: 'string',
|
|
11
|
-
typeOptions: { password: true },
|
|
12
|
-
default: '',
|
|
13
|
-
required: true,
|
|
14
|
-
},
|
|
15
|
-
];
|
|
16
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
|
-
|
|
3
|
-
export class RooyaiOpenRouter implements ICredentialType {
|
|
4
|
-
name = 'rooyaiOpenRouter';
|
|
5
|
-
displayName = 'Rooyai OpenRouter';
|
|
6
|
-
properties: INodeProperties[] = [
|
|
7
|
-
{
|
|
8
|
-
displayName: 'API Key',
|
|
9
|
-
name: 'apiKey',
|
|
10
|
-
type: 'string',
|
|
11
|
-
typeOptions: { password: true },
|
|
12
|
-
default: '',
|
|
13
|
-
required: true,
|
|
14
|
-
},
|
|
15
|
-
];
|
|
16
|
-
}
|