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)) {
|
if (empty($size)) {
|
||||||
return Base::retError('消息发送保存失败');
|
return Base::retError('消息发送保存失败');
|
||||||
}
|
}
|
||||||
$ext = $markdown ? 'md' : 'htm';
|
$type = $markdown ? 'md' : 'htm';
|
||||||
$text = MsgTool::truncateText($text, 500, $ext);
|
$desc = $text;
|
||||||
$desc = strip_tags($markdown ? Base::markdown2html($text) : $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);
|
$desc = mb_substr(WebSocketDialogMsg::filterEscape($desc), 0, 200);
|
||||||
|
$text = MsgTool::truncateText($text, 500, $type);
|
||||||
$msgData = [
|
$msgData = [
|
||||||
|
'type' => $type, // 内容类型
|
||||||
'desc' => $desc, // 描述内容
|
'desc' => $desc, // 描述内容
|
||||||
'text' => $text, // 简要内容
|
'text' => $text, // 简要内容
|
||||||
'type' => $ext, // 内容类型
|
|
||||||
'file' => [
|
'file' => [
|
||||||
'name' => "LongText-{$strlen}.{$ext}",
|
'name' => "LongText-{$strlen}.{$type}",
|
||||||
'size' => $size,
|
'size' => $size,
|
||||||
'file' => $file,
|
'file' => $file,
|
||||||
'path' => $path,
|
'path' => $path,
|
||||||
@ -1119,7 +1124,7 @@ class DialogController extends AbstractController
|
|||||||
'thumb' => '',
|
'thumb' => '',
|
||||||
'width' => -1,
|
'width' => -1,
|
||||||
'height' => -1,
|
'height' => -1,
|
||||||
'ext' => $ext,
|
'ext' => $type,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
if (empty($key)) {
|
if (empty($key)) {
|
||||||
|
|||||||
@ -764,9 +764,15 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
$key = '';
|
$key = '';
|
||||||
switch ($this->type) {
|
switch ($this->type) {
|
||||||
case 'text':
|
case 'text':
|
||||||
if (!preg_match("/<span[^>]*?data-quick-key=([\"'])([^\"']+?)\\1[^>]*?>/is", $this->msg['text'])) {
|
if (preg_match("/<span[^>]*?data-quick-key=([\"'])([^\"']+?)\\1[^>]*?>/i", $this->msg['text'])) {
|
||||||
$key = strip_tags($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;
|
break;
|
||||||
|
|
||||||
case 'vote':
|
case 'vote':
|
||||||
@ -1144,6 +1150,7 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
}
|
}
|
||||||
//
|
//
|
||||||
$updateData = [
|
$updateData = [
|
||||||
|
'type' => $type,
|
||||||
'mtype' => $mtype,
|
'mtype' => $mtype,
|
||||||
'link' => $link,
|
'link' => $link,
|
||||||
'msg' => array_merge($oldMsg, $msg),
|
'msg' => array_merge($oldMsg, $msg),
|
||||||
|
|||||||
@ -173,6 +173,7 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
REDIS_HOST: "${REDIS_HOST}"
|
REDIS_HOST: "${REDIS_HOST}"
|
||||||
REDIS_PORT: "${REDIS_PORT}"
|
REDIS_PORT: "${REDIS_PORT}"
|
||||||
|
TIMEOUT: 600
|
||||||
networks:
|
networks:
|
||||||
extnetwork:
|
extnetwork:
|
||||||
ipv4_address: "${APP_IPPR}.12"
|
ipv4_address: "${APP_IPPR}.12"
|
||||||
|
|||||||
@ -194,8 +194,9 @@ server {
|
|||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_buffering off;
|
proxy_buffering off;
|
||||||
proxy_cache off;
|
proxy_cache off;
|
||||||
proxy_read_timeout 300s;
|
proxy_read_timeout 3600s;
|
||||||
proxy_send_timeout 300s;
|
proxy_send_timeout 3600s;
|
||||||
|
proxy_connect_timeout 3600s;
|
||||||
proxy_set_header Scheme $scheme;
|
proxy_set_header Scheme $scheme;
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
proxy_set_header Connection $connection_upgrade;
|
proxy_set_header Connection $connection_upgrade;
|
||||||
|
|||||||
@ -32,28 +32,25 @@ if (languageName === "zh" || languageName === "zh-CHT") {
|
|||||||
|
|
||||||
// Katex
|
// Katex
|
||||||
import createKatexPlugin from '@kangc/v-md-editor/lib/plugins/katex/cdn';
|
import createKatexPlugin from '@kangc/v-md-editor/lib/plugins/katex/cdn';
|
||||||
|
|
||||||
VMdPreview.use(createKatexPlugin());
|
VMdPreview.use(createKatexPlugin());
|
||||||
|
|
||||||
// Mermaid
|
// Mermaid
|
||||||
import createMermaidPlugin from '@kangc/v-md-editor/lib/plugins/mermaid/cdn';
|
import createMermaidPlugin from '@kangc/v-md-editor/lib/plugins/mermaid/cdn';
|
||||||
import '@kangc/v-md-editor/lib/plugins/mermaid/mermaid.css';
|
import '@kangc/v-md-editor/lib/plugins/mermaid/mermaid.css';
|
||||||
|
|
||||||
VMdPreview.use(createMermaidPlugin());
|
VMdPreview.use(createMermaidPlugin());
|
||||||
|
|
||||||
// TodoList
|
// TodoList
|
||||||
import createTodoListPlugin from '@kangc/v-md-editor/lib/plugins/todo-list/index';
|
import createTodoListPlugin from '@kangc/v-md-editor/lib/plugins/todo-list/index';
|
||||||
import '@kangc/v-md-editor/lib/plugins/todo-list/todo-list.css';
|
import '@kangc/v-md-editor/lib/plugins/todo-list/todo-list.css';
|
||||||
|
|
||||||
VMdPreview.use(createTodoListPlugin());
|
VMdPreview.use(createTodoListPlugin());
|
||||||
|
|
||||||
// CopyCode
|
// CopyCode
|
||||||
import createCopyCodePlugin from '@kangc/v-md-editor/lib/plugins/copy-code/index';
|
import createCopyCodePlugin from '@kangc/v-md-editor/lib/plugins/copy-code/index';
|
||||||
import '@kangc/v-md-editor/lib/plugins/copy-code/copy-code.css';
|
import '@kangc/v-md-editor/lib/plugins/copy-code/copy-code.css';
|
||||||
|
|
||||||
VMdPreview.use(createCopyCodePlugin());
|
VMdPreview.use(createCopyCodePlugin());
|
||||||
|
|
||||||
import {previewMixin} from "../mixin";
|
import {previewMixin} from "../mixin";
|
||||||
|
import {MarkdownPluginUtils} from "../../../store/markdown";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [previewMixin],
|
mixins: [previewMixin],
|
||||||
@ -68,6 +65,7 @@ export default {
|
|||||||
extend(md) {
|
extend(md) {
|
||||||
// md为 markdown-it 实例,可以在此处进行修改配置,并使用 plugin 进行语法扩展
|
// md为 markdown-it 实例,可以在此处进行修改配置,并使用 plugin 进行语法扩展
|
||||||
// md.set(option).use(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) {
|
export function MarkdownConver(text) {
|
||||||
if (text === '...') {
|
if (text === '...') {
|
||||||
return '<div class="input-blink"></div>'
|
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;
|
padding-bottom: 0.8rem;
|
||||||
border-bottom: 1px solid #eaecef;
|
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 {
|
.reasoning-label {
|
||||||
margin-bottom: 4px;
|
margin-bottom: 4px;
|
||||||
|
opacity: 0.9;
|
||||||
}
|
}
|
||||||
|
|
||||||
.reasoning-content {
|
.reasoning-content {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user