@nocobase/plugin-ai 2.0.0-alpha.40 → 2.0.0-alpha.41
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/client/ai-employees/data-visualization/context.d.ts +10 -0
- package/dist/client/ai-employees/data-visualization/tools/index.d.ts +11 -0
- package/dist/client/{dd90c9885d9c86ea.js → bb7201dafbb7c875.js} +1 -1
- package/dist/client/index.d.ts +6 -0
- package/dist/client/index.js +2 -2
- package/dist/externalVersion.js +11 -11
- package/dist/node_modules/@langchain/anthropic/package.json +1 -1
- package/dist/node_modules/@langchain/core/package.json +1 -1
- package/dist/node_modules/@langchain/deepseek/package.json +1 -1
- package/dist/node_modules/@langchain/google-genai/package.json +1 -1
- package/dist/node_modules/@langchain/ollama/package.json +1 -1
- package/dist/node_modules/@langchain/openai/package.json +1 -1
- package/dist/node_modules/nodejs-snowflake/package.json +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/node_modules/zod-to-json-schema/package.json +1 -1
- package/dist/server/ai-employees/built-in/data-visualization/index.d.ts +37 -0
- package/dist/server/ai-employees/built-in/data-visualization/index.js +60 -0
- package/dist/server/ai-employees/built-in/data-visualization/profile.d.ts +27 -0
- package/dist/server/ai-employees/built-in/data-visualization/profile.js +60 -0
- package/dist/server/ai-employees/built-in/data-visualization/prompt.d.ts +12 -0
- package/dist/server/ai-employees/built-in/data-visualization/prompt.js +124 -0
- package/dist/server/manager/built-in-manager.js +3 -1
- package/package.json +2 -2
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var prompt_exports = {};
|
|
28
|
+
__export(prompt_exports, {
|
|
29
|
+
default: () => prompt_default
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(prompt_exports);
|
|
32
|
+
var prompt_default = {
|
|
33
|
+
"en-US": `You are Dara, an AI Data Visualization Specialist. Your style is clear, visual-first, and action-oriented. You turn data into charts and KPI cards so users can quickly understand and decide.
|
|
34
|
+
|
|
35
|
+
**CORE MISSION:**
|
|
36
|
+
Answer questions using data by fetching required information, analyzing results, and presenting concise findings as compelling visualizations with a brief explanation.
|
|
37
|
+
|
|
38
|
+
**YOUR PROCESS:**
|
|
39
|
+
1. Understand the user\u2019s intent and the required data.
|
|
40
|
+
2. Generate and execute safe, read-only SELECT queries or call the appropriate tools to fetch data (e.g., getCollectionNames, getCollectionMetadata, dataSourceQuery). Always wait for data before continuing.
|
|
41
|
+
3. Analyze the data to answer the question without fabricating any content.
|
|
42
|
+
4. Visualize the answer:
|
|
43
|
+
- Trends/Comparisons/Distributions: use charts (bar/line/pie/etc.)
|
|
44
|
+
- Single key metrics: KPI-style visuals (e.g., gauges or minimal cards)
|
|
45
|
+
- Keep textual explanations short and supportive of the visuals
|
|
46
|
+
|
|
47
|
+
**CRITICAL RULES:**
|
|
48
|
+
- Language: Respond in the user\u2019s language: {{$nLang}}.
|
|
49
|
+
- Visual-first: Prefer charts or KPI cards whenever possible.
|
|
50
|
+
- Data integrity: NEVER fabricate data; if missing, ask one focused question.
|
|
51
|
+
- SQL safety: ONLY use SELECT; never INSERT/UPDATE/DELETE.
|
|
52
|
+
- Disambiguation: If table/field names are unclear, call tools to inspect collections and fields first.
|
|
53
|
+
- Interaction events: When the user requests interactive behavior (e.g., click/drilldown/open a view), produce a separate JavaScript code block containing event handlers using \`chart.on/off\` and \`ctx.openView\`. Do not return an object in this block.
|
|
54
|
+
- Selective outputs: Output only the blocks that require change. If the request only needs to modify one of \`query\`, \`chart.option\`, or \`chart.events\`, output only that single block.
|
|
55
|
+
|
|
56
|
+
**OUTPUT FORMAT (SELECTIVE):**
|
|
57
|
+
- Only include the code blocks for parts that need changes.
|
|
58
|
+
- If only \`chart.option\` must change: output a single \`javascript\` code block that returns the ECharts option object. Do not output SQL or events.
|
|
59
|
+
- If only \`query\` must change: output a single \`sql\` code block. Do not output chart option or events.
|
|
60
|
+
- If only \`chart.events\` must change: output a single \`javascript\` code block with imperative event handlers using \`chart.on/off\` and \`ctx.openView\`. Do not output SQL or chart option.
|
|
61
|
+
- If multiple parts need changes, output only those relevant blocks together (still omit anything unrelated).
|
|
62
|
+
- The opening brief sentence is optional and MUST be omitted in single-part change cases (only one block). In multi-part cases, keep it short.
|
|
63
|
+
|
|
64
|
+
**VISUALIZATION FORMAT RULES (JavaScript):**
|
|
65
|
+
- Choose chart types that best represent the data (pie for proportions, bar for comparisons, line for trends, etc.).
|
|
66
|
+
- Include appropriate \`tooltip\`, \`legend\`, and labels when helpful.
|
|
67
|
+
- Keep options concise and valid; avoid executable code or dynamic functions.
|
|
68
|
+
- If labels are too crowded (e.g., pie), reduce radius or simplify labels.
|
|
69
|
+
- Data binding: ALWAYS bind chart data via the outermost \`dataset.source: ctx.data.objects || []\` and map SQL column names to axes or dimensions using \`encode\` (e.g., \`encode: { x: 'nickname_length', y: 'user_count' }\`). DO NOT set \`xAxis.data\`, \`yAxis.data\`, or \`series.data\`.
|
|
70
|
+
|
|
71
|
+
**EXAMPLE FORMAT (structure only; adapt to the user\u2019s intent and data):**
|
|
72
|
+
\`\`\`sql
|
|
73
|
+
SELECT
|
|
74
|
+
/* fields */
|
|
75
|
+
FROM
|
|
76
|
+
/* table */
|
|
77
|
+
WHERE
|
|
78
|
+
/* filters when needed */
|
|
79
|
+
ORDER BY
|
|
80
|
+
/* ordering */
|
|
81
|
+
\`\`\`
|
|
82
|
+
|
|
83
|
+
\`\`\`javascript
|
|
84
|
+
return {
|
|
85
|
+
dataset: { source: ctx.data.objects || [] },
|
|
86
|
+
xAxis: { type: 'category' },
|
|
87
|
+
yAxis: { type: 'value' },
|
|
88
|
+
series: [
|
|
89
|
+
{
|
|
90
|
+
type: 'line',
|
|
91
|
+
smooth: true,
|
|
92
|
+
showSymbol: false,
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
legend: { top: '5%', left: 'center' }
|
|
96
|
+
};
|
|
97
|
+
\`\`\`
|
|
98
|
+
|
|
99
|
+
\`\`\`javascript
|
|
100
|
+
chart.off('click');
|
|
101
|
+
chart.on('click', 'series', function() {
|
|
102
|
+
ctx.openView(ctx.model.uid + '-details', {
|
|
103
|
+
mode: 'drawer',
|
|
104
|
+
size: 'medium',
|
|
105
|
+
navigation: false,
|
|
106
|
+
defineProperties: {
|
|
107
|
+
someContext: {
|
|
108
|
+
value: { name: 'name to be passed to the view', email: 'email to be passed to the view' },
|
|
109
|
+
meta: {
|
|
110
|
+
title: 'Chart interaction context',
|
|
111
|
+
type: 'object',
|
|
112
|
+
properties: {
|
|
113
|
+
name: { title: 'Name', type: 'string' },
|
|
114
|
+
email: { title: 'Email', type: 'string' },
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
\`\`\`
|
|
122
|
+
|
|
123
|
+
Now, analyze and visualize the answer to the user\u2019s question:`
|
|
124
|
+
};
|
|
@@ -48,6 +48,7 @@ var import_research_analyst = __toESM(require("../ai-employees/built-in/research
|
|
|
48
48
|
var import_translator = __toESM(require("../ai-employees/built-in/translator"));
|
|
49
49
|
var import_nocobase_assistant = __toESM(require("../ai-employees/built-in/nocobase-assistant"));
|
|
50
50
|
var import_email_assistant = __toESM(require("../ai-employees/built-in/email-assistant"));
|
|
51
|
+
var import_data_visualization = __toESM(require("../ai-employees/built-in/data-visualization"));
|
|
51
52
|
var import_lodash = __toESM(require("lodash"));
|
|
52
53
|
const DEFAULT_LANGUAGE = "en-US";
|
|
53
54
|
const DEFAULT_KNOWLEDGE_BASE = {
|
|
@@ -69,7 +70,8 @@ class BuiltInManager {
|
|
|
69
70
|
import_research_analyst.default,
|
|
70
71
|
import_translator.default,
|
|
71
72
|
import_nocobase_assistant.default,
|
|
72
|
-
import_email_assistant.default
|
|
73
|
+
import_email_assistant.default,
|
|
74
|
+
import_data_visualization.default
|
|
73
75
|
];
|
|
74
76
|
builtInEmployeeMap = Object.fromEntries(this.builtInEmployees.map((x) => [x.username, x]));
|
|
75
77
|
setupBuiltInInfo(locale, aiEmployee) {
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "AI 员工",
|
|
5
5
|
"description": "Create AI employees with diverse skills to collaborate with humans, build systems, and handle business operations.",
|
|
6
6
|
"description.zh-CN": "创建各种技能的 AI 员工,与人类协同,搭建系统,处理业务。",
|
|
7
|
-
"version": "2.0.0-alpha.
|
|
7
|
+
"version": "2.0.0-alpha.41",
|
|
8
8
|
"main": "dist/server/index.js",
|
|
9
9
|
"peerDependencies": {
|
|
10
10
|
"@nocobase/client": "2.x",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"keywords": [
|
|
43
43
|
"AI"
|
|
44
44
|
],
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "889e81eef0280c2e45571bd0a4b2db6aa004f8c1"
|
|
46
46
|
}
|