@shun-js/aibaiban-server 0.6.5 → 0.6.7

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.
@@ -8,41 +8,9 @@
8
8
  <!-- 首页/落地页 - 最高优先级 -->
9
9
  <url>
10
10
  <loc>https://aibaiban.com/</loc>
11
- <lastmod>2026-01-26</lastmod>
11
+ <lastmod>2026-02-03</lastmod>
12
12
  <changefreq>weekly</changefreq>
13
13
  <priority>1.0</priority>
14
14
  </url>
15
15
 
16
- <!-- 白板应用页面 - 高优先级 -->
17
- <url>
18
- <loc>https://aibaiban.com/board</loc>
19
- <lastmod>2026-01-26</lastmod>
20
- <changefreq>monthly</changefreq>
21
- <priority>0.8</priority>
22
- </url>
23
-
24
- <!-- 未来可以添加更多页面 -->
25
- <!--
26
- <url>
27
- <loc>https://aibaiban.com/about</loc>
28
- <lastmod>2026-01-26</lastmod>
29
- <changefreq>monthly</changefreq>
30
- <priority>0.6</priority>
31
- </url>
32
-
33
- <url>
34
- <loc>https://aibaiban.com/help</loc>
35
- <lastmod>2026-01-26</lastmod>
36
- <changefreq>monthly</changefreq>
37
- <priority>0.5</priority>
38
- </url>
39
-
40
- <url>
41
- <loc>https://aibaiban.com/pricing</loc>
42
- <lastmod>2026-01-26</lastmod>
43
- <changefreq>monthly</changefreq>
44
- <priority>0.7</priority>
45
- </url>
46
- -->
47
-
48
16
  </urlset>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shun-js/aibaiban-server",
3
- "version": "0.6.5",
3
+ "version": "0.6.7",
4
4
  "description": "aibaiban.com server",
5
5
  "keywords": [
6
6
  "ai aibaiban"
@@ -22,7 +22,7 @@
22
22
  "app.js"
23
23
  ],
24
24
  "scripts": {
25
- "pack": "cp ./static/*.html ./views",
25
+ "pack": "cp ./static/index.html ./views/index.html",
26
26
  "upload": "qcos fo ../../configs/aitubiao-web.json ./static aibaiban/static"
27
27
  },
28
28
  "dependencies": {
@@ -33,16 +33,16 @@
33
33
  "qiao-rate-limit": "^5.8.8",
34
34
  "qiao-redis": "^5.8.9",
35
35
  "qiao-z": "^5.8.9",
36
- "qiao-z-nuser": "^5.8.8",
37
- "qiao-z-service": "^5.8.8",
38
- "qiao-z-sms": "^5.8.8",
36
+ "qiao-z-nuser": "^5.9.5",
37
+ "qiao-z-service": "^5.9.2",
38
+ "qiao-z-sms": "^5.9.2",
39
39
  "viho-llm": "^0.2.3",
40
- "zod": "^3.25.76",
41
- "zod-to-json-schema": "^3.25.0"
40
+ "zod": "^4.3.6",
41
+ "zod-to-json-schema": "^3.25.1"
42
42
  },
43
43
  "publishConfig": {
44
44
  "access": "public",
45
45
  "registry": "https://registry.npmjs.org/"
46
46
  },
47
- "gitHead": "a6d44d1fe7933c163c91fcc5157fcd89a8000b00"
47
+ "gitHead": "60f6356fdb876d69ce8aee9a143c3e06cff23c0c"
48
48
  }
@@ -9,9 +9,4 @@ module.exports = (app) => {
9
9
  app.get('/', (req, res) => {
10
10
  service.index(req, res);
11
11
  });
12
-
13
- // board
14
- app.get('/board', (req, res) => {
15
- service.board(req, res);
16
- });
17
12
  };
@@ -10,12 +10,7 @@ module.exports = (app) => {
10
10
  service.intent(req, res);
11
11
  });
12
12
 
13
- // draw (原有方法)
14
- app.post('/draw', (req, res) => {
15
- service.draw(req, res);
16
- });
17
-
18
- // drawWithTools (Tool Calling 方法)
13
+ // drawWithTools (使用结构化 JSON 输出)
19
14
  app.post('/drawWithTools', (req, res) => {
20
15
  service.drawWithTools(req, res);
21
16
  });
@@ -14,20 +14,3 @@ exports.index = async (req, res) => {
14
14
  // render
15
15
  res.render(pagePath, {}, true);
16
16
  };
17
-
18
- /**
19
- * board
20
- * @param {*} req
21
- * @param {*} res
22
- */
23
- exports.board = async (req, res) => {
24
- // const
25
- const pagePath = './views/board.html';
26
-
27
- // is static
28
- const isStatic = await res.staticRender(pagePath);
29
- if (isStatic) return;
30
-
31
- // render
32
- res.render(pagePath, {}, true);
33
- };
@@ -1,7 +1,7 @@
1
1
  // llm
2
- const { llmParseIntent, llmGetDrawJson } = require('../util/llm-v4.js');
2
+ const { llmParseIntent } = require('../util/llm-intent.js');
3
3
 
4
- // tool calling
4
+ // structured json output
5
5
  const { generateFlowchartWithTools } = require('../util/llm-toolcall.js');
6
6
 
7
7
  // util
@@ -47,46 +47,7 @@ exports.intent = async (req, res) => {
47
47
  };
48
48
 
49
49
  /**
50
- * draw
51
- * @param {*} req
52
- * @param {*} res
53
- * @returns
54
- */
55
- exports.draw = async (req, res) => {
56
- const methodName = 'draw';
57
-
58
- // check
59
- if (!req.body.userPrompt) {
60
- const msg = 'need userPrompt';
61
- req.logger.error(methodName, msg);
62
- res.jsonFail(msg);
63
- return;
64
- }
65
-
66
- // const
67
- const userPrompt = decodeURIComponent(req.body.userPrompt);
68
- req.logger.info(methodName, 'userPrompt', userPrompt);
69
- chatFeishuMsg(req);
70
-
71
- // go
72
- try {
73
- const llmGetDrawJsonRes = await llmGetDrawJson(userPrompt);
74
- const llmGetDrawJsonObj = JSON.parse(llmGetDrawJsonRes);
75
- req.logger.info(methodName, 'llmGetDrawJsonObj', llmGetDrawJsonObj);
76
-
77
- // r
78
- chatResFeishuMsg(req, JSON.stringify(llmGetDrawJsonObj));
79
- res.jsonSuccess('success', llmGetDrawJsonObj);
80
- } catch (error) {
81
- const msg = 'draw json error';
82
- errorFeishuMsg(req, msg);
83
- req.logger.error(methodName, msg, error);
84
- res.jsonFail(msg);
85
- }
86
- };
87
-
88
- /**
89
- * drawWithTools - 使用 Tool Calling 生成流程图
50
+ * drawWithTools - 使用结构化 JSON 输出生成流程图
90
51
  * @param {*} req
91
52
  * @param {*} res
92
53
  * @returns
@@ -0,0 +1,79 @@
1
+ // path
2
+ const path = require('path');
3
+ const { readFile } = require('qiao-file');
4
+
5
+ // z
6
+ const { z } = require('zod');
7
+ const { zodToJsonSchema } = require('zod-to-json-schema');
8
+
9
+ // llm
10
+ const { GeminiVertex } = require('viho-llm');
11
+ const gemini = GeminiVertex({
12
+ projectId: global.QZ_CONFIG.gemini.projectId,
13
+ location: global.QZ_CONFIG.gemini.location,
14
+ modelName: global.QZ_CONFIG.gemini.modelName,
15
+ });
16
+
17
+ // const
18
+ const chatConfig = {
19
+ responseMimeType: 'application/json',
20
+ temperature: 0.2, // 保持较低温度,确保输出稳定
21
+ topP: 0.9,
22
+ topK: 40,
23
+ maxOutputTokens: 8192, // 足够大以支持复杂图表
24
+ thinkingConfig: {
25
+ thinkingBudget: 0,
26
+ includeThoughts: false,
27
+ },
28
+ };
29
+ const safetySettings = [
30
+ {
31
+ category: 'HARM_CATEGORY_HATE_SPEECH',
32
+ threshold: 'BLOCK_ONLY_HIGH',
33
+ },
34
+ {
35
+ category: 'HARM_CATEGORY_DANGEROUS_CONTENT',
36
+ threshold: 'BLOCK_ONLY_HIGH',
37
+ },
38
+ {
39
+ category: 'HARM_CATEGORY_SEXUALLY_EXPLICIT',
40
+ threshold: 'BLOCK_ONLY_HIGH',
41
+ },
42
+ {
43
+ category: 'HARM_CATEGORY_HARASSMENT',
44
+ threshold: 'BLOCK_ONLY_HIGH',
45
+ },
46
+ ];
47
+
48
+ /**
49
+ * llmParseIntent
50
+ * @param {*} userPrompts
51
+ */
52
+ let intentSystemPrompt = null;
53
+ exports.llmParseIntent = async (userPrompts) => {
54
+ // intent system prompt - 支持版本切换
55
+ if (!intentSystemPrompt) {
56
+ const promptFile = './prompt-intent.md';
57
+ intentSystemPrompt = await readFile(path.resolve(__dirname, promptFile));
58
+ }
59
+
60
+ // chat config - 新增 confidence 字段支持
61
+ chatConfig.responseJsonSchema = zodToJsonSchema(
62
+ z.object({
63
+ intent: z.enum(['DRAW', 'REJECT']).describe('用户意图:DRAW(绘图)或 REJECT(非绘图)'),
64
+ reason: z.string().describe('判断理由(一句话说明)'),
65
+ confidence: z.number().min(0).max(1).optional().describe('置信度评分(0.0-1.0),可选字段'),
66
+ }),
67
+ );
68
+
69
+ // chat options
70
+ const chatOptions = {
71
+ contents: userPrompts,
72
+ systemInstruction: intentSystemPrompt,
73
+ config: chatConfig,
74
+ safetySettings: safetySettings,
75
+ };
76
+
77
+ // go
78
+ return await gemini.chat(chatOptions);
79
+ };