| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- import {
- formatRefferenceString,
- formatRefferenceFlag,
- formatFileDownloadStr
- } from './format-dialog-answer-custom-markdown-str';
- /**
- * 拼接到智能体回复后面的html字符串
- * 智能体的回答,最终呈现到界面上,共有如下几个步骤:
- * 1. 智能体回复的markdown
- * 2. 将markdown解析为html文件
- * 3. 在解析后的html字符串后,拼接一些特殊情况下的其他html字符串
- *
- * 此方法所做的事情就是生成上述步骤3所需要的 特殊情况下的其他html字符串
- * 最终将该html字符串,赋给 client_custom_attached_html_before_render 属性
- * 在 ../conversation-item/DialogAnswer.vue 组件中,会进行上述步骤2和步骤3的处理
- * @param {object} currentMsg - 前一次的消息,如果是流式消息,则需要上一次的Content进行拼接,从而形成新的消息
- * @returns
- */
- export default function formatDialogAnswerAttachedHtmlBeforeRender(currentMsg) {
- /**
- * 在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) {
- temp_html_str = temp_html_str + `<div class="agent-answer-download-container"></div>`;
- // 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;
- return currentMsg;
- }
|