n8n-nodes-rooyai-chat 0.2.0 → 0.3.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.
- package/README.md +2 -2
- package/dist/credentials/RooyaiApi.credentials.d.ts +2 -1
- package/dist/credentials/RooyaiApi.credentials.js +15 -0
- package/dist/nodes/Rooyai/N8nLlmTracing.js +7 -7
- package/dist/nodes/Rooyai/Rooyai.node.js +8 -1
- package/dist/nodes/Rooyai/RooyaiLangChainWrapper.d.ts +2 -0
- package/dist/nodes/Rooyai/RooyaiLangChainWrapper.js +30 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Custom n8n node for Rooyai Chat API - A supply node that provides Rooyai languag
|
|
|
4
4
|
|
|
5
5
|
## Description
|
|
6
6
|
|
|
7
|
-
This n8n custom node provides a **Rooyai Chat Model** supply node that can be connected to the **Basic LLM Chain** node, **AI Agent**,
|
|
7
|
+
This n8n custom node provides a **Rooyai Chat Model** supply node that can be connected to the **Basic LLM Chain** node, **AI Agent**, and other AI processing nodes in n8n.
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
@@ -77,7 +77,7 @@ Then restart your n8n instance. The node will appear in the node palette under *
|
|
|
77
77
|
Connect the **Model** output from **Rooyai Chat Model** to:
|
|
78
78
|
- **Basic LLM Chain**
|
|
79
79
|
- **AI Agent**
|
|
80
|
-
|
|
80
|
+
|
|
81
81
|
- Any other n8n AI node that accepts a Language Model
|
|
82
82
|
|
|
83
83
|
## Available Models
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { IAuthenticateGeneric, ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
1
|
+
import { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
2
|
export declare class RooyaiApi implements ICredentialType {
|
|
3
3
|
name: string;
|
|
4
4
|
displayName: string;
|
|
5
5
|
documentationUrl: string;
|
|
6
6
|
properties: INodeProperties[];
|
|
7
7
|
authenticate: IAuthenticateGeneric;
|
|
8
|
+
test: ICredentialTestRequest;
|
|
8
9
|
}
|
|
@@ -35,6 +35,21 @@ class RooyaiApi {
|
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
37
|
};
|
|
38
|
+
this.test = {
|
|
39
|
+
request: {
|
|
40
|
+
baseURL: '={{$credentials.baseUrl}}',
|
|
41
|
+
url: '/chat',
|
|
42
|
+
method: 'POST',
|
|
43
|
+
headers: {
|
|
44
|
+
'Content-Type': 'application/json',
|
|
45
|
+
},
|
|
46
|
+
body: {
|
|
47
|
+
model: 'gemini-2.0-flash',
|
|
48
|
+
messages: [{ role: 'user', content: 'test' }],
|
|
49
|
+
max_tokens: 5,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
};
|
|
38
53
|
}
|
|
39
54
|
}
|
|
40
55
|
exports.RooyaiApi = RooyaiApi;
|
|
@@ -10,27 +10,27 @@ class N8nLlmTracing extends base_1.BaseCallbackHandler {
|
|
|
10
10
|
}
|
|
11
11
|
async handleLLMStart(llm, prompts, runId, parentRunId, extraParams, tags, metadata) {
|
|
12
12
|
if (this.supplyDataFunctions.logger) {
|
|
13
|
-
this.supplyDataFunctions.logger.
|
|
13
|
+
this.supplyDataFunctions.logger.info('🚀 Rooyai LLM started', {
|
|
14
14
|
runId,
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
promptCount: prompts.length,
|
|
16
|
+
model: extraParams?.invocation_params?.model || 'unknown',
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
async handleLLMEnd(output, runId, parentRunId, tags) {
|
|
21
21
|
if (this.supplyDataFunctions.logger) {
|
|
22
|
-
this.supplyDataFunctions.logger.
|
|
22
|
+
this.supplyDataFunctions.logger.info('✅ Rooyai LLM finished successfully', {
|
|
23
23
|
runId,
|
|
24
|
-
|
|
24
|
+
generationCount: output?.generations?.length || 0,
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
async handleLLMError(error, runId, parentRunId, tags) {
|
|
29
29
|
if (this.supplyDataFunctions.logger) {
|
|
30
|
-
this.supplyDataFunctions.logger.error('Rooyai LLM error', {
|
|
30
|
+
this.supplyDataFunctions.logger.error('❌ Rooyai LLM error', {
|
|
31
31
|
runId,
|
|
32
|
-
parentRunId,
|
|
33
32
|
error: error.message,
|
|
33
|
+
stack: error.stack,
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -147,10 +147,11 @@ class Rooyai {
|
|
|
147
147
|
const modelName = this.getNodeParameter('model', itemIndex);
|
|
148
148
|
const options = this.getNodeParameter('options', itemIndex, {});
|
|
149
149
|
if (this.logger) {
|
|
150
|
-
this.logger.info('Rooyai Chat Model
|
|
150
|
+
this.logger.info('🎯 Initializing Rooyai Chat Model', {
|
|
151
151
|
model: modelName,
|
|
152
152
|
temperature: options.temperature ?? 0.7,
|
|
153
153
|
maxTokens: options.maxTokensToSample,
|
|
154
|
+
baseUrl,
|
|
154
155
|
});
|
|
155
156
|
}
|
|
156
157
|
const model = new RooyaiLangChainWrapper_1.RooyaiLangChainWrapper({
|
|
@@ -161,7 +162,13 @@ class Rooyai {
|
|
|
161
162
|
temperature: options.temperature ?? 0.7,
|
|
162
163
|
supplyDataFunctions: this,
|
|
163
164
|
callbacks: [new N8nLlmTracing_1.N8nLlmTracing(this)],
|
|
165
|
+
verbose: true,
|
|
164
166
|
});
|
|
167
|
+
if (this.logger) {
|
|
168
|
+
this.logger.info('✅ Rooyai Chat Model ready', {
|
|
169
|
+
model: modelName,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
165
172
|
return {
|
|
166
173
|
response: model,
|
|
167
174
|
};
|
|
@@ -11,6 +11,7 @@ interface RooyaiLangChainWrapperParams {
|
|
|
11
11
|
maxTokens?: number;
|
|
12
12
|
supplyDataFunctions?: ISupplyDataFunctions;
|
|
13
13
|
callbacks?: any[];
|
|
14
|
+
verbose?: boolean;
|
|
14
15
|
}
|
|
15
16
|
export declare class RooyaiLangChainWrapper extends BaseChatModel {
|
|
16
17
|
lc_namespace: string[];
|
|
@@ -20,6 +21,7 @@ export declare class RooyaiLangChainWrapper extends BaseChatModel {
|
|
|
20
21
|
private temperature;
|
|
21
22
|
private maxTokens?;
|
|
22
23
|
private supplyDataFunctions?;
|
|
24
|
+
verbose: boolean;
|
|
23
25
|
constructor(params: RooyaiLangChainWrapperParams);
|
|
24
26
|
_llmType(): string;
|
|
25
27
|
_modelType(): string;
|
|
@@ -13,6 +13,7 @@ class RooyaiLangChainWrapper extends chat_models_1.BaseChatModel {
|
|
|
13
13
|
super({
|
|
14
14
|
...params,
|
|
15
15
|
callbacks,
|
|
16
|
+
verbose: params.verbose ?? false,
|
|
16
17
|
});
|
|
17
18
|
this.lc_namespace = ['n8n', 'rooyai', 'chat'];
|
|
18
19
|
this.apiKey = params.apiKey;
|
|
@@ -21,6 +22,7 @@ class RooyaiLangChainWrapper extends chat_models_1.BaseChatModel {
|
|
|
21
22
|
this.temperature = params.temperature ?? 0.7;
|
|
22
23
|
this.maxTokens = params.maxTokens;
|
|
23
24
|
this.supplyDataFunctions = params.supplyDataFunctions;
|
|
25
|
+
this.verbose = params.verbose ?? false;
|
|
24
26
|
}
|
|
25
27
|
_llmType() {
|
|
26
28
|
return 'rooyai';
|
|
@@ -34,6 +36,15 @@ class RooyaiLangChainWrapper extends chat_models_1.BaseChatModel {
|
|
|
34
36
|
'Content-Type': 'application/json',
|
|
35
37
|
};
|
|
36
38
|
const url = `${this.baseUrl}/chat`;
|
|
39
|
+
if (this.verbose && this.supplyDataFunctions?.logger) {
|
|
40
|
+
this.supplyDataFunctions.logger.debug('📡 Calling Rooyai API', {
|
|
41
|
+
url,
|
|
42
|
+
model: body.model,
|
|
43
|
+
messageCount: body.messages.length,
|
|
44
|
+
temperature: body.temperature,
|
|
45
|
+
maxTokens: body.max_tokens,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
37
48
|
try {
|
|
38
49
|
const response = await axios_1.default.post(url, body, {
|
|
39
50
|
headers,
|
|
@@ -45,9 +56,22 @@ class RooyaiLangChainWrapper extends chat_models_1.BaseChatModel {
|
|
|
45
56
|
: JSON.stringify(response.data);
|
|
46
57
|
throw new Error(`Rooyai API error (${response.status}): ${errorText}`);
|
|
47
58
|
}
|
|
59
|
+
if (this.verbose && this.supplyDataFunctions?.logger) {
|
|
60
|
+
this.supplyDataFunctions.logger.debug('✅ Rooyai API response received', {
|
|
61
|
+
status: response.status,
|
|
62
|
+
hasChoices: !!response.data.choices,
|
|
63
|
+
hasReply: !!response.data.reply,
|
|
64
|
+
cost: response.data.usage?.cost_usd,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
48
67
|
return response.data;
|
|
49
68
|
}
|
|
50
69
|
catch (error) {
|
|
70
|
+
if (this.verbose && this.supplyDataFunctions?.logger) {
|
|
71
|
+
this.supplyDataFunctions.logger.error('❌ Rooyai API call failed', {
|
|
72
|
+
error: error instanceof Error ? error.message : String(error),
|
|
73
|
+
});
|
|
74
|
+
}
|
|
51
75
|
if (error instanceof Error) {
|
|
52
76
|
throw new Error(`Failed to call Rooyai API: ${error.message}`);
|
|
53
77
|
}
|
|
@@ -104,6 +128,12 @@ class RooyaiLangChainWrapper extends chat_models_1.BaseChatModel {
|
|
|
104
128
|
};
|
|
105
129
|
if (response.usage?.cost_usd !== undefined) {
|
|
106
130
|
llmOutput.costUsd = response.usage.cost_usd;
|
|
131
|
+
if (this.verbose && this.supplyDataFunctions?.logger) {
|
|
132
|
+
this.supplyDataFunctions.logger.info('💰 API Cost', {
|
|
133
|
+
cost: response.usage.cost_usd,
|
|
134
|
+
totalTokens: response.usage.total_tokens,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
107
137
|
}
|
|
108
138
|
const generation = {
|
|
109
139
|
message: aiMessage,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-rooyai-chat",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "n8n supply node for Rooyai Chat API - Provides Rooyai language models for use with Basic LLM Chain, AI Agent, and other AI nodes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package",
|