n8n-nodes-rooyai-model 1.0.6 → 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.
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RooyaiApi = void 0;
|
|
4
|
+
class RooyaiApi {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = 'rooyaiApi';
|
|
7
|
+
this.displayName = 'Rooyai API';
|
|
8
|
+
this.documentationUrl = 'https://rooyai.com/docs';
|
|
9
|
+
this.properties = [
|
|
10
|
+
// القائمة اللي بتخلي العميل يختار هو عايز يربط إيه
|
|
11
|
+
{
|
|
12
|
+
displayName: 'Provider',
|
|
13
|
+
name: 'providerType',
|
|
14
|
+
type: 'options',
|
|
15
|
+
options: [
|
|
16
|
+
{
|
|
17
|
+
name: 'OpenAI',
|
|
18
|
+
value: 'openai',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'OpenRouter',
|
|
22
|
+
value: 'openrouter',
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
default: 'openrouter',
|
|
26
|
+
},
|
|
27
|
+
// API Key لـ OpenRouter (يظهر فقط لما يختار OpenRouter)
|
|
28
|
+
{
|
|
29
|
+
displayName: 'OpenRouter API Key',
|
|
30
|
+
name: 'apiKey',
|
|
31
|
+
type: 'string',
|
|
32
|
+
typeOptions: {
|
|
33
|
+
password: true,
|
|
34
|
+
},
|
|
35
|
+
displayOptions: {
|
|
36
|
+
show: {
|
|
37
|
+
providerType: ['openrouter'],
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
default: '',
|
|
41
|
+
},
|
|
42
|
+
// API Key لـ OpenAI (يظهر فقط لما يختار OpenAI)
|
|
43
|
+
{
|
|
44
|
+
displayName: 'OpenAI API Key',
|
|
45
|
+
name: 'apiKey', // نفس الاسم عشان نسهل استخدامه في الكود
|
|
46
|
+
type: 'string',
|
|
47
|
+
typeOptions: {
|
|
48
|
+
password: true,
|
|
49
|
+
},
|
|
50
|
+
displayOptions: {
|
|
51
|
+
show: {
|
|
52
|
+
providerType: ['openai'],
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
default: '',
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.RooyaiApi = RooyaiApi;
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RooyaiChatModel = void 0;
|
|
4
4
|
const openai_1 = require("@langchain/openai");
|
|
5
|
-
|
|
6
|
-
const ROOYAI_TOKEN = '12345678';
|
|
5
|
+
const ROOYAI_TOKEN = '12345678'; // الرمز الثابت للعملاء
|
|
7
6
|
class RooyaiChatModel {
|
|
8
7
|
constructor() {
|
|
9
8
|
this.description = {
|
|
@@ -24,29 +23,15 @@ class RooyaiChatModel {
|
|
|
24
23
|
},
|
|
25
24
|
inputs: [],
|
|
26
25
|
outputs: ['ai_languageModel'],
|
|
27
|
-
//
|
|
26
|
+
// استخدام Credential واحد فقط
|
|
28
27
|
credentials: [
|
|
29
28
|
{
|
|
30
|
-
name: '
|
|
29
|
+
name: 'rooyaiApi',
|
|
31
30
|
required: true,
|
|
32
|
-
displayOptions: {
|
|
33
|
-
show: {
|
|
34
|
-
provider: ['openai'],
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: 'rooyaiOpenRouter',
|
|
40
|
-
required: true,
|
|
41
|
-
displayOptions: {
|
|
42
|
-
show: {
|
|
43
|
-
provider: ['openrouter'],
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
31
|
},
|
|
47
32
|
],
|
|
48
33
|
properties: [
|
|
49
|
-
// 1. اختيار الـ Provider (
|
|
34
|
+
// 1. اختيار الـ Provider (في النود نفسها عشان فلترة الموديلات)
|
|
50
35
|
{
|
|
51
36
|
displayName: 'Provider',
|
|
52
37
|
name: 'provider',
|
|
@@ -122,25 +107,23 @@ class RooyaiChatModel {
|
|
|
122
107
|
}
|
|
123
108
|
async supplyData(itemIndex) {
|
|
124
109
|
var _a;
|
|
125
|
-
|
|
110
|
+
// قراءة الـ Credentials
|
|
111
|
+
const credentials = await this.getCredentials('rooyaiApi');
|
|
112
|
+
const providerType = credentials.providerType; // نوع الـ Provider اللي العميل اختاره في الـ Credential
|
|
113
|
+
const apiKey = credentials.apiKey;
|
|
114
|
+
// قراءة إعدادات النود
|
|
115
|
+
const selectedProvider = this.getNodeParameter('provider', itemIndex);
|
|
126
116
|
const modelName = this.getNodeParameter('model', itemIndex);
|
|
127
117
|
const options = this.getNodeParameter('options', itemIndex, {});
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const creds = await this.getCredentials('rooyaiOpenRouter');
|
|
131
|
-
apiKey = creds.apiKey;
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
const creds = await this.getCredentials('rooyaiOpenAI');
|
|
135
|
-
apiKey = creds.apiKey;
|
|
136
|
-
}
|
|
118
|
+
// تحذير بسيط لو العميل اختار provider في النود غير اللي في الـ credential (اختياري)
|
|
119
|
+
// بس الكود هيشتغل عادي لأنه بيبعت الـ providerType للسيرفر
|
|
137
120
|
const model = new openai_1.ChatOpenAI({
|
|
138
121
|
openAIApiKey: apiKey,
|
|
139
122
|
configuration: {
|
|
140
123
|
baseURL: 'http://35.226.94.120:3000/v1',
|
|
141
124
|
defaultHeaders: {
|
|
142
|
-
'x-rooyai-token': ROOYAI_TOKEN,
|
|
143
|
-
'x-rooyai-provider':
|
|
125
|
+
'x-rooyai-token': ROOYAI_TOKEN,
|
|
126
|
+
'x-rooyai-provider': providerType, // بنبعت النوع الفعلي من الـ Credential
|
|
144
127
|
},
|
|
145
128
|
},
|
|
146
129
|
modelName: modelName,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-rooyai-model",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "Rooyai AI Model Integration for n8n",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package"
|
|
@@ -10,9 +10,7 @@
|
|
|
10
10
|
"main": "index.js",
|
|
11
11
|
"n8n": {
|
|
12
12
|
"credentials": [
|
|
13
|
-
"dist/
|
|
14
|
-
"dist/RooyaiOpenAI.credentials.js",
|
|
15
|
-
"dist/RooyaiOpenRouter.credentials.js"
|
|
13
|
+
"dist/RooyaiApi.credentials.js"
|
|
16
14
|
],
|
|
17
15
|
"nodes": [
|
|
18
16
|
"dist/RooyaiChatModel.node.js"
|
|
@@ -28,10 +26,10 @@
|
|
|
28
26
|
],
|
|
29
27
|
"devDependencies": {
|
|
30
28
|
"n8n-workflow": "^1.120.4",
|
|
31
|
-
"typescript": "^5.
|
|
29
|
+
"typescript": "^5.0.0"
|
|
32
30
|
},
|
|
33
31
|
"dependencies": {
|
|
34
|
-
"@langchain/core": "^
|
|
35
|
-
"@langchain/openai": "^
|
|
32
|
+
"@langchain/core": "^0.1.0",
|
|
33
|
+
"@langchain/openai": "^0.0.14"
|
|
36
34
|
}
|
|
37
35
|
}
|