@shun-js/aibaiban-server 0.8.7 → 0.8.9

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.8.7",
3
+ "version": "0.8.9",
4
4
  "description": "aibaiban.com server",
5
5
  "keywords": [
6
6
  "ai aibaiban"
@@ -44,5 +44,5 @@
44
44
  "access": "public",
45
45
  "registry": "https://registry.npmjs.org/"
46
46
  },
47
- "gitHead": "87f3b0d45f4f95caca6d23b861e262f443dc891b"
47
+ "gitHead": "b7126491abd4565dd2cdc69e5787579c10265a79"
48
48
  }
@@ -2,6 +2,9 @@
2
2
  const { callLLMForJSON, callLLM } = require('../util/llm-agent.js');
3
3
  const prompts = require('../util/prompt-agent.js');
4
4
 
5
+ // util
6
+ const { chatFeishuMsg, errorFeishuMsg } = require('../util/feishu.js');
7
+
5
8
  /**
6
9
  * drawAgent - 流式 Agent 接口
7
10
  * 流程:router -> classify -> elaborate -> review -> generate
@@ -22,15 +25,18 @@ exports.drawAgent = async (req, res) => {
22
25
 
23
26
  const input = decodeURIComponent(req.body.userPrompt);
24
27
  req.logger.info(methodName, 'userPrompt', input);
28
+ chatFeishuMsg(req, `userPrompt-${input}`);
25
29
 
26
30
  try {
27
- // 1. router - 判断意图
31
+ // start
28
32
  res.streaming(`data: ${JSON.stringify({ step: 'router', status: 'start' })}\n\n`);
29
33
  req.logger.info(methodName, 'step: router');
34
+
35
+ // intent
30
36
  const intentResult = await callLLMForJSON(prompts.ROUTER_PROMPT.replace('{input}', input), res, 'router');
31
37
  const intent = intentResult.intent;
32
38
  req.logger.info(methodName, 'intent', intent);
33
- // 发送结果
39
+ chatFeishuMsg(req, `intent-${intent}`);
34
40
  res.streaming(`data: ${JSON.stringify({ step: 'router', intent })}\n\n`);
35
41
 
36
42
  // 非白板请求
@@ -48,7 +54,7 @@ exports.drawAgent = async (req, res) => {
48
54
  const classifyResult = await callLLMForJSON(prompts.CLASSIFY_PROMPT.replace('{input}', input), res, 'classify');
49
55
  const diagramType = classifyResult.diagramType;
50
56
  req.logger.info(methodName, 'diagramType', diagramType);
51
- // 发送结果
57
+ chatFeishuMsg(req, `diagramType-${diagramType}`);
52
58
  res.streaming(`data: ${JSON.stringify({ step: 'classify', diagramType })}\n\n`);
53
59
 
54
60
  // 3. elaborate - 细化内容
@@ -60,7 +66,7 @@ exports.drawAgent = async (req, res) => {
60
66
  'elaborate',
61
67
  );
62
68
  req.logger.info(methodName, 'elaboration', elaboration.slice(0, 100) + '...');
63
- // 发送结果(不显示内容,只标记完成)
69
+ chatFeishuMsg(req, `elaboration-${elaboration}`);
64
70
  res.streaming(`data: ${JSON.stringify({ step: 'elaborate', done: true })}\n\n`);
65
71
 
66
72
  // 4. review - 质量检查
@@ -74,7 +80,7 @@ exports.drawAgent = async (req, res) => {
74
80
  'review',
75
81
  );
76
82
  req.logger.info(methodName, 'reviewResult', reviewResult);
77
- // 发送结果
83
+ chatFeishuMsg(req, `reviewResult-${reviewResult}`);
78
84
  res.streaming(`data: ${JSON.stringify({ step: 'review', result: reviewResult.result })}\n\n`);
79
85
 
80
86
  // 信息不足,追问用户
@@ -98,14 +104,15 @@ exports.drawAgent = async (req, res) => {
98
104
  res,
99
105
  'generate',
100
106
  );
101
-
102
107
  req.logger.info(methodName, 'mermaidCode', mermaidCode.slice(0, 100) + '...');
108
+ chatFeishuMsg(req, `mermaidCode-${mermaidCode}`);
103
109
 
104
110
  // 返回最终结果
105
111
  res.streaming(`data: ${JSON.stringify({ step: 'generate', mermaidCode })}\n\n`);
106
112
  res.streamingEnd();
107
113
  } catch (error) {
108
114
  req.logger.error(methodName, 'error', error);
115
+ errorFeishuMsg(req, error.message);
109
116
  res.streaming(`data: ${JSON.stringify({ step: 'error', message: error.message })}\n\n`);
110
117
  res.streamingEnd();
111
118
  }
@@ -43,35 +43,17 @@ exports.errorFeishuMsg = (req, msg) => {
43
43
  /**
44
44
  * chatFeishuMsg
45
45
  * @param {*} req
46
+ * @param {*} msg
46
47
  * @returns
47
48
  */
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) => {
49
+ exports.chatFeishuMsg = (req, msg) => {
67
50
  // check
68
51
  if (isBot(req)) return;
69
52
 
70
53
  // msg
71
54
  const uaJson = JSON.stringify(req.useragent || {});
72
55
  const userid = req.headers.userid;
73
- const prompt = decodeURIComponent(req.body.userPrompt);
74
56
 
75
- const msg = `【通知】/chat生成成功\nuserid:${userid}\nua:\n${uaJson}\nprompt:\n${prompt}\nres:${chatRes}`;
76
- exports.feishuMsg(msg);
57
+ const finalMsg = `【通知】/chat被访问\nuserid:${userid}\nua:\n${uaJson}\nmsg:\n${msg}`;
58
+ exports.feishuMsg(finalMsg);
77
59
  };
package/views/index.html CHANGED
@@ -107,32 +107,32 @@
107
107
  <script
108
108
  type="module"
109
109
  crossorigin
110
- src="https://static-small.vincentqiao.com/aibaiban/static/index-ChG0Vz1x.js"
110
+ src="https://static-small.vincentqiao.com/aibaiban/static/index-B8pTLfcc.js"
111
111
  ></script>
112
112
  <link
113
113
  rel="modulepreload"
114
114
  crossorigin
115
- href="https://static-small.vincentqiao.com/aibaiban/static/chunks/react-vendor-3yn_rB-k.js"
115
+ href="https://static-small.vincentqiao.com/aibaiban/static/chunks/react-vendor-sruPWfIs.js"
116
116
  />
117
117
  <link
118
118
  rel="modulepreload"
119
119
  crossorigin
120
- href="https://static-small.vincentqiao.com/aibaiban/static/chunks/antd-base-DsOgKHDt.js"
120
+ href="https://static-small.vincentqiao.com/aibaiban/static/chunks/antd-base-CUHU3t6W.js"
121
121
  />
122
122
  <link
123
123
  rel="modulepreload"
124
124
  crossorigin
125
- href="https://static-small.vincentqiao.com/aibaiban/static/chunks/antd-icons-CdlvvYvH.js"
125
+ href="https://static-small.vincentqiao.com/aibaiban/static/chunks/antd-icons-C5ujIBy3.js"
126
126
  />
127
127
  <link
128
128
  rel="modulepreload"
129
129
  crossorigin
130
- href="https://static-small.vincentqiao.com/aibaiban/static/chunks/antd-x-BIAsZ6s9.js"
130
+ href="https://static-small.vincentqiao.com/aibaiban/static/chunks/antd-x-Ch3MovBd.js"
131
131
  />
132
132
  <link
133
133
  rel="modulepreload"
134
134
  crossorigin
135
- href="https://static-small.vincentqiao.com/aibaiban/static/chunks/excalidraw-DGFFb3CZ.js"
135
+ href="https://static-small.vincentqiao.com/aibaiban/static/chunks/excalidraw-BGgbH-5v.js"
136
136
  />
137
137
  <link
138
138
  rel="stylesheet"