@alephantai/n8n-nodes-alephant-analytics-ai 0.1.3 → 0.1.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.
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AlephantAnalyticsAi = void 0;
|
|
4
4
|
const tools_1 = require("@langchain/core/tools");
|
|
5
5
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
6
|
-
const zod_1 = require("zod");
|
|
7
6
|
const usage_1 = require("../../shared/usage");
|
|
8
7
|
function toSafeToolName(nodeName) {
|
|
9
8
|
const normalized = (0, n8n_workflow_1.nodeNameToToolName)(nodeName)
|
|
@@ -11,30 +10,59 @@ function toSafeToolName(nodeName) {
|
|
|
11
10
|
.replace(/^[^A-Za-z_]+/, '');
|
|
12
11
|
return normalized || 'Alephant_Analytics_AI';
|
|
13
12
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
13
|
+
function readToolInput(input) {
|
|
14
|
+
return typeof input === 'object' && input !== null ? input : {};
|
|
15
|
+
}
|
|
16
|
+
function readString(value, fallback) {
|
|
17
|
+
return typeof value === 'string' && value.trim() !== '' ? value : fallback;
|
|
18
|
+
}
|
|
19
|
+
function readNumber(value, fallback) {
|
|
20
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : fallback;
|
|
21
|
+
}
|
|
22
|
+
const analyticsToolSchema = {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {
|
|
25
|
+
operation: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
enum: [
|
|
28
|
+
'scope',
|
|
29
|
+
'budgetStatus',
|
|
30
|
+
'usageSummary',
|
|
31
|
+
'dailyCosts',
|
|
32
|
+
'costByModel',
|
|
33
|
+
'recentRequests',
|
|
34
|
+
'requestLogDetail',
|
|
35
|
+
],
|
|
36
|
+
description: 'Alephant analytics operation to run.',
|
|
37
|
+
default: 'usageSummary',
|
|
38
|
+
},
|
|
39
|
+
period: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
enum: ['24h', '7d', '30d', '90d'],
|
|
42
|
+
description: 'Time period for budget, usage, daily cost, and cost-by-model operations.',
|
|
43
|
+
default: '7d',
|
|
44
|
+
},
|
|
45
|
+
limit: {
|
|
46
|
+
type: 'integer',
|
|
47
|
+
minimum: 1,
|
|
48
|
+
description: 'Maximum recent requests to return.',
|
|
49
|
+
},
|
|
50
|
+
offset: {
|
|
51
|
+
type: 'integer',
|
|
52
|
+
minimum: 0,
|
|
53
|
+
description: 'Recent requests offset.',
|
|
54
|
+
},
|
|
55
|
+
requestLogId: {
|
|
56
|
+
type: 'string',
|
|
57
|
+
description: 'Request log ID for requestLogDetail.',
|
|
58
|
+
},
|
|
59
|
+
workspaceId: {
|
|
60
|
+
type: 'string',
|
|
61
|
+
description: 'Workspace ID for request log detail lookups when credentials do not include one.',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
additionalProperties: false,
|
|
65
|
+
};
|
|
38
66
|
class AlephantAnalyticsAi {
|
|
39
67
|
constructor() {
|
|
40
68
|
this.description = {
|
|
@@ -150,13 +178,14 @@ class AlephantAnalyticsAi {
|
|
|
150
178
|
description: 'Query Alephant AI analytics for usage, cost, latency, model/provider performance, budget status, recent requests, and request log detail.',
|
|
151
179
|
schema: analyticsToolSchema,
|
|
152
180
|
func: async (input) => {
|
|
181
|
+
const toolInput = readToolInput(input);
|
|
153
182
|
const data = await (0, usage_1.runUsageRequest)(this, {
|
|
154
|
-
operation:
|
|
155
|
-
period:
|
|
156
|
-
limit:
|
|
157
|
-
offset:
|
|
158
|
-
requestLogId:
|
|
159
|
-
workspaceId:
|
|
183
|
+
operation: readString(toolInput.operation, 'usageSummary'),
|
|
184
|
+
period: readString(toolInput.period, '7d'),
|
|
185
|
+
limit: readNumber(toolInput.limit, 50),
|
|
186
|
+
offset: readNumber(toolInput.offset, 0),
|
|
187
|
+
requestLogId: readString(toolInput.requestLogId, ''),
|
|
188
|
+
workspaceId: readString(toolInput.workspaceId, ''),
|
|
160
189
|
}, itemIndex);
|
|
161
190
|
return JSON.stringify(data);
|
|
162
191
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alephantai/n8n-nodes-alephant-analytics-ai",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "n8n AI tool node for Alephant analytics",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://alephant.io",
|
|
@@ -51,8 +51,7 @@
|
|
|
51
51
|
"n8n-workflow": "*"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@langchain/core": "^1.1.46"
|
|
55
|
-
"zod": "^3.25.67"
|
|
54
|
+
"@langchain/core": "^1.1.46"
|
|
56
55
|
},
|
|
57
56
|
"devDependencies": {
|
|
58
57
|
"n8n-workflow": "*",
|