mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 03:01:12 +00:00
perf: 优化AI消息
This commit is contained in:
parent
9e4beaa317
commit
db6500369f
@ -1102,16 +1102,21 @@ class DialogController extends AbstractController
|
||||
if (empty($size)) {
|
||||
return Base::retError('消息发送保存失败');
|
||||
}
|
||||
$ext = $markdown ? 'md' : 'htm';
|
||||
$text = MsgTool::truncateText($text, 500, $ext);
|
||||
$desc = strip_tags($markdown ? Base::markdown2html($text) : $text);
|
||||
$type = $markdown ? 'md' : 'htm';
|
||||
$desc = $text;
|
||||
if ($markdown) {
|
||||
$desc = preg_replace("/:::\s*reasoning[\s\S]*?:::/", "", $desc);
|
||||
$desc = Base::markdown2html($desc);
|
||||
}
|
||||
$desc = strip_tags($desc);
|
||||
$desc = mb_substr(WebSocketDialogMsg::filterEscape($desc), 0, 200);
|
||||
$text = MsgTool::truncateText($text, 500, $type);
|
||||
$msgData = [
|
||||
'type' => $type, // 内容类型
|
||||
'desc' => $desc, // 描述内容
|
||||
'text' => $text, // 简要内容
|
||||
'type' => $ext, // 内容类型
|
||||
'file' => [
|
||||
'name' => "LongText-{$strlen}.{$ext}",
|
||||
'name' => "LongText-{$strlen}.{$type}",
|
||||
'size' => $size,
|
||||
'file' => $file,
|
||||
'path' => $path,
|
||||
@ -1119,7 +1124,7 @@ class DialogController extends AbstractController
|
||||
'thumb' => '',
|
||||
'width' => -1,
|
||||
'height' => -1,
|
||||
'ext' => $ext,
|
||||
'ext' => $type,
|
||||
],
|
||||
];
|
||||
if (empty($key)) {
|
||||
|
||||
@ -764,9 +764,15 @@ class WebSocketDialogMsg extends AbstractModel
|
||||
$key = '';
|
||||
switch ($this->type) {
|
||||
case 'text':
|
||||
if (!preg_match("/<span[^>]*?data-quick-key=([\"'])([^\"']+?)\\1[^>]*?>/is", $this->msg['text'])) {
|
||||
$key = strip_tags($this->msg['text']);
|
||||
if (preg_match("/<span[^>]*?data-quick-key=([\"'])([^\"']+?)\\1[^>]*?>/i", $this->msg['text'])) {
|
||||
break;
|
||||
}
|
||||
$key = $this->msg['text'];
|
||||
if ($this->msg['type'] === 'md') {
|
||||
$key = preg_replace("/:::\s*reasoning[\s\S]*?:::/", "", $key);
|
||||
$key = Base::markdown2html($key);
|
||||
}
|
||||
$key = strip_tags($key);
|
||||
break;
|
||||
|
||||
case 'vote':
|
||||
@ -1144,6 +1150,7 @@ class WebSocketDialogMsg extends AbstractModel
|
||||
}
|
||||
//
|
||||
$updateData = [
|
||||
'type' => $type,
|
||||
'mtype' => $mtype,
|
||||
'link' => $link,
|
||||
'msg' => array_merge($oldMsg, $msg),
|
||||
|
||||
@ -173,6 +173,7 @@ services:
|
||||
environment:
|
||||
REDIS_HOST: "${REDIS_HOST}"
|
||||
REDIS_PORT: "${REDIS_PORT}"
|
||||
TIMEOUT: 600
|
||||
networks:
|
||||
extnetwork:
|
||||
ipv4_address: "${APP_IPPR}.12"
|
||||
|
||||
@ -194,8 +194,9 @@ server {
|
||||
proxy_http_version 1.1;
|
||||
proxy_buffering off;
|
||||
proxy_cache off;
|
||||
proxy_read_timeout 300s;
|
||||
proxy_send_timeout 300s;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
proxy_connect_timeout 3600s;
|
||||
proxy_set_header Scheme $scheme;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
|
||||
@ -32,28 +32,25 @@ if (languageName === "zh" || languageName === "zh-CHT") {
|
||||
|
||||
// Katex
|
||||
import createKatexPlugin from '@kangc/v-md-editor/lib/plugins/katex/cdn';
|
||||
|
||||
VMdPreview.use(createKatexPlugin());
|
||||
|
||||
// Mermaid
|
||||
import createMermaidPlugin from '@kangc/v-md-editor/lib/plugins/mermaid/cdn';
|
||||
import '@kangc/v-md-editor/lib/plugins/mermaid/mermaid.css';
|
||||
|
||||
VMdPreview.use(createMermaidPlugin());
|
||||
|
||||
// TodoList
|
||||
import createTodoListPlugin from '@kangc/v-md-editor/lib/plugins/todo-list/index';
|
||||
import '@kangc/v-md-editor/lib/plugins/todo-list/todo-list.css';
|
||||
|
||||
VMdPreview.use(createTodoListPlugin());
|
||||
|
||||
// CopyCode
|
||||
import createCopyCodePlugin from '@kangc/v-md-editor/lib/plugins/copy-code/index';
|
||||
import '@kangc/v-md-editor/lib/plugins/copy-code/copy-code.css';
|
||||
|
||||
VMdPreview.use(createCopyCodePlugin());
|
||||
|
||||
import {previewMixin} from "../mixin";
|
||||
import {MarkdownPluginUtils} from "../../../store/markdown";
|
||||
|
||||
export default {
|
||||
mixins: [previewMixin],
|
||||
@ -68,6 +65,7 @@ export default {
|
||||
extend(md) {
|
||||
// md为 markdown-it 实例,可以在此处进行修改配置,并使用 plugin 进行语法扩展
|
||||
// md.set(option).use(plugin);
|
||||
MarkdownPluginUtils.initReasoningPlugin(md);
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
2
resources/assets/js/store/markdown.js
vendored
2
resources/assets/js/store/markdown.js
vendored
@ -248,6 +248,8 @@ const MarkdownPluginUtils = {
|
||||
}
|
||||
};
|
||||
|
||||
export {MarkdownPluginUtils}
|
||||
|
||||
export function MarkdownConver(text) {
|
||||
if (text === '...') {
|
||||
return '<div class="input-blink"></div>'
|
||||
|
||||
29
resources/assets/sass/pages/common.scss
vendored
29
resources/assets/sass/pages/common.scss
vendored
@ -512,6 +512,35 @@ body {
|
||||
padding-bottom: 0.8rem;
|
||||
border-bottom: 1px solid #eaecef;
|
||||
}
|
||||
|
||||
.apply-reasoning {
|
||||
margin: 0 0 12px 0;
|
||||
padding: 0 0 0 13px;
|
||||
line-height: 26px;
|
||||
position: relative;
|
||||
|
||||
&:before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
width: 2px;
|
||||
background-color: #e1e1e1;
|
||||
}
|
||||
|
||||
.reasoning-label {
|
||||
margin-bottom: 4px;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.reasoning-content {
|
||||
opacity: 0.5;
|
||||
> p:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2083,6 +2083,7 @@
|
||||
|
||||
.reasoning-label {
|
||||
margin-bottom: 4px;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.reasoning-content {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user