Fix some bug (#5048)

* fix: chat log time range

* fix: repeat system prompt

* perf: nanoid random

* fix: get files from histories

* fix: ts

* ts config

* perf: search dataset collection
This commit is contained in:
Archer
2025-06-17 16:10:01 +08:00
committed by GitHub
parent 7981b61ca9
commit af3221fa47
21 changed files with 121 additions and 79 deletions

View File

@@ -21,7 +21,6 @@ import {
import type { VariableItemType } from '@fastgpt/global/core/app/type.d';
import MyIcon from '@fastgpt/web/components/common/Icon';
import { useForm, type UseFormReset } from 'react-hook-form';
import { customAlphabet } from 'nanoid';
import MyModal from '@fastgpt/web/components/common/MyModal';
import { useTranslation } from 'next-i18next';
import { useToast } from '@fastgpt/web/hooks/useToast';
@@ -36,11 +35,10 @@ import DndDrag, {
type DraggableProvided,
type DraggableStateSnapshot
} from '@fastgpt/web/components/common/DndDrag';
const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz1234567890', 6);
import { getNanoid } from '@fastgpt/global/common/string/tools';
export const defaultVariable: VariableItemType = {
id: nanoid(),
id: getNanoid(6),
key: '',
label: '',
type: VariableInputEnum.input,
@@ -136,7 +134,7 @@ const VariableEdit = ({
} else {
onChangeVariable.push({
...data,
id: nanoid()
id: getNanoid(6)
});
}

View File

@@ -306,7 +306,7 @@ const ChatInput = ({
isChatting ? 'primary.50' : canSendMessage ? 'primary.500' : 'rgba(17, 24, 36, 0.1)'
}
borderRadius={['md', 'lg']}
cursor={canSendMessage ? 'pointer' : 'not-allowed'}
cursor={isChatting ? 'pointer' : canSendMessage ? 'pointer' : 'not-allowed'}
onClick={() => {
if (isChatting) {
return onStop();

View File

@@ -1,4 +1,4 @@
import React, { useMemo, useState } from 'react';
import React, { useEffect, useMemo, useState } from 'react';
import {
Flex,
Box,
@@ -46,8 +46,8 @@ const Logs = () => {
const appId = useContextSelector(AppContext, (v) => v.appId);
const [dateRange, setDateRange] = useState<DateRangeType>({
from: addDays(new Date(), -7),
to: new Date()
from: new Date(addDays(new Date(), -6).setHours(0, 0, 0, 0)),
to: new Date(new Date().setHours(23, 59, 59, 999))
});
const [detailLogsId, setDetailLogsId] = useState<string>();
@@ -69,6 +69,16 @@ const Logs = () => {
[t]
);
const params = useMemo(
() => ({
appId,
dateStart: dateRange.from!,
dateEnd: dateRange.to!,
sources: isSelectAllSource ? undefined : chatSources,
logTitle
}),
[appId, chatSources, dateRange.from, dateRange.to, isSelectAllSource, logTitle]
);
const {
data: logs,
isLoading,
@@ -78,14 +88,8 @@ const Logs = () => {
total
} = usePagination(getAppChatLogs, {
pageSize: 20,
params: {
appId,
dateStart: dateRange.from || new Date(),
dateEnd: addDays(dateRange.to || new Date(), 1),
sources: isSelectAllSource ? undefined : chatSources,
logTitle
},
refreshDeps: [chatSources, logTitle]
params,
refreshDeps: [params]
});
const { runAsync: exportLogs } = useRequest2(
@@ -116,7 +120,7 @@ const Logs = () => {
refreshDeps: [chatSources, logTitle]
}
);
console.log(dateRange, 111);
return (
<Flex
flexDirection={'column'}
@@ -153,8 +157,9 @@ const Logs = () => {
<DateRangePicker
defaultDate={dateRange}
position="bottom"
onChange={setDateRange}
onSuccess={() => getData(1)}
onSuccess={(date) => {
setDateRange(date);
}}
/>
</Flex>
<Flex alignItems={'center'} gap={2}>

View File

@@ -30,8 +30,7 @@ import { useContextSelector } from 'use-context-selector';
import { DatasetPageContext } from '@/web/core/dataset/context/datasetPageContext';
import EmptyTip from '@fastgpt/web/components/common/EmptyTip';
import QuestionTip from '@fastgpt/web/components/common/MyTooltip/QuestionTip';
const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz1234567890', 12);
import { getNanoid } from '@fastgpt/global/common/string/tools';
const DatasetParamsModal = dynamic(() => import('@/components/core/app/DatasetParamsModal'));
@@ -108,7 +107,7 @@ const Test = ({ datasetId }: { datasetId: string }) => {
}
const testItem: SearchTestStoreItemType = {
id: nanoid(),
id: getNanoid(),
datasetId,
text: getValues('inputText').trim(),
time: new Date(),

View File

@@ -38,13 +38,14 @@ async function handler(req: NextApiRequest) {
const match = {
teamId: new Types.ObjectId(teamId),
datasetId: new Types.ObjectId(datasetId),
parentId: parentId ? new Types.ObjectId(parentId) : null,
...(selectFolder ? { type: DatasetCollectionTypeEnum.folder } : {}),
...(searchText
? {
name: new RegExp(searchText, 'i')
}
: {}),
: {
parentId: parentId ? new Types.ObjectId(parentId) : null
}),
...(filterTags.length ? { tags: { $in: filterTags } } : {})
};

View File

@@ -43,13 +43,14 @@ async function handler(
const match = {
teamId: new Types.ObjectId(teamId),
datasetId: new Types.ObjectId(datasetId),
parentId: parentId ? new Types.ObjectId(parentId) : null,
...(selectFolder ? { type: DatasetCollectionTypeEnum.folder } : {}),
...(searchText
? {
name: new RegExp(searchText, 'i')
}
: {}),
: {
parentId: parentId ? new Types.ObjectId(parentId) : null
}),
...(filterTags.length ? { tags: { $in: filterTags } } : {})
};

View File

@@ -1,7 +1,6 @@
import { MongoOutLink } from '@fastgpt/service/support/outLink/schema';
import { authApp } from '@fastgpt/service/support/permission/app/auth';
import type { OutLinkEditType } from '@fastgpt/global/support/outLink/type.d';
import { customAlphabet } from 'nanoid';
import type { PublishChannelEnum } from '@fastgpt/global/support/outLink/constant';
import { ManagePermissionVal } from '@fastgpt/global/support/permission/constant';
import type { ApiRequestProps } from '@fastgpt/service/type/next';
@@ -9,8 +8,7 @@ import { NextAPI } from '@/service/middleware/entry';
import { addOperationLog } from '@fastgpt/service/support/operationLog/addOperationLog';
import { OperationLogEventEnum } from '@fastgpt/global/support/operationLog/constants';
import { getI18nAppType } from '@fastgpt/service/support/operationLog/util';
/* create a shareChat */
const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz1234567890', 24);
import { getNanoid } from '@fastgpt/global/common/string/tools';
export type OutLinkCreateQuery = {};
export type OutLinkCreateBody = OutLinkEditType &
@@ -32,7 +30,7 @@ async function handler(
per: ManagePermissionVal
});
const shareId = nanoid();
const shareId = getNanoid(24);
await MongoOutLink.create({
shareId,
teamId,