diff --git a/public/docs/chatProblem.md b/public/docs/chatProblem.md
index 9b46c72ef..baa8c22f4 100644
--- a/public/docs/chatProblem.md
+++ b/public/docs/chatProblem.md
@@ -1,9 +1,10 @@
-## 常见问题
+### 常见问题
+**请求次数太多了**
+一般是因为自己的 openai 账号异常。请先检查自己的账号是否正常使用。
**内容长度**
chatgpt 上下文最长 4096 tokens, 上下文超长时会报错。
-
**删除和复制**
-点击对话头像,可以选择复制或删除该条内容。
-
+电脑端:聊天内容右侧有复制和删除的图标。
+移动端:点击对话头像,可以选择复制或删除该条内容。
**代理出错**
-服务器代理不稳定,可以过一会儿再尝试。
\ No newline at end of file
+服务器代理不稳定,可以过一会儿再尝试。 或者可以访问国外服务器: [FastGpt](https://fastgpt.run/)
\ No newline at end of file
diff --git a/public/docs/versionIntro.md b/public/docs/versionIntro.md
index 50ea8b612..25345d437 100644
--- a/public/docs/versionIntro.md
+++ b/public/docs/versionIntro.md
@@ -1,3 +1,5 @@
-## Fast GPT V2.7
-* FastGpt Api 允许你将 Fast Gpt 的部分功能通过 api 的形式,将知识库接入到自己的应用中,例如:飞书、企业微信、客服助手.
-* 通过 csv 文件导入和导出你的问答对。你可以将你的 csv 文件放置在飞书文档上,以便团队共享。
\ No newline at end of file
+### Fast GPT V2.8.1
+* 优化 - 知识库升级,内容条数不上限!
+* 优化 - 导入去重效果,可防止导出后的 csv 重复导入。
+* 优化 - 聊天框,电脑端复制删除图标。
+* 优化 - 聊天框,生成内容时,如果滚动条触底,则会自动向下滚动,不需要手动下滑。
\ No newline at end of file
diff --git a/src/components/Icon/icons/delete.svg b/src/components/Icon/icons/delete.svg
new file mode 100644
index 000000000..60df09a4b
--- /dev/null
+++ b/src/components/Icon/icons/delete.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/components/Icon/index.tsx b/src/components/Icon/index.tsx
index 1e38406e8..a5be36b50 100644
--- a/src/components/Icon/index.tsx
+++ b/src/components/Icon/index.tsx
@@ -13,14 +13,23 @@ const map = {
board: require('./icons/board.svg').default,
develop: require('./icons/develop.svg').default,
user: require('./icons/user.svg').default,
- chatting: require('./icons/chatting.svg').default
+ chatting: require('./icons/chatting.svg').default,
+ delete: require('./icons/delete.svg').default
};
export type IconName = keyof typeof map;
const MyIcon = ({ name, w = 'auto', h = 'auto', ...props }: { name: IconName } & IconProps) => {
return map[name] ? (
-
+
) : null;
};
diff --git a/src/components/Markdown/index.tsx b/src/components/Markdown/index.tsx
index e5f140a43..51d6b977d 100644
--- a/src/components/Markdown/index.tsx
+++ b/src/components/Markdown/index.tsx
@@ -13,8 +13,8 @@ import styles from './index.module.scss';
import { codeLight } from './codeLight';
const Markdown = ({ source, isChatting = false }: { source: string; isChatting?: boolean }) => {
- const formatSource = useMemo(() => source, [source]);
const { copyData } = useCopyData();
+ const formatSource = useMemo(() => source, [source]);
return (
('modelData', {
fields: ['id', 'q', 'a', 'status'],
- where: [['user_id', userId], 'AND', ['model_id', modelId]],
+ where,
order: [{ field: 'id', mode: 'DESC' }],
limit: pageSize,
offset: pageSize * (pageNum - 1)
@@ -50,7 +57,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
pageSize,
data: searchRes.rows,
total: await PgClient.count('modelData', {
- where: [['user_id', userId], 'AND', ['model_id', modelId]]
+ where
})
}
});
diff --git a/src/pages/chat/index.tsx b/src/pages/chat/index.tsx
index 46ce72277..c93b16f53 100644
--- a/src/pages/chat/index.tsx
+++ b/src/pages/chat/index.tsx
@@ -28,7 +28,8 @@ import { useChatStore } from '@/store/chat';
import { useCopyData } from '@/utils/tools';
import { streamFetch } from '@/api/fetch';
import Icon from '@/components/Icon';
-import { modelList } from '@/constants/model';
+import MyIcon from '@/components/Icon';
+import { throttle } from 'lodash';
const SlideBar = dynamic(() => import('./components/SlideBar'));
const Empty = dynamic(() => import('./components/Empty'));
@@ -73,16 +74,28 @@ const Chat = ({ chatId }: { chatId: string }) => {
const { pushChatHistory } = useChatStore();
// 滚动到底部
- const scrollToBottom = useCallback(() => {
- setTimeout(() => {
- ChatBox.current &&
- ChatBox.current.scrollTo({
- top: ChatBox.current.scrollHeight,
- behavior: 'smooth'
- });
- }, 100);
+ const scrollToBottom = useCallback((behavior: 'smooth' | 'auto' = 'smooth') => {
+ if (!ChatBox.current) return;
+ ChatBox.current.scrollTo({
+ top: ChatBox.current.scrollHeight,
+ behavior
+ });
}, []);
+ // 聊天信息生成中……获取当前滚动条位置,判断是否需要滚动到底部
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ const generatingMessage = useCallback(
+ throttle(() => {
+ if (!ChatBox.current) return;
+ const isBottom =
+ ChatBox.current.scrollTop + ChatBox.current.clientHeight + 50 >=
+ ChatBox.current.scrollHeight;
+
+ isBottom && scrollToBottom('auto');
+ }, 100),
+ []
+ );
+
// 重置输入内容
const resetInputVal = useCallback((val: string) => {
setInputVal(val);
@@ -141,6 +154,7 @@ const Chat = ({ chatId }: { chatId: string }) => {
};
})
}));
+ generatingMessage();
},
abortSignal: controller.current
});
@@ -178,7 +192,7 @@ const Chat = ({ chatId }: { chatId: string }) => {
})
}));
},
- [chatData.modelName, chatId, toast]
+ [chatData.modelName, chatId, generatingMessage, toast]
);
/**
@@ -226,7 +240,9 @@ const Chat = ({ chatId }: { chatId: string }) => {
// 清空输入内容
resetInputVal('');
- scrollToBottom();
+ setTimeout(() => {
+ scrollToBottom();
+ }, 100);
try {
await gptChatPrompt(newChatList[newChatList.length - 2]);
@@ -313,8 +329,8 @@ const Chat = ({ chatId }: { chatId: string }) => {
});
if (res.history.length > 0) {
setTimeout(() => {
- scrollToBottom();
- }, 500);
+ scrollToBottom('auto');
+ }, 2000);
}
},
onError(e: any) {
@@ -340,6 +356,7 @@ const Chat = ({ chatId }: { chatId: string }) => {
controller.current?.abort();
};
}, [chatId]);
+
return (
{
{item.value}
)}
+ {isPc && (
+
+
+ onclickCopy(item.value)}
+ />
+
+ delChatRecord(index)}
+ />
+
+ )}
))}