Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
3a911c51
authored
Apr 28, 2025
by
heheer
Committed by
GitHub
Apr 28, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix chat log list api (#4700)
parent
433e7ed9
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
112 additions
and
45 deletions
+112
-45
packages/web/i18n/en/chat.json
+1
-0
packages/web/i18n/zh-CN/chat.json
+1
-0
packages/web/i18n/zh-Hant/chat.json
+1
-0
projects/app/src/components/core/chat/ChatContainer/ChatBox/components/ChatItem.tsx
+19
-1
projects/app/src/pages/api/core/app/getChatLogs.ts
+90
-44
No files found.
packages/web/i18n/en/chat.json
View file @
3a911c51
...
...
@@ -6,6 +6,7 @@
"back_to_text"
:
"Text input"
,
"chat.quote.No Data"
:
"The file cannot be found"
,
"chat.quote.deleted"
:
"This data has been deleted ~"
,
"chat.waiting_for_response"
:
"Please wait for the conversation to complete"
,
"chat_history"
:
"Conversation History"
,
"chat_input_guide_lexicon_is_empty"
:
"Lexicon not configured yet"
,
"chat_test_app"
:
"Debug-{{name}}"
,
...
...
packages/web/i18n/zh-CN/chat.json
View file @
3a911c51
...
...
@@ -6,6 +6,7 @@
"back_to_text"
:
"返回输入"
,
"chat.quote.No Data"
:
"找不到该文件"
,
"chat.quote.deleted"
:
"该数据已被删除~"
,
"chat.waiting_for_response"
:
"请等待对话完成"
,
"chat_history"
:
"聊天记录"
,
"chat_input_guide_lexicon_is_empty"
:
"还没有配置词库"
,
"chat_test_app"
:
"调试-{{name}}"
,
...
...
packages/web/i18n/zh-Hant/chat.json
View file @
3a911c51
...
...
@@ -6,6 +6,7 @@
"back_to_text"
:
"返回輸入"
,
"chat.quote.No Data"
:
"找不到該文件"
,
"chat.quote.deleted"
:
"該資料已被刪除~"
,
"chat.waiting_for_response"
:
"請等待對話完成"
,
"chat_history"
:
"對話紀錄"
,
"chat_input_guide_lexicon_is_empty"
:
"尚未設定詞彙庫"
,
"chat_test_app"
:
"除錯-{{name}}"
,
...
...
projects/app/src/components/core/chat/ChatContainer/ChatBox/components/ChatItem.tsx
View file @
3a911c51
...
...
@@ -28,6 +28,7 @@ import dayjs from 'dayjs';
import
{
ChatItemContext
}
from
'@/web/core/chat/context/chatItemContext'
;
import
{
eventBus
,
EventNameEnum
}
from
'@/web/common/utils/eventbus'
;
import
{
addStatisticalDataToHistoryItem
}
from
'@/global/core/chat/utils'
;
import
{
useToast
}
from
'@fastgpt/web/hooks/useToast'
;
const
colorMap
=
{
[
ChatStatusEnum
.
loading
]:
{
...
...
@@ -117,6 +118,7 @@ const ChatItem = (props: Props) => {
const
{
type
,
avatar
,
statusBoxData
,
children
,
isLastChild
,
questionGuides
=
[],
chat
}
=
props
;
const
{
isPc
}
=
useSystem
();
const
{
toast
}
=
useToast
();
const
styleMap
:
BoxProps
=
{
...(
type
===
ChatRoleEnum
.
Human
...
...
@@ -237,6 +239,11 @@ const ChatItem = (props: Props) => {
quoteId
?:
string
;
})
=>
{
if
(
!
setQuoteData
)
return
;
if
(
isChatting
)
return
toast
({
title
:
t
(
'chat:chat.waiting_for_response'
),
status
:
'info'
});
const
collectionIdList
=
collectionId
?
[
collectionId
]
...
...
@@ -269,7 +276,18 @@ const ChatItem = (props: Props) => {
}
});
},
[
setQuoteData
,
quoteList
,
isShowReadRawSource
,
appId
,
chatId
,
chat
.
dataId
,
outLinkAuthData
]
[
setQuoteData
,
isChatting
,
toast
,
t
,
quoteList
,
isShowReadRawSource
,
appId
,
chatId
,
chat
.
dataId
,
outLinkAuthData
]
);
useEffect
(()
=>
{
...
...
projects/app/src/pages/api/core/app/getChatLogs.ts
View file @
3a911c51
...
...
@@ -57,9 +57,6 @@ async function handler(
{
$match
:
where
},
{
$sort
:
{
userBadFeedbackCount
:
-
1
,
userGoodFeedbackCount
:
-
1
,
customFeedbacksCount
:
-
1
,
updateTime
:
-
1
}
},
...
...
@@ -68,68 +65,117 @@ async function handler(
{
$lookup
:
{
from
:
ChatItemCollectionName
,
let
:
{
chatId
:
'$chatId'
},
let
:
{
chatId
:
'$chatId'
,
appId
:
new
Types
.
ObjectId
(
appId
)
},
pipeline
:
[
{
$match
:
{
$expr
:
{
$and
:
[{
$eq
:
[
'$appId'
,
'$$appId'
]
},
{
$eq
:
[
'$chatId'
,
'$$chatId'
]
}]
}
}
},
{
$count
:
'messageCount'
}
],
as
:
'messageCountData'
}
},
{
$lookup
:
{
from
:
ChatItemCollectionName
,
let
:
{
chatId
:
'$chatId'
,
appId
:
new
Types
.
ObjectId
(
appId
)
},
pipeline
:
[
{
$match
:
{
$expr
:
{
$and
:
[
{
$eq
:
[
'$appId'
,
'$$appId'
]
},
{
$eq
:
[
'$chatId'
,
'$$chatId'
]
},
{
$eq
:
[
'$userGoodFeedback'
,
true
]
}
]
}
}
},
{
$count
:
'count'
}
],
as
:
'userGoodFeedbackData'
}
},
{
$lookup
:
{
from
:
ChatItemCollectionName
,
let
:
{
chatId
:
'$chatId'
,
appId
:
new
Types
.
ObjectId
(
appId
)
},
pipeline
:
[
{
$match
:
{
$expr
:
{
$and
:
[
{
$eq
:
[
'$appId'
,
'$$appId'
]
},
{
$eq
:
[
'$chatId'
,
'$$chatId'
]
},
{
$eq
:
[
'$userBadFeedback'
,
true
]
}
]
}
}
},
{
$count
:
'count'
}
],
as
:
'userBadFeedbackData'
}
},
{
$lookup
:
{
from
:
ChatItemCollectionName
,
let
:
{
chatId
:
'$chatId'
,
appId
:
new
Types
.
ObjectId
(
appId
)
},
pipeline
:
[
{
$match
:
{
$expr
:
{
$and
:
[
{
$eq
:
[
'$appId'
,
new
Types
.
ObjectId
(
appId
)]
},
{
$eq
:
[
'$chatId'
,
'$$chatId'
]
}
{
$eq
:
[
'$appId'
,
'$$appId'
]
},
{
$eq
:
[
'$chatId'
,
'$$chatId'
]
},
{
$gt
:
[{
$size
:
{
$ifNull
:
[
'$customFeedbacks'
,
[]]
}
},
0
]
}
]
}
}
},
{
$count
:
'count'
}
],
as
:
'customFeedbacksData'
}
},
{
$lookup
:
{
from
:
ChatItemCollectionName
,
let
:
{
chatId
:
'$chatId'
,
appId
:
new
Types
.
ObjectId
(
appId
)
},
pipeline
:
[
{
$project
:
{
userGoodFeedback
:
1
,
userBadFeedback
:
1
,
customFeedbacks
:
1
,
adminFeedback
:
1
$match
:
{
$expr
:
{
$and
:
[
{
$eq
:
[
'$appId'
,
'$$appId'
]
},
{
$eq
:
[
'$chatId'
,
'$$chatId'
]
},
{
$eq
:
[
'$adminFeedback'
,
true
]
}
]
}
}
}
},
{
$count
:
'count'
}
],
as
:
'
chatitems
'
as
:
'
markData
'
}
},
{
$addFields
:
{
userGoodFeedbackCount
:
{
$size
:
{
$filter
:
{
input
:
'$chatitems'
,
as
:
'item'
,
cond
:
{
$ifNull
:
[
'$$item.userGoodFeedback'
,
false
]
}
}
}
$ifNull
:
[{
$arrayElemAt
:
[
'$userGoodFeedbackData.count'
,
0
]
},
0
]
},
userBadFeedbackCount
:
{
$size
:
{
$filter
:
{
input
:
'$chatitems'
,
as
:
'item'
,
cond
:
{
$ifNull
:
[
'$$item.userBadFeedback'
,
false
]
}
}
}
$ifNull
:
[{
$arrayElemAt
:
[
'$userBadFeedbackData.count'
,
0
]
},
0
]
},
customFeedbacksCount
:
{
$size
:
{
$filter
:
{
input
:
'$chatitems'
,
as
:
'item'
,
cond
:
{
$gt
:
[{
$size
:
{
$ifNull
:
[
'$$item.customFeedbacks'
,
[]]
}
},
0
]
}
}
}
$ifNull
:
[{
$arrayElemAt
:
[
'$customFeedbacksData.count'
,
0
]
},
0
]
},
markCount
:
{
$size
:
{
$filter
:
{
input
:
'$chatitems'
,
as
:
'item'
,
cond
:
{
$ifNull
:
[
'$$item.adminFeedback'
,
false
]
}
}
}
}
markCount
:
{
$ifNull
:
[{
$arrayElemAt
:
[
'$markData.count'
,
0
]
},
0
]
},
messageCount
:
{
$ifNull
:
[{
$arrayElemAt
:
[
'$messageCountData.messageCount'
,
0
]
},
0
]
}
}
},
{
...
...
@@ -141,7 +187,7 @@ async function handler(
source
:
1
,
sourceName
:
1
,
time
:
'$updateTime'
,
messageCount
:
{
$size
:
'$chatitems'
}
,
messageCount
:
1
,
userGoodFeedbackCount
:
1
,
userBadFeedbackCount
:
1
,
customFeedbacksCount
:
1
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment