perF: getInitData api cache;perf: tool description field;signoz store level (#5465)

* perf: auto focus

* perF: getInitData api cache

* perf: tool description field

* signoz store level

* perF: chat logs index
This commit is contained in:
Archer
2025-08-15 15:01:20 +08:00
committed by GitHub
parent d78a0e9e4b
commit 76dc23c2e4
20 changed files with 91 additions and 71 deletions

View File

@@ -95,3 +95,4 @@ CONFIG_JSON_PATH=
# Signoz
SIGNOZ_BASE_URL=
SIGNOZ_SERVICE_NAME=
SIGNOZ_STORE_LEVEL=warn

View File

@@ -37,6 +37,8 @@ const OptimizerPopover = ({
const { t } = useTranslation();
const { llmModelList, defaultModels } = useSystemStore();
const InputRef = useRef<HTMLTextAreaElement>(null);
const [optimizerInput, setOptimizerInput] = useState('');
const [optimizedResult, setOptimizedResult] = useState('');
const [selectedModel = '', setSelectedModel] = useLocalStorageState<string>(
@@ -122,7 +124,7 @@ const OptimizerPopover = ({
Trigger={
<Flex {...iconButtonStyle}>
<MyTooltip label={t('app:Optimizer_Tooltip')}>
<MyIcon name={'optimizer'} w={'18px'} />
<MyIcon name={'optimizer'} w={'1.2rem'} />
</MyTooltip>
</Flex>
}
@@ -136,6 +138,11 @@ const OptimizerPopover = ({
closePopoverRef.current?.();
}
}}
onOpenFunc={() => {
setTimeout(() => {
InputRef.current?.focus();
}, 50);
}}
>
{({ onClose }) => {
closePopoverRef.current = onClose;
@@ -234,11 +241,13 @@ const OptimizerPopover = ({
>
<MyIcon name={'optimizer'} alignSelf={'flex-start'} mt={0.5} w={5} />
<Textarea
ref={InputRef}
placeholder={
!loading
? t('app:Optimizer_Placeholder')
: t('app:Optimizer_Placeholder_loading')
}
autoFocus
resize={'none'}
rows={1}
minHeight={'24px'}
@@ -246,14 +255,11 @@ const OptimizerPopover = ({
maxHeight={'96px'}
overflowY={'hidden'}
border={'none'}
_focus={{
boxShadow: 'none'
}}
boxShadow={'none !important'}
fontSize={'sm'}
p={0}
borderRadius={'none'}
value={optimizerInput}
autoFocus
onKeyDown={handleKeyDown}
isDisabled={loading}
onChange={(e) => {

View File

@@ -38,7 +38,7 @@ const ChatTest = ({ isOpen, nodes = [], edges = [], onClose, chatId }: Props) =>
const isPlugin = appDetail.type === AppTypeEnum.plugin;
const { copyData } = useCopyData();
const { restartChat, ChatContainer, loading } = useChatTest({
const { restartChat, ChatContainer } = useChatTest({
nodes,
edges,
chatConfig: appDetail.chatConfig,

View File

@@ -25,6 +25,7 @@ export const uiWorkflow2StoreWorkflow = ({
parentNodeId: item.data.parentNodeId,
name: item.data.name,
intro: item.data.intro,
toolDescription: item.data.toolDescription,
avatar: item.data.avatar,
flowNodeType: item.data.flowNodeType,
showStatus: item.data.showStatus,

View File

@@ -2,7 +2,6 @@ import type { NextApiResponse } from 'next';
import { type ApiRequestProps } from '@fastgpt/service/type/next';
import { NextAPI } from '@/service/middleware/entry';
import { type InitDateResponse } from '@/global/common/api/systemRes';
import { type SystemModelItemType } from '@fastgpt/service/core/ai/type';
import { authCert } from '@fastgpt/service/support/permission/auth/common';
async function handler(
@@ -11,18 +10,6 @@ async function handler(
): Promise<InitDateResponse> {
const { bufferId } = req.query;
const activeModelList = global.systemActiveModelList.map((model) => ({
...model,
defaultSystemChatPrompt: undefined,
fieldMap: undefined,
defaultConfig: undefined,
weight: undefined,
dbConfig: undefined,
queryConfig: undefined,
requestUrl: undefined,
requestAuth: undefined
})) as SystemModelItemType[];
try {
await authCert({ req, authToken: true });
// If bufferId is the same as the current bufferId, return directly
@@ -38,7 +25,7 @@ async function handler(
feConfigs: global.feConfigs,
subPlans: global.subPlans,
systemVersion: global.systemVersion,
activeModelList,
activeModelList: global.systemActiveDesensitizedModels,
defaultModels: global.systemDefaultModel
};
} catch (error) {
@@ -47,7 +34,7 @@ async function handler(
return {
feConfigs: global.feConfigs,
subPlans: global.subPlans,
activeModelList
activeModelList: global.systemActiveDesensitizedModels
};
}

View File

@@ -18,6 +18,8 @@ import { type ChatSourceEnum } from '@fastgpt/global/core/chat/constants';
import { AppLogKeysEnum } from '@fastgpt/global/core/app/logs/constants';
import { sanitizeCsvField } from '@fastgpt/service/common/file/csv';
import { AppReadChatLogPerVal } from '@fastgpt/global/support/permission/app/constant';
import { addAuditLog, getI18nAppType } from '@fastgpt/service/support/user/audit/util';
import { AuditEventEnum } from '@fastgpt/global/support/user/audit/constants';
const formatJsonString = (data: any) => {
if (data == null) return '';
@@ -47,7 +49,12 @@ async function handler(req: ApiRequestProps<ExportChatLogsBody, {}>, res: NextAp
throw new Error('缺少参数');
}
const { teamId } = await authApp({ req, authToken: true, appId, per: AppReadChatLogPerVal });
const { teamId, tmbId, app } = await authApp({
req,
authToken: true,
appId,
per: AppReadChatLogPerVal
});
const teamMemberWithContact = await MongoTeamMember.aggregate([
{ $match: { teamId: new Types.ObjectId(teamId) } },
@@ -394,6 +401,18 @@ async function handler(req: ApiRequestProps<ExportChatLogsBody, {}>, res: NextAp
res.status(500);
res.end();
});
(async () => {
addAuditLog({
tmbId,
teamId,
event: AuditEventEnum.EXPORT_APP_CHAT_LOG,
params: {
appName: app.name,
appType: getI18nAppType(app.type)
}
});
})();
}
export default NextAPI(

View File

@@ -11,9 +11,6 @@ import { readFromSecondary } from '@fastgpt/service/common/mongo/utils';
import { parsePaginationRequest } from '@fastgpt/service/common/api/pagination';
import { type PaginationResponse } from '@fastgpt/web/common/fetch/type';
import { addSourceMember } from '@fastgpt/service/support/user/utils';
import { addAuditLog } from '@fastgpt/service/support/user/audit/util';
import { AuditEventEnum } from '@fastgpt/global/support/user/audit/constants';
import { getI18nAppType } from '@fastgpt/service/support/user/audit/util';
import { replaceRegChars } from '@fastgpt/global/common/string/tools';
import { AppReadChatLogPerVal } from '@fastgpt/global/support/permission/app/constant';
import { CommonErrEnum } from '@fastgpt/global/common/error/code/common';
@@ -38,7 +35,7 @@ async function handler(
}
// 凭证校验
const { teamId, tmbId, app } = await authApp({
const { teamId } = await authApp({
req,
authToken: true,
appId,
@@ -48,12 +45,12 @@ async function handler(
const where = {
teamId: new Types.ObjectId(teamId),
appId: new Types.ObjectId(appId),
source: sources ? { $in: sources } : { $exists: true },
tmbId: tmbIds ? { $in: tmbIds.map((item) => new Types.ObjectId(item)) } : { $exists: true },
updateTime: {
$gte: new Date(dateStart),
$lte: new Date(dateEnd)
},
source: sources ? { $in: sources } : { $exists: true },
tmbId: tmbIds ? { $in: tmbIds.map((item) => new Types.ObjectId(item)) } : { $exists: true },
...(chatSearch && {
$or: [
{ chatId: { $regex: new RegExp(`${replaceRegChars(chatSearch)}`, 'i') } },
@@ -77,7 +74,7 @@ async function handler(
{
$lookup: {
from: ChatItemCollectionName,
let: { chatId: '$chatId', appId: new Types.ObjectId(appId) },
let: { appId: new Types.ObjectId(appId), chatId: '$chatId' },
pipeline: [
{
$match: {
@@ -244,18 +241,6 @@ async function handler(
const listWithoutTmbId = list.filter((item) => !item.tmbId);
(async () => {
addAuditLog({
tmbId,
teamId,
event: AuditEventEnum.EXPORT_APP_CHAT_LOG,
params: {
appName: app.name,
appType: getI18nAppType(app.type)
}
});
})();
return {
list: listWithSourceMember.concat(listWithoutTmbId),
total

View File

@@ -393,6 +393,7 @@ export function form2AppWorkflow(
pluginId: tool.pluginId,
name: tool.name,
intro: tool.intro,
toolDescription: tool.toolDescription,
avatar: tool.avatar,
flowNodeType: tool.flowNodeType,
showStatus: tool.showStatus,