@shun-js/aibaiban-server 0.7.5 → 0.7.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shun-js/aibaiban-server",
3
- "version": "0.7.5",
3
+ "version": "0.7.7",
4
4
  "description": "aibaiban.com server",
5
5
  "keywords": [
6
6
  "ai aibaiban"
@@ -16,9 +16,6 @@
16
16
  "url": "https://github.com/uikoo9/shun-js/issues"
17
17
  },
18
18
  "files": [
19
- "server",
20
- "assets",
21
- "views",
22
19
  "app.js"
23
20
  ],
24
21
  "scripts": {
package/assets/bing.txt DELETED
@@ -1 +0,0 @@
1
- 4cb288d7aef5469c92616c0f5b5aeb89
package/assets/robots.txt DELETED
@@ -1,36 +0,0 @@
1
- # AI白板 - robots.txt
2
- # 更新时间: 2026-01-26
3
-
4
- # 允许所有搜索引擎爬虫
5
- User-agent: *
6
- Allow: /
7
-
8
- # 禁止爬取静态资源文件(可选,减少服务器负载)
9
- # Disallow: /assets/
10
- # Disallow: /*.js$
11
- # Disallow: /*.css$
12
-
13
- # 禁止爬取 API 接口
14
- Disallow: /api/
15
-
16
- # 爬虫访问速率限制(可选,防止爬虫过度占用带宽)
17
- # Crawl-delay: 1
18
-
19
- # 站点地图
20
- Sitemap: https://aibaiban.com/sitemap.xml
21
-
22
- # 特定爬虫配置
23
- # Google Bot
24
- User-agent: Googlebot
25
- Allow: /
26
- Crawl-delay: 0
27
-
28
- # Bing Bot
29
- User-agent: Bingbot
30
- Allow: /
31
- Crawl-delay: 0
32
-
33
- # 百度爬虫
34
- User-agent: Baiduspider
35
- Allow: /
36
- Crawl-delay: 1
@@ -1,16 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <urlset
3
- xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
4
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
- xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
6
- http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
7
-
8
- <!-- 首页/落地页 - 最高优先级 -->
9
- <url>
10
- <loc>https://aibaiban.com/</loc>
11
- <lastmod>2026-02-03</lastmod>
12
- <changefreq>weekly</changefreq>
13
- <priority>1.0</priority>
14
- </url>
15
-
16
- </urlset>
@@ -1,12 +0,0 @@
1
- // service
2
- const service = require('../service/IndexService.js');
3
-
4
- /**
5
- * controller
6
- */
7
- module.exports = (app) => {
8
- // index
9
- app.get('/', (req, res) => {
10
- service.index(req, res);
11
- });
12
- };
@@ -1,17 +0,0 @@
1
- // service
2
- const service = require('../service/LLMService.js');
3
-
4
- /**
5
- * controller
6
- */
7
- module.exports = (app) => {
8
- // intent
9
- app.post('/intent', (req, res) => {
10
- service.intent(req, res);
11
- });
12
-
13
- // drawWithTools (使用结构化 JSON 输出)
14
- app.post('/drawWithTools', (req, res) => {
15
- service.drawWithTools(req, res);
16
- });
17
- };
@@ -1,18 +0,0 @@
1
- // service
2
- const service = require('../service/SEOService.js');
3
-
4
- /**
5
- * controller
6
- */
7
- module.exports = (app) => {
8
- // seo
9
- app.get('/robots.txt', (req, res) => {
10
- service.robots(req, res);
11
- });
12
- app.get('/sitemap.xml', (req, res) => {
13
- service.sitemap(req, res);
14
- });
15
- app.get('/4cb288d7aef5469c92616c0f5b5aeb89.txt', (req, res) => {
16
- service.bingIndexNow(req, res);
17
- });
18
- };
@@ -1,34 +0,0 @@
1
- /**
2
- * log options
3
- * @returns
4
- */
5
- module.exports = () => {
6
- // log options
7
- const logLevel = 'debug';
8
- const logPattern = 'yyyy-MM-dd-hh';
9
- const logPath = require('path').resolve(__dirname, '../logs/qiao-z.log');
10
-
11
- return {
12
- pm2: true,
13
- pm2InstanceVar: 'INSTANCE_ID',
14
- appenders: {
15
- stdout: {
16
- type: 'stdout',
17
- },
18
- datefile: {
19
- type: 'dateFile',
20
- pattern: logPattern,
21
- filename: logPath,
22
- keepFileExt: true,
23
- numBackups: 30,
24
- compress: true,
25
- },
26
- },
27
- categories: {
28
- default: {
29
- level: logLevel,
30
- appenders: ['stdout', 'datefile'],
31
- },
32
- },
33
- };
34
- };
@@ -1,16 +0,0 @@
1
- /**
2
- * index
3
- * @param {*} req
4
- * @param {*} res
5
- */
6
- exports.index = async (req, res) => {
7
- // const
8
- const pagePath = './views/index.html';
9
-
10
- // is static
11
- const isStatic = await res.staticRender(pagePath);
12
- if (isStatic) return;
13
-
14
- // render
15
- res.render(pagePath, {}, true);
16
- };
@@ -1,85 +0,0 @@
1
- // llm
2
- const { llmParseIntent } = require('../util/llm-intent.js');
3
-
4
- // structured json output
5
- const { generateFlowchartWithTools } = require('../util/llm-toolcall.js');
6
-
7
- // util
8
- const { chatFeishuMsg, chatResFeishuMsg, errorFeishuMsg } = require('../util/feishu.js');
9
-
10
- /**
11
- * intent
12
- * @param {*} req
13
- * @param {*} res
14
- * @returns
15
- */
16
- exports.intent = async (req, res) => {
17
- const methodName = 'intent';
18
-
19
- // check
20
- if (!req.body.userPrompt) {
21
- const msg = 'need userPrompt';
22
- req.logger.error(methodName, msg);
23
- res.jsonFail(msg);
24
- return;
25
- }
26
-
27
- // const
28
- const userPrompt = decodeURIComponent(req.body.userPrompt);
29
- req.logger.info(methodName, 'userPrompt', userPrompt);
30
- chatFeishuMsg(req);
31
-
32
- // go
33
- try {
34
- const llmParseIntentRes = await llmParseIntent(userPrompt);
35
- const llmParseIntentObj = JSON.parse(llmParseIntentRes);
36
- req.logger.info(methodName, 'llmParseIntentObj', llmParseIntentObj);
37
-
38
- // r
39
- chatResFeishuMsg(req, JSON.stringify(llmParseIntentObj));
40
- res.jsonSuccess('success', llmParseIntentObj);
41
- } catch (error) {
42
- const msg = 'parse intent error';
43
- errorFeishuMsg(req, msg);
44
- req.logger.error(methodName, msg, error);
45
- res.jsonFail(msg);
46
- }
47
- };
48
-
49
- /**
50
- * drawWithTools - 使用结构化 JSON 输出生成流程图
51
- * @param {*} req
52
- * @param {*} res
53
- * @returns
54
- */
55
- exports.drawWithTools = async (req, res) => {
56
- const methodName = 'drawWithTools';
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 diagram = await generateFlowchartWithTools(userPrompt);
74
- req.logger.info(methodName, 'diagram', diagram);
75
-
76
- // r
77
- chatResFeishuMsg(req, JSON.stringify(diagram));
78
- res.jsonSuccess('success', diagram);
79
- } catch (error) {
80
- const msg = 'draw with tools error';
81
- errorFeishuMsg(req, msg);
82
- req.logger.error(methodName, msg, error);
83
- res.jsonFail(msg);
84
- }
85
- };
@@ -1,38 +0,0 @@
1
- // path
2
- const path = require('path');
3
-
4
- // qiao
5
- const { readFile } = require('qiao-file');
6
-
7
- /**
8
- * robots
9
- * @param {*} req
10
- * @param {*} res
11
- */
12
- exports.robots = async (req, res) => {
13
- const txtPath = path.resolve(__dirname, '../../assets/robots.txt');
14
- const txt = await readFile(txtPath);
15
- res.send(txt);
16
- };
17
-
18
- /**
19
- * sitemap
20
- * @param {*} req
21
- * @param {*} res
22
- */
23
- exports.sitemap = async (req, res) => {
24
- const sitemapPath = path.resolve(__dirname, '../../assets/sitemap.xml');
25
- const sitemap = await readFile(sitemapPath);
26
- res.send(sitemap);
27
- };
28
-
29
- /**
30
- * bingIndexNow
31
- * @param {*} req
32
- * @param {*} res
33
- */
34
- exports.bingIndexNow = async (req, res) => {
35
- const txtPath = path.resolve(__dirname, '../../assets/bing.txt');
36
- const txt = await readFile(txtPath);
37
- res.send(txt);
38
- };
@@ -1,23 +0,0 @@
1
- // qiao
2
- const { userCheck } = require('qiao-z-service');
3
-
4
- /**
5
- * checkUserAuth
6
- * @param {*} req
7
- * @param {*} res
8
- * @returns
9
- */
10
- exports.checkUserAuth = async function (req, res) {
11
- const userCheckRes = await userCheck(global.QZ_CONFIG.user, {
12
- userid: req.headers.userid,
13
- usertoken: req.headers.usertoken,
14
- paths: JSON.stringify(global.QZ_CONFIG.paths),
15
- path: req.url.pathname,
16
- });
17
-
18
- // pass
19
- if (userCheckRes && userCheckRes.type === 'success') return true;
20
-
21
- // r
22
- res.json(userCheckRes);
23
- };
@@ -1,77 +0,0 @@
1
- // services
2
- const { feishuBot } = require('@shun-js/shun-service');
3
-
4
- /**
5
- * feishuMsg
6
- * @param {*} msg
7
- */
8
- exports.feishuMsg = (msg) => {
9
- if (global.QZ_CONFIG.env !== 'production') return;
10
-
11
- feishuBot({
12
- url: global.QZ_CONFIG.feishu.url,
13
- feishuUrl: global.QZ_CONFIG.feishu.feishuUrl,
14
- feishuMsg: msg,
15
- });
16
- };
17
-
18
- // is bot
19
- function isBot(req) {
20
- const ua = req.useragent;
21
- const hasOSName = ua && ua.os && ua.os.name;
22
- const isGoogleBot = ua && ua.browser && ua.browser.name === 'Googlebot';
23
- const isMetaBot = ua && ua.browser && ua.browser.name === 'meta-externalagent';
24
- const isSafariBot = ua && ua.engine && ua.engine.name === 'WebKit' && ua.engine.version === '605.1.15';
25
- return !hasOSName || isGoogleBot || isMetaBot || isSafariBot;
26
- }
27
-
28
- /**
29
- * errorFeishuMsg
30
- * @param {*} req
31
- * @param {*} msg
32
- * @returns
33
- */
34
- exports.errorFeishuMsg = (req, msg) => {
35
- // check
36
- if (isBot(req)) return;
37
-
38
- // msg
39
- const uaJson = JSON.stringify(req.useragent || {});
40
- exports.feishuMsg(`【通知】服务异常,${msg},请查看日志,ua:${uaJson}`);
41
- };
42
-
43
- /**
44
- * chatFeishuMsg
45
- * @param {*} req
46
- * @returns
47
- */
48
- exports.chatFeishuMsg = (req) => {
49
- // check
50
- if (isBot(req)) return;
51
-
52
- // msg
53
- const uaJson = JSON.stringify(req.useragent || {});
54
- const userid = req.headers.userid;
55
- const prompt = decodeURIComponent(req.body.userPrompt);
56
-
57
- const msg = `【通知】/chat被访问\nuserid:${userid}\nua:\n${uaJson}\nprompt:\n${prompt}`;
58
- exports.feishuMsg(msg);
59
- };
60
-
61
- /**
62
- * chatResFeishuMsg
63
- * @param {*} req
64
- * @returns
65
- */
66
- exports.chatResFeishuMsg = (req, chatRes) => {
67
- // check
68
- if (isBot(req)) return;
69
-
70
- // msg
71
- const uaJson = JSON.stringify(req.useragent || {});
72
- const userid = req.headers.userid;
73
- const prompt = decodeURIComponent(req.body.userPrompt);
74
-
75
- const msg = `【通知】/chat生成成功\nuserid:${userid}\nua:\n${uaJson}\nprompt:\n${prompt}\nres:${chatRes}`;
76
- exports.feishuMsg(msg);
77
- };
@@ -1,79 +0,0 @@
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
- };