Commit c865fc04 authored by 水玉婷's avatar 水玉婷
Browse files

feat:md模版

parent 7d91f005
...@@ -304,12 +304,50 @@ export class ContentTemplateService { ...@@ -304,12 +304,50 @@ export class ContentTemplateService {
thinkBoxExpanded: false, thinkBoxExpanded: false,
}); });
} else { } else {
// 走选项
updatedResponse.contentBlocks.push({ updatedResponse.contentBlocks.push({
content: this.templates.option({ content: this.templates.option(messageContent),
tips, hasThinkBox: false,
options, thinkContent: '',
}), thinkBoxExpanded: false,
});
}
}
break;
case 4: // MD格式
if (updatedResponse) {
// 对于SSE流式数据,使用流式处理
const markdownContent = templateTools?.markdownTemplate ?
templateTools.markdownTemplate(messageContent || '', true) :
this.templates.markdown(messageContent || '', true);
// 检查最后一个块是否是markdown块
const isLastMarkdown = templateTools?.isLastBlockMarkdown ?
templateTools.isLastBlockMarkdown(updatedResponse.contentBlocks) :
isLastBlockMarkdown(updatedResponse.contentBlocks);
if (isLastMarkdown) {
// 合并到现有的markdown块
const lastMarkdownIndex = templateTools?.getLastMarkdownBlockIndex ?
templateTools.getLastMarkdownBlockIndex(updatedResponse.contentBlocks) :
getLastMarkdownBlockIndex(updatedResponse.contentBlocks);
if (lastMarkdownIndex !== -1) {
updatedResponse.contentBlocks[lastMarkdownIndex].content =
templateTools?.mergeMarkdownContent ?
templateTools.mergeMarkdownContent(
updatedResponse.contentBlocks[lastMarkdownIndex].content,
markdownContent
) :
mergeMarkdownContent(
updatedResponse.contentBlocks[lastMarkdownIndex].content,
markdownContent
);
}
} else {
// 创建新的markdown块
updatedResponse.contentBlocks.push({
content: markdownContent,
hasThinkBox: false, hasThinkBox: false,
thinkContent: '', thinkContent: '',
thinkBoxExpanded: false, thinkBoxExpanded: false,
...@@ -317,10 +355,20 @@ export class ContentTemplateService { ...@@ -317,10 +355,20 @@ export class ContentTemplateService {
} }
} }
break; break;
default: // 默认处理
updatedResponse.contentBlocks.push({
content: this.templates.text(messageContent || ''),
hasThinkBox: false,
thinkContent: '',
thinkBoxExpanded: false,
});
break;
} }
} }
break; break;
case 10: // 思考开始 case 10: // 思考开始
updatedIsThinking = true; updatedIsThinking = true;
// 记录思考开始时间 // 记录思考开始时间
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment