mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-14 23:22:22 +00:00
fix: input modal (#5108)
* fix: input modal * fix: input modal * fix: chat logs count
This commit is contained in:
@@ -37,4 +37,5 @@ weight: 786
|
||||
## 🐛 修复
|
||||
|
||||
1. 知识库数据输入,识别 QA 模式错误。
|
||||
2. 知识库标签条件冲突。
|
||||
2. 知识库标签条件冲突。
|
||||
3. 对话日志点赞点踩统计。
|
@@ -64,9 +64,7 @@ const ChatItemSchema = new Schema({
|
||||
memories: Object,
|
||||
errorMsg: String,
|
||||
userGoodFeedback: String,
|
||||
userBadFeedback: {
|
||||
type: String
|
||||
},
|
||||
userBadFeedback: String,
|
||||
customFeedbacks: [String],
|
||||
adminFeedback: {
|
||||
type: {
|
||||
|
@@ -76,58 +76,47 @@ const InputDataModal = ({
|
||||
});
|
||||
const imagePreivewUrl = watch('imagePreivewUrl');
|
||||
|
||||
const { data: collection = defaultCollectionDetail } = useRequest2(
|
||||
() => getDatasetCollectionById(collectionId),
|
||||
{
|
||||
manual: false,
|
||||
refreshDeps: [collectionId],
|
||||
onSuccess(res) {
|
||||
if (res.type === DatasetCollectionTypeEnum.images) {
|
||||
setCurrentTab(TabEnum.image);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Get data
|
||||
const { data: dataItem, loading: isFetchingData } = useRequest2(
|
||||
const { data: collection = defaultCollectionDetail, loading: initLoading } = useRequest2(
|
||||
async () => {
|
||||
if (dataId) return getDatasetDataItemById(dataId);
|
||||
return null;
|
||||
const [collection, dataItem] = await Promise.all([
|
||||
getDatasetCollectionById(collectionId),
|
||||
...(dataId ? [getDatasetDataItemById(dataId)] : [])
|
||||
]);
|
||||
|
||||
if (dataItem) {
|
||||
setCurrentTab(dataItem?.a ? TabEnum.qa : TabEnum.chunk);
|
||||
reset({
|
||||
q: dataItem.q || '',
|
||||
a: dataItem.a || '',
|
||||
imagePreivewUrl: dataItem.imagePreivewUrl,
|
||||
indexes: dataItem.indexes.map((item) => ({
|
||||
...item,
|
||||
fold: true
|
||||
}))
|
||||
});
|
||||
} else if (defaultValue) {
|
||||
setCurrentTab(defaultValue?.a ? TabEnum.qa : TabEnum.chunk);
|
||||
reset({
|
||||
q: defaultValue.q || '',
|
||||
a: defaultValue.a || '',
|
||||
imagePreivewUrl: defaultValue.imagePreivewUrl
|
||||
});
|
||||
} else {
|
||||
setCurrentTab(TabEnum.chunk);
|
||||
}
|
||||
|
||||
// Forcus reset to image tab
|
||||
if (collection.type === DatasetCollectionTypeEnum.images) {
|
||||
setCurrentTab(TabEnum.image);
|
||||
}
|
||||
return collection;
|
||||
},
|
||||
{
|
||||
manual: false,
|
||||
refreshDeps: [dataId],
|
||||
onSuccess(res) {
|
||||
if (res) {
|
||||
reset({
|
||||
q: res.q || '',
|
||||
a: res.a || '',
|
||||
imagePreivewUrl: res.imagePreivewUrl,
|
||||
indexes: res.indexes.map((item) => ({
|
||||
...item,
|
||||
fold: true
|
||||
}))
|
||||
});
|
||||
} else if (defaultValue) {
|
||||
reset({
|
||||
q: defaultValue.q || '',
|
||||
a: defaultValue.a || '',
|
||||
imagePreivewUrl: defaultValue.imagePreivewUrl
|
||||
});
|
||||
}
|
||||
},
|
||||
onError(err) {
|
||||
onClose();
|
||||
}
|
||||
refreshDeps: [collectionId, dataId, defaultValue]
|
||||
}
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (currentTab || !dataItem) return;
|
||||
setCurrentTab(dataItem.a ? TabEnum.qa : TabEnum.chunk);
|
||||
}, [collection, dataItem, currentTab]);
|
||||
|
||||
// Import new data
|
||||
const { runAsync: sureImportData, loading: isImporting } = useRequest2(
|
||||
async (e: InputDataType) => {
|
||||
@@ -138,7 +127,7 @@ const InputDataModal = ({
|
||||
q: e.q,
|
||||
a: currentTab === TabEnum.qa ? e.a : '',
|
||||
// Contains no default index
|
||||
indexes: e.indexes.filter((item) => !!item.text?.trim())
|
||||
indexes: e.indexes?.filter((item) => !!item.text?.trim()) || []
|
||||
};
|
||||
|
||||
const dataId = await postInsertData2Dataset(postData);
|
||||
@@ -194,8 +183,6 @@ const InputDataModal = ({
|
||||
}
|
||||
);
|
||||
|
||||
const isLoading = isFetchingData;
|
||||
|
||||
const icon = useMemo(
|
||||
() => getCollectionIcon({ type: collection.type, name: collection.sourceName }),
|
||||
[collection]
|
||||
@@ -240,7 +227,7 @@ const InputDataModal = ({
|
||||
<MyBox
|
||||
display={'flex'}
|
||||
flexDir={'column'}
|
||||
isLoading={isLoading}
|
||||
isLoading={initLoading}
|
||||
h={'100%'}
|
||||
py={[6, '1.5rem']}
|
||||
>
|
||||
|
@@ -86,14 +86,44 @@ async function handler(
|
||||
$group: {
|
||||
_id: null,
|
||||
messageCount: { $sum: 1 },
|
||||
goodFeedback: { $sum: { $cond: [{ $eq: ['$userGoodFeedback', true] }, 1, 0] } },
|
||||
badFeedback: { $sum: { $cond: [{ $eq: ['$userBadFeedback', true] }, 1, 0] } },
|
||||
goodFeedback: {
|
||||
$sum: {
|
||||
$cond: [
|
||||
{
|
||||
$ifNull: ['$userGoodFeedback', false]
|
||||
},
|
||||
1,
|
||||
0
|
||||
]
|
||||
}
|
||||
},
|
||||
badFeedback: {
|
||||
$sum: {
|
||||
$cond: [
|
||||
{
|
||||
$ifNull: ['$userBadFeedback', false]
|
||||
},
|
||||
1,
|
||||
0
|
||||
]
|
||||
}
|
||||
},
|
||||
customFeedback: {
|
||||
$sum: {
|
||||
$cond: [{ $gt: [{ $size: { $ifNull: ['$customFeedbacks', []] } }, 0] }, 1, 0]
|
||||
}
|
||||
},
|
||||
adminMark: { $sum: { $cond: [{ $eq: ['$adminFeedback', true] }, 1, 0] } }
|
||||
adminMark: {
|
||||
$sum: {
|
||||
$cond: [
|
||||
{
|
||||
$ifNull: ['$adminFeedback', false]
|
||||
},
|
||||
1,
|
||||
0
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -140,9 +170,9 @@ async function handler(
|
||||
),
|
||||
MongoChat.countDocuments(where, { ...readFromSecondary })
|
||||
]);
|
||||
|
||||
console.log(list);
|
||||
const listWithSourceMember = await addSourceMember({
|
||||
list: list
|
||||
list
|
||||
});
|
||||
|
||||
const listWithoutTmbId = list.filter((item) => !item.tmbId);
|
||||
|
Reference in New Issue
Block a user