('.markdown');
+
+ if (!chatContent) {
+ return '';
+ }
+
+ const chatContentClone = chatContent.cloneNode(true) as HTMLDivElement;
+
+ const codeHeader = chatContentClone.querySelectorAll('.code-header');
+ codeHeader.forEach((childElement: any) => {
+ childElement.remove();
+ });
+
+ return `
+ ${avatar}
+ ${chatContentClone.outerHTML}
+
`;
+ });
+ const html = htmlTemplate.replace('{{CHAT_CONTENT}}', dom.join('\n'));
+ return html;
+ }, []);
+
+ const onclickExportHtml = useCallback(() => {
+ const html = getHistoryHtml();
+ html &&
+ fileDownload({
+ text: html,
+ type: 'text/html',
+ filename: '聊天记录.html'
+ });
+ }, [getHistoryHtml]);
+
+ const onclickExportPdf = useCallback(() => {
+ const html = getHistoryHtml();
+
+ html &&
+ // @ts-ignore
+ html2pdf(html, {
+ margin: 0,
+ filename: `聊天记录.pdf`
+ });
+ }, [getHistoryHtml]);
+
const RenderHistory = () => (
<>
{chatHistory.map((item) => (
@@ -145,7 +215,7 @@ const SlideBar = ({
onClick: () => void;
children: JSX.Element | string;
}) => (
-
+
}
onClick={() => resetChat()}
@@ -238,7 +308,33 @@ const SlideBar = ({
-
+
+
+ {history.length > 0 && (
+
+ )}
router.push('/')}>
<>
diff --git a/src/pages/chat/index.tsx b/src/pages/chat/index.tsx
index 9d7716b29..d1e21ef01 100644
--- a/src/pages/chat/index.tsx
+++ b/src/pages/chat/index.tsx
@@ -403,6 +403,7 @@ const Chat = ({ modelId, chatId }: { modelId: string; chatId: string }) => {
resetChat={resetChat}
chatId={chatId}
modelId={modelId}
+ history={chatData.history}
onClose={onCloseSlider}
/>
@@ -434,6 +435,7 @@ const Chat = ({ modelId, chatId }: { modelId: string; chatId: string }) => {
resetChat={resetChat}
chatId={chatId}
modelId={modelId}
+ history={chatData.history}
onClose={onCloseSlider}
/>
@@ -447,7 +449,15 @@ const Chat = ({ modelId, chatId }: { modelId: string; chatId: string }) => {
flexDirection={'column'}
>
{/* 聊天内容 */}
-
+
{chatData.history.map((item, index) => (
{
-
+
{item.obj === 'AI' ? (
) : (
- {item.value}
+
+ {item.value}
+
)}
{isPc && (
diff --git a/src/service/events/generateQA.ts b/src/service/events/generateQA.ts
index f911db5bd..aae049c9b 100644
--- a/src/service/events/generateQA.ts
+++ b/src/service/events/generateQA.ts
@@ -75,7 +75,7 @@ export async function generateQA(next = false): Promise {
role: 'system',
content: `你是出题人
${dataItem.prompt || '下面是"一段长文本"'}
-从中选出5至20个题目和答案,题目包含问答题,计算题,代码题等.答案要详细.按格式返回: Q1:
+从中选出5至20个题目和答案.答案详细.按格式返回: Q1:
A1:
Q2:
A2:
diff --git a/src/service/utils/openai.ts b/src/service/utils/openai.ts
index 0c079a518..689d00faa 100644
--- a/src/service/utils/openai.ts
+++ b/src/service/utils/openai.ts
@@ -90,7 +90,7 @@ export const openaiCreateEmbedding = async ({
)
.then((res) => ({
tokenLen: res.data.usage.total_tokens || 0,
- vector: res?.data?.data?.[0]?.embedding || []
+ vector: res.data.data?.[0]?.embedding || []
}));
pushGenerateVectorBill({