@shun-js/aibaiban-server 1.3.7 → 1.3.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 +3 -3
- package/server/service/LLMService.js +25 -28
- package/views/index.html +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shun-js/aibaiban-server",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.9",
|
|
4
4
|
"description": "aibaiban.com server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai aibaiban"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"qiao-z-nuser": "^6.0.0",
|
|
38
38
|
"qiao-z-service": "^6.0.0",
|
|
39
39
|
"qiao-z-sms": "^6.0.0",
|
|
40
|
-
"viho-llm": "^1.0
|
|
40
|
+
"viho-llm": "^1.1.0",
|
|
41
41
|
"zod": "^4.3.6",
|
|
42
42
|
"zod-to-json-schema": "^3.25.1"
|
|
43
43
|
},
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"access": "public",
|
|
46
46
|
"registry": "https://registry.npmjs.org/"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "7288be3407eb8a311adbe7e6026ce0ed80ec4b83"
|
|
49
49
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// llm
|
|
2
|
-
const { OpenAIAPI, runAgents } = require('viho-llm');
|
|
2
|
+
const { OpenAIAPI, LibLibAPI, runAgents } = require('viho-llm');
|
|
3
3
|
const prompts = require('../util/prompt-agent.js');
|
|
4
4
|
|
|
5
5
|
// util
|
|
@@ -12,8 +12,9 @@ const llm = OpenAIAPI(finalLLMConfig);
|
|
|
12
12
|
const modelName = finalLLMConfig.modelName;
|
|
13
13
|
const thinking = finalLLMConfig.thinking;
|
|
14
14
|
|
|
15
|
-
// 图片生成配置
|
|
15
|
+
// 图片生成配置 (LibLib)
|
|
16
16
|
const imageGenConfig = global.QZ_CONFIG.imageGen;
|
|
17
|
+
const liblib = LibLibAPI(imageGenConfig);
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* convertToolCallToSkeleton - 将单个 tool call 转为 ExcalidrawElementSkeleton
|
|
@@ -335,39 +336,35 @@ exports.drawAgent = async (req, res) => {
|
|
|
335
336
|
res.streaming(`data: ${JSON.stringify({ type: 'message', content: canvasResponse.content })}\n\n`);
|
|
336
337
|
}
|
|
337
338
|
} else if (decision.action === 'image') {
|
|
338
|
-
// 4. Image -
|
|
339
|
+
// 4. Image - 调用 LibLib 图片生成 API
|
|
339
340
|
res.streaming(`data: ${JSON.stringify({ type: 'status', step: 'image' })}\n\n`);
|
|
340
341
|
req.logger.info(methodName, 'step: image generation', decision.prompt);
|
|
341
342
|
chatFeishuMsg(req, `image-${decision.prompt}`);
|
|
342
343
|
|
|
343
|
-
const
|
|
344
|
-
|
|
345
|
-
headers: {
|
|
346
|
-
Authorization: `Bearer ${imageGenConfig.apiKey}`,
|
|
347
|
-
'Content-Type': 'application/json',
|
|
348
|
-
},
|
|
349
|
-
body: JSON.stringify({
|
|
350
|
-
model: imageGenConfig.modelName,
|
|
351
|
-
prompt: decision.prompt,
|
|
352
|
-
}),
|
|
353
|
-
});
|
|
344
|
+
const submitRes = await liblib.text2img(decision.prompt, { aspectRatio: 'square' });
|
|
345
|
+
const generateUuid = submitRes.data?.generateUuid;
|
|
354
346
|
|
|
355
|
-
|
|
356
|
-
|
|
347
|
+
if (!generateUuid) {
|
|
348
|
+
req.logger.error(methodName, 'liblib submit failed', JSON.stringify(submitRes));
|
|
349
|
+
res.streaming(`data: ${JSON.stringify({ type: 'message', content: '图片生成失败,请稍后重试。' })}\n\n`);
|
|
350
|
+
} else {
|
|
351
|
+
const result = await liblib.waitForResult(generateUuid);
|
|
352
|
+
const imageUrl = result.imagesInfo?.[0]?.imageUrl;
|
|
357
353
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
354
|
+
if (imageUrl) {
|
|
355
|
+
// 下载图片转 base64
|
|
356
|
+
const imgResponse = await fetch(imageUrl);
|
|
357
|
+
const imgBuffer = Buffer.from(await imgResponse.arrayBuffer());
|
|
358
|
+
const contentType = imgResponse.headers.get('content-type') || 'image/jpeg';
|
|
359
|
+
const dataURL = `data:${contentType};base64,${imgBuffer.toString('base64')}`;
|
|
364
360
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
361
|
+
const duration = Date.now() - startTime;
|
|
362
|
+
req.logger.info(methodName, 'image generated', `${duration}ms`);
|
|
363
|
+
res.streaming(`data: ${JSON.stringify({ type: 'image', dataURL, duration })}\n\n`);
|
|
364
|
+
} else {
|
|
365
|
+
req.logger.error(methodName, 'liblib no image url', JSON.stringify(result));
|
|
366
|
+
res.streaming(`data: ${JSON.stringify({ type: 'message', content: '图片生成失败,请稍后重试。' })}\n\n`);
|
|
367
|
+
}
|
|
371
368
|
}
|
|
372
369
|
} else if (decision.action === 'sketch') {
|
|
373
370
|
// 5. Sketch - 通知前端执行线稿提取(处理在前端完成)
|
package/views/index.html
CHANGED
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
<script
|
|
106
106
|
type="module"
|
|
107
107
|
crossorigin
|
|
108
|
-
src="https://static-small.vincentqiao.com/aibaiban/static/index-
|
|
108
|
+
src="https://static-small.vincentqiao.com/aibaiban/static/index-DhOf2fPx.js"
|
|
109
109
|
></script>
|
|
110
110
|
<link
|
|
111
111
|
rel="modulepreload"
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
<link
|
|
131
131
|
rel="modulepreload"
|
|
132
132
|
crossorigin
|
|
133
|
-
href="https://static-small.vincentqiao.com/aibaiban/static/chunks/excalidraw-
|
|
133
|
+
href="https://static-small.vincentqiao.com/aibaiban/static/chunks/excalidraw-CaLPmsCY.js"
|
|
134
134
|
/>
|
|
135
135
|
<link
|
|
136
136
|
rel="stylesheet"
|