n8n-nodes-rooyai-model 1.0.0
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,16 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "n8n-nodes-rooyai-model",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"n8n": {
|
|
5
|
+
"credentials": [
|
|
6
|
+
"dist/RooyaiAccount.credentials.js",
|
|
7
|
+
"dist/RooyaiOpenAI.credentials.js",
|
|
8
|
+
"dist/RooyaiOpenRouter.credentials.js"
|
|
9
|
+
],
|
|
10
|
+
"nodes": ["dist/RooyaiChatModel.node.js"]
|
|
11
|
+
}
|
|
12
|
+
}
|