Skip to content

Commit 9415e22

Browse files
authored
v4.2 (#217)
* fix: chat module link * fix: url fetch check * fix: import file ui * feat: app logs * perf: iframe icon * imgs cdn * perf: click range and pg
1 parent 2b50dac commit 9415e22

File tree

30 files changed

+506
-63
lines changed

30 files changed

+506
-63
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ FastGPT 是一个基于 LLM 大语言模型的知识库问答系统,提供开
4747
- [x] 支持直接分段导入
4848
- [x] 支持 QA 拆分导入
4949
- [x] 支持手动输入内容
50-
- [ ] 支持 url 读取导入
50+
- [x] 支持 url 读取导入
5151
- [x] 支持 CSV 批量导入问答对
5252
- [ ] 支持知识库单独设置向量模型
5353
- [ ] 源文件存储

client/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
"@dqbd/tiktoken": "^1.0.7",
1616
"@emotion/react": "^11.10.6",
1717
"@emotion/styled": "^11.10.6",
18+
"@mozilla/readability": "^0.4.4",
1819
"@next/font": "13.1.6",
1920
"@tanstack/react-query": "^4.24.10",
2021
"@types/nprogress": "^0.2.0",
21-
"@mozilla/readability": "^0.4.4",
2222
"axios": "^1.3.3",
2323
"cookie": "^0.5.0",
2424
"crypto": "^1.0.1",
@@ -31,6 +31,7 @@
3131
"i18next": "^22.5.1",
3232
"immer": "^9.0.19",
3333
"js-cookie": "^3.0.5",
34+
"jsdom": "^22.1.0",
3435
"jsonwebtoken": "^9.0.0",
3536
"lodash": "^4.17.21",
3637
"mammoth": "^1.5.1",
@@ -59,7 +60,6 @@
5960
"request-ip": "^3.3.0",
6061
"sass": "^1.58.3",
6162
"tunnel": "^0.0.6",
62-
"jsdom": "^22.1.0",
6363
"winston": "^3.10.0",
6464
"winston-mongodb": "^5.1.1",
6565
"zustand": "^4.3.5"
@@ -69,6 +69,7 @@
6969
"@types/cookie": "^0.5.1",
7070
"@types/formidable": "^2.0.5",
7171
"@types/js-cookie": "^3.0.3",
72+
"@types/jsdom": "^21.1.1",
7273
"@types/jsonwebtoken": "^9.0.1",
7374
"@types/lodash": "^4.14.191",
7475
"@types/node": "18.14.0",
@@ -79,7 +80,6 @@
7980
"@types/react-syntax-highlighter": "^15.5.6",
8081
"@types/request-ip": "^0.0.37",
8182
"@types/tunnel": "^0.0.3",
82-
"@types/jsdom": "^21.1.1",
8383
"eslint": "8.34.0",
8484
"eslint-config-next": "13.1.6",
8585
"typescript": "4.9.5"

client/public/docs/versionIntro.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
### Fast GPT V4.1
1+
### Fast GPT V4.2
22

3-
1. 新增 - 高级编排导入导出功能
4-
2. 优化对话存储结构
5-
3. 优化日志存储
6-
4. [点击查看高级编排介绍文档](https://doc.fastgpt.run/docs/workflow)
7-
5. 填写个人 OpenAI 账号后,分享和 API 功能也不会走平台余额扣费。
3+
1. 新增 - 应用日志初版,可观测到所有对话记录
4+
2. 新增 - 好友邀请链接,[点击查看](/account?currentTab=promotion)
5+
3. 新增 - Iframe 嵌入页面图标可拖拽
6+
4. 优化 - 知识库搜索提示词
7+
5. 优化 - [使用文档](https://doc.fastgpt.run/docs/intro/)
8+
6. [点击查看高级编排介绍文档](https://doc.fastgpt.run/docs/workflow)

client/public/js/iframe.js

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ async function embedChatbot() {
2020
const ChatBtn = document.createElement('div');
2121
ChatBtn.id = chatBtnId;
2222
ChatBtn.style.cssText =
23-
'position: fixed; bottom: 1rem; right: 1rem; width: 40px; height: 40px; cursor: pointer; z-index: 2147483647; ';
23+
'position: fixed; bottom: 1rem; right: 1rem; width: 40px; height: 40px; cursor: pointer; z-index: 2147483647; transition: 0;';
2424

2525
const ChatBtnDiv = document.createElement('div');
26-
ChatBtnDiv.style.cssText =
27-
'transition: all 0.2s ease-in-out 0s; left: unset; transform: scale(1); :hover {transform: scale(1.1);} display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; z-index: 9999;';
2826
ChatBtnDiv.innerHTML = MessageIcon;
2927

3028
const iframe = document.createElement('iframe');
@@ -38,7 +36,15 @@ async function embedChatbot() {
3836

3937
document.body.appendChild(iframe);
4038

39+
let chatBtnDragged = false;
40+
let chatBtnDown = false;
41+
let chatBtnMouseX;
42+
let chatBtnMouseY;
4143
ChatBtn.addEventListener('click', function () {
44+
if (chatBtnDragged) {
45+
chatBtnDragged = false;
46+
return;
47+
}
4248
const chatWindow = document.getElementById(chatWindowId);
4349

4450
if (!chatWindow) return;
@@ -52,6 +58,31 @@ async function embedChatbot() {
5258
}
5359
});
5460

61+
ChatBtn.addEventListener('mousedown', (e) => {
62+
if (!chatBtnMouseX && !chatBtnMouseY) {
63+
chatBtnMouseX = e.clientX;
64+
chatBtnMouseY = e.clientY;
65+
}
66+
67+
chatBtnDown = true;
68+
});
69+
ChatBtn.addEventListener('mousemove', (e) => {
70+
if (!chatBtnDown) return;
71+
chatBtnDragged = true;
72+
const transformX = e.clientX - chatBtnMouseX;
73+
const transformY = e.clientY - chatBtnMouseY;
74+
75+
ChatBtn.style.transform = `translate3d(${transformX}px, ${transformY}px, 0)`;
76+
77+
e.stopPropagation();
78+
});
79+
ChatBtn.addEventListener('mouseup', (e) => {
80+
chatBtnDown = false;
81+
});
82+
ChatBtn.addEventListener('mouseleave', (e) => {
83+
chatBtnDown = false;
84+
});
85+
5586
ChatBtn.appendChild(ChatBtnDiv);
5687
document.body.appendChild(ChatBtn);
5788
}

client/public/locales/en/common.json

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
"Confirm": "Yes",
55
"Running": "Running",
66
"Warning": "Warning",
7+
"UnKnow": "UnKnow",
78
"app": {
89
"Advance App TestTip": "The current application is advanced editing mode \n. If you need to switch to [simple mode], please click the save button on the left",
910
"App Detail": "App Detail",
11+
"Chat Logs Tips": "Logs record the app's online, shared, and API conversations",
12+
"Chat logs": "Chat Logs",
1013
"Confirm Del App Tip": "Confirm to delete the app and all its chats",
1114
"Confirm Save App Tip": "The application may be in advanced orchestration mode, and the advanced orchestration configuration will be overwritten after saving, please confirm!",
1215
"Connection is invalid": "Connecting is invalid",
@@ -18,6 +21,11 @@
1821
"Import Config Failed": "Failed to import the configuration, please ensure that the configuration is normal!",
1922
"Import Configs": "Import Configs",
2023
"Input Field Settings": "Input Field Settings",
24+
"Logs Empty": "Logs is empty",
25+
"Logs Message Total": "Message Count",
26+
"Logs Source": "Source",
27+
"Logs Time": "Time",
28+
"Logs Title": "Title",
2129
"My Apps": "My Apps",
2230
"Output Field Settings": "Output Field Settings",
2331
"Paste Config": "Paste Config"
@@ -28,7 +36,13 @@
2836
"Exit Chat": "Exit",
2937
"History": "History",
3038
"New Chat": "New Chat",
31-
"You need to a chat app": "You need to a chat app"
39+
"You need to a chat app": "You need to a chat app",
40+
"logs": {
41+
"api": "API",
42+
"online": "Online Chat",
43+
"share": "Share",
44+
"test": "Test Chat "
45+
}
3246
},
3347
"commom": {
3448
"Password inconsistency": "Password inconsistency"
@@ -149,6 +163,10 @@
149163
"Update Password": "Update Password",
150164
"Update password failed": "Update password failed",
151165
"Update password succseful": "Update password succseful",
152-
"Usage Record": "Usage"
166+
"Usage Record": "Usage",
167+
"promotion": {
168+
"pay": "",
169+
"register": ""
170+
}
153171
}
154172
}

client/public/locales/zh/common.json

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
"Confirm": "确认",
55
"Running": "运行中",
66
"Warning": "提示",
7+
"UnKnow": "未知",
78
"app": {
89
"Advance App TestTip": "当前应用为高级编排模式\n如需切换为【简易模式】请点击左侧保存按键",
910
"App Detail": "应用详情",
11+
"Chat Logs Tips": "日志会记录该应用的在线、分享和 API 对话记录",
12+
"Chat logs": "对话日志",
1013
"Confirm Del App Tip": "确认删除该应用及其所有聊天记录?",
1114
"Confirm Save App Tip": "该应用可能为高级编排模式,保存后将会覆盖高级编排配置,请确认!",
1215
"Connection is invalid": "连接无效",
@@ -18,6 +21,11 @@
1821
"Import Config Failed": "导入配置失败,请确保配置正常!",
1922
"Import Configs": "导入配置",
2023
"Input Field Settings": "输入字段编辑",
24+
"Logs Empty": "还没有日志噢~",
25+
"Logs Message Total": "消息总数",
26+
"Logs Source": "来源",
27+
"Logs Time": "时间",
28+
"Logs Title": "标题",
2129
"My Apps": "我的应用",
2230
"Output Field Settings": "输出字段编辑",
2331
"Paste Config": "粘贴配置"
@@ -28,7 +36,13 @@
2836
"Exit Chat": "退出聊天",
2937
"History": "记录",
3038
"New Chat": "新对话",
31-
"You need to a chat app": "你需要创建一个应用"
39+
"You need to a chat app": "你需要创建一个应用",
40+
"logs": {
41+
"api": "API 调用",
42+
"online": "在线使用",
43+
"share": "外部链接调用",
44+
"test": "测试"
45+
}
3246
},
3347
"commom": {
3448
"Password inconsistency": "两次密码不一致"
@@ -151,8 +165,8 @@
151165
"Update password succseful": "修改密码成功",
152166
"Usage Record": "使用记录",
153167
"promotion": {
154-
"register": "好友注册",
155-
"pay": "好友充值"
168+
"pay": "好友充值",
169+
"register": "好友注册"
156170
}
157171
}
158172
}

client/src/api/app.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,6 @@ export const getAppTotalUsage = (data: { appId: string }) =>
5151
start: addDays(new Date(), -13),
5252
end: addDays(new Date(), 1)
5353
}).then((res) => (res.length === 0 ? [{ date: new Date(), total: 0 }] : res));
54+
55+
export const getAppChatLogs = (data: RequestPaging & { appId: string }) =>
56+
POST(`/chat/getChatLogs`, data);

client/src/components/ChatBox/QuoteModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ const QuoteModal = ({
9696
_notLast={{ mb: 2 }}
9797
position={'relative'}
9898
_hover={{ '& .edit': { display: 'flex' } }}
99+
overflow={'hidden'}
99100
>
100101
{item.source && <Box color={'myGray.600'}>({item.source})</Box>}
101102
<Box>{item.q}</Box>

client/src/components/ChatBox/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ const ChatBox = (
141141
variableModules?: VariableItemType[];
142142
welcomeText?: string;
143143
onUpdateVariable?: (e: Record<string, any>) => void;
144-
onStartChat: (e: StartChatFnProps) => Promise<{
144+
onStartChat?: (e: StartChatFnProps) => Promise<{
145145
responseText: string;
146146
[TaskResponseKeyEnum.responseData]: ChatHistoryItemResType[];
147147
}>;
@@ -239,8 +239,7 @@ const ChatBox = (
239239
// 复制内容
240240
const onclickCopy = useCallback(
241241
(value: string) => {
242-
const val = value.replace(/\n+/g, '\n');
243-
copyData(val);
242+
copyData(value);
244243
},
245244
[copyData]
246245
);
@@ -264,6 +263,7 @@ const ChatBox = (
264263
*/
265264
const sendPrompt = useCallback(
266265
async (variables: Record<string, any> = {}, inputVal = '') => {
266+
if (!onStartChat) return;
267267
if (isChatting) {
268268
toast({
269269
title: '正在聊天中...请等待结束',
@@ -272,7 +272,7 @@ const ChatBox = (
272272
return;
273273
}
274274
// get input value
275-
const val = inputVal.trim().replace(/\n\s*/g, '\n');
275+
const val = inputVal.trim();
276276

277277
if (!val) {
278278
toast({
@@ -698,7 +698,7 @@ const ChatBox = (
698698
</Box>
699699
</Box>
700700
{/* input */}
701-
{variableIsFinish ? (
701+
{onStartChat && variableIsFinish ? (
702702
<Box m={['0 auto', '10px auto']} w={'100%'} maxW={['auto', 'min(750px, 100%)']} px={[0, 5]}>
703703
<Box
704704
py={'18px'}
Lines changed: 14 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)