@shun-js/aibaiban-server 0.8.5 → 0.8.6

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.5",
3
+ "version": "0.8.6",
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": "f3fa85784a8d086877a5057a29964d862126791c"
47
+ "gitHead": "04eafc5cc7cc90e3fe81103daa88c168ff6f5037"
48
48
  }
@@ -5,18 +5,8 @@ const service = require('../service/LLMService.js');
5
5
  * controller
6
6
  */
7
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
-
18
- // draw/agent (流式 Agent)
19
- app.post('/draw/agent', (req, res) => {
8
+ // draw agent
9
+ app.post('/chat-streaming', (req, res) => {
20
10
  service.drawAgent(req, res);
21
11
  });
22
12
  };
@@ -1,93 +1,7 @@
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
1
  // llm agent
11
2
  const { callLLMForJSON, callLLM } = require('../util/llm-agent.js');
12
3
  const prompts = require('../util/prompt-agent.js');
13
4
 
14
- /**
15
- * intent
16
- * @param {*} req
17
- * @param {*} res
18
- * @returns
19
- */
20
- exports.intent = async (req, res) => {
21
- const methodName = 'intent';
22
-
23
- // check
24
- if (!req.body.userPrompt) {
25
- const msg = 'need userPrompt';
26
- req.logger.error(methodName, msg);
27
- res.jsonFail(msg);
28
- return;
29
- }
30
-
31
- // const
32
- const userPrompt = decodeURIComponent(req.body.userPrompt);
33
- req.logger.info(methodName, 'userPrompt', userPrompt);
34
- chatFeishuMsg(req);
35
-
36
- // go
37
- try {
38
- const llmParseIntentRes = await llmParseIntent(userPrompt);
39
- const llmParseIntentObj = JSON.parse(llmParseIntentRes);
40
- req.logger.info(methodName, 'llmParseIntentObj', llmParseIntentObj);
41
-
42
- // r
43
- chatResFeishuMsg(req, JSON.stringify(llmParseIntentObj));
44
- res.jsonSuccess('success', llmParseIntentObj);
45
- } catch (error) {
46
- const msg = 'parse intent error';
47
- errorFeishuMsg(req, msg);
48
- req.logger.error(methodName, msg, error);
49
- res.jsonFail(msg);
50
- }
51
- };
52
-
53
- /**
54
- * drawWithTools - 使用结构化 JSON 输出生成流程图
55
- * @param {*} req
56
- * @param {*} res
57
- * @returns
58
- */
59
- exports.drawWithTools = async (req, res) => {
60
- const methodName = 'drawWithTools';
61
-
62
- // check
63
- if (!req.body.userPrompt) {
64
- const msg = 'need userPrompt';
65
- req.logger.error(methodName, msg);
66
- res.jsonFail(msg);
67
- return;
68
- }
69
-
70
- // const
71
- const userPrompt = decodeURIComponent(req.body.userPrompt);
72
- req.logger.info(methodName, 'userPrompt', userPrompt);
73
- chatFeishuMsg(req);
74
-
75
- // go
76
- try {
77
- const diagram = await generateFlowchartWithTools(userPrompt);
78
- req.logger.info(methodName, 'diagram', diagram);
79
-
80
- // r
81
- chatResFeishuMsg(req, JSON.stringify(diagram));
82
- res.jsonSuccess('success', diagram);
83
- } catch (error) {
84
- const msg = 'draw with tools error';
85
- errorFeishuMsg(req, msg);
86
- req.logger.error(methodName, msg, error);
87
- res.jsonFail(msg);
88
- }
89
- };
90
-
91
5
  /**
92
6
  * drawAgent - 流式 Agent 接口
93
7
  * 流程:router -> classify -> elaborate -> review -> generate