|
|
@@ -1,9 +1,9 @@
|
|
|
import { jsonParse, jsonStringify } from '../../utils/utils';
|
|
|
-import { formatStaticAssetsUrl } from '../../utils/utils';
|
|
|
+// import { formatStaticAssetsUrl } from '../../utils/utils';
|
|
|
import generateClientUniqueId from '../../utils/generate-client-unique-id';
|
|
|
|
|
|
import { formatCodePython, formatCodeSql } from './format-code-string';
|
|
|
-import formatAnwserString, { formatMarkdownString } from './format-anwser-string';
|
|
|
+// import formatAnwserString, { formatMarkdownString } from './format-anwser-string';
|
|
|
// import { formatFileDownloadStr } from './format-dialog-answer-custom-markdown-str';
|
|
|
import { getIcon4Answer } from './get-icon-4-dialog';
|
|
|
|
|
|
@@ -13,9 +13,15 @@ import {
|
|
|
formatFileDownloadStr
|
|
|
} from './format-dialog-answer-custom-markdown-str';
|
|
|
|
|
|
+import formatDialogAnswerAttachedHtmlBeforeRender from './format-dialog-answer-attached-html-before-render';
|
|
|
+
|
|
|
/**
|
|
|
* 格式化websocket发送消息的参数
|
|
|
* 此方法返回的数据项,为智能体返回的回答的数据
|
|
|
+ *
|
|
|
+ * 请注意,通常情况下,此文件改动,可能意味着 ./format-dialog-answer-from-history.js 文件也需要改动
|
|
|
+ * 此文件是针对 实时对话 进行的回答字符串的处理
|
|
|
+ * ./format-dialog-answer-from-history.js 文件是针对历史会话回答的字符串进行处理
|
|
|
* @param {string} message_str
|
|
|
* @param {object} preMsg - 前一次的消息,如果是流式消息,则需要上一次的Content进行拼接,从而形成新的消息
|
|
|
* @returns
|
|
|
@@ -232,11 +238,25 @@ export default function formatDialogAnswerFromWebsocketReceiveMessage(message_st
|
|
|
}
|
|
|
|
|
|
if (resFiles) {
|
|
|
+ // 历史记录也有此同样处理
|
|
|
// 文档合并有此数据
|
|
|
if (resFiles[0]) {
|
|
|
+ const fileInfo = resFiles[0];
|
|
|
+ const f_url = fileInfo.file_url;
|
|
|
+ const mock_url = `http://127.0.0.1${f_url}`;
|
|
|
+ const urlObj = new URL(mock_url);
|
|
|
+ const file_type = urlObj.searchParams.get('file_type');
|
|
|
+
|
|
|
+ let f_name = fileInfo.file_name;
|
|
|
+ if (file_type === 'word') {
|
|
|
+ f_name = f_name + '.docx';
|
|
|
+ } else {
|
|
|
+ // 对于非 word类型,未知文件名
|
|
|
+ }
|
|
|
+
|
|
|
currentMsg.client_custom_linked_download_files = {
|
|
|
- file_name: resFiles[0].file_name,
|
|
|
- file_url: resFiles[0].file_url
|
|
|
+ file_name: f_name,
|
|
|
+ file_url: fileInfo.file_url
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
@@ -314,37 +334,39 @@ export default function formatDialogAnswerFromWebsocketReceiveMessage(message_st
|
|
|
// ---------------------------------------------------------------
|
|
|
// ---------------------------------------------------------------
|
|
|
|
|
|
- /**
|
|
|
- * 在answer字符串渲染到界面之前,在answer后拼接的html字符串
|
|
|
- */
|
|
|
- let temp_html_str = '';
|
|
|
-
|
|
|
- // 处理python代码
|
|
|
- if (currentMsg.client_custom_linked_code) {
|
|
|
- temp_html_str = temp_html_str + currentMsg.client_custom_linked_code;
|
|
|
- }
|
|
|
-
|
|
|
- // 由于SQL和代码不能通过markdown解析,所以此处进行字符串的拼接
|
|
|
- if (currentMsg.client_custom_linked_sql) {
|
|
|
- temp_html_str = temp_html_str + currentMsg.client_custom_linked_sql;
|
|
|
- }
|
|
|
-
|
|
|
- // 处理图片展示
|
|
|
- if (currentMsg.client_custom_linked_image) {
|
|
|
- temp_html_str = temp_html_str + `<img src="${currentMsg.client_custom_linked_image}" />`;
|
|
|
- }
|
|
|
- // 拼接文件的下载链接
|
|
|
- if (currentMsg.client_custom_linked_download_files) {
|
|
|
- const file_name = currentMsg.client_custom_linked_download_files.file_name;
|
|
|
- const file_url = currentMsg.client_custom_linked_download_files.file_url;
|
|
|
- const download_file_str = formatFileDownloadStr(file_name, file_url);
|
|
|
- temp_html_str = temp_html_str + download_file_str;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 在answer字符串渲染到界面之前,在answer后拼接的html字符串
|
|
|
- */
|
|
|
- currentMsg.client_custom_attached_html_before_render = temp_html_str;
|
|
|
+ // /**
|
|
|
+ // * 在answer字符串渲染到界面之前,在answer后拼接的html字符串
|
|
|
+ // */
|
|
|
+ // let temp_html_str = '';
|
|
|
+
|
|
|
+ // // 处理python代码
|
|
|
+ // if (currentMsg.client_custom_linked_code) {
|
|
|
+ // temp_html_str = temp_html_str + currentMsg.client_custom_linked_code;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // // 由于SQL和代码不能通过markdown解析,所以此处进行字符串的拼接
|
|
|
+ // if (currentMsg.client_custom_linked_sql) {
|
|
|
+ // temp_html_str = temp_html_str + currentMsg.client_custom_linked_sql;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // // 处理图片展示
|
|
|
+ // if (currentMsg.client_custom_linked_image) {
|
|
|
+ // temp_html_str = temp_html_str + `<img src="${currentMsg.client_custom_linked_image}" />`;
|
|
|
+ // }
|
|
|
+ // // 拼接文件的下载链接
|
|
|
+ // if (currentMsg.client_custom_linked_download_files) {
|
|
|
+ // const file_name = currentMsg.client_custom_linked_download_files.file_name;
|
|
|
+ // const file_url = currentMsg.client_custom_linked_download_files.file_url;
|
|
|
+ // const download_file_str = formatFileDownloadStr(file_name, file_url);
|
|
|
+ // temp_html_str = temp_html_str + download_file_str;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // /**
|
|
|
+ // * 在answer字符串渲染到界面之前,在answer后拼接的html字符串
|
|
|
+ // */
|
|
|
+ // currentMsg.client_custom_attached_html_before_render = temp_html_str;
|
|
|
+
|
|
|
+ formatDialogAnswerAttachedHtmlBeforeRender(currentMsg);
|
|
|
|
|
|
return {
|
|
|
status: chat_status, // 本轮会话的状态:0 未开始 1 进行中 2 已结束 3 错误
|