From 83d54d046d77110a3d0336be275b9c4b3d24ed42 Mon Sep 17 00:00:00 2001
From: Archer <545436317@qq.com>
Date: Thu, 8 May 2025 13:35:08 +0800
Subject: [PATCH] perf: replace cite;perf: app card ui (#4768)
* perf: replace cite
* perf: app card ui
* fix: test
---
packages/service/core/ai/utils.ts | 2 +-
.../web/components/common/UserBox/index.tsx | 6 +-
.../pageComponents/dashboard/apps/List.tsx | 13 +--
.../app/src/pages/dashboard/apps/index.tsx | 2 -
.../core/ai/parseStreamResponse.test.ts | 88 ++++++++++++++++++-
5 files changed, 95 insertions(+), 16 deletions(-)
diff --git a/packages/service/core/ai/utils.ts b/packages/service/core/ai/utils.ts
index 2485a7af8..99b73753c 100644
--- a/packages/service/core/ai/utils.ts
+++ b/packages/service/core/ai/utils.ts
@@ -221,7 +221,7 @@ export const parseReasoningContent = (text: string): [string, string] => {
};
export const removeDatasetCiteText = (text: string, retainDatasetCite: boolean) => {
- return retainDatasetCite ? text : text.replace(/\[([a-f0-9]{24})\]\(CITE\)/g, '');
+ return retainDatasetCite ? text : text.replace(/\[([a-f0-9]{24})\](?:\([^\)]*\)?)?/g, '');
};
// Parse llm stream part
diff --git a/packages/web/components/common/UserBox/index.tsx b/packages/web/components/common/UserBox/index.tsx
index 696976d63..bc22ea466 100644
--- a/packages/web/components/common/UserBox/index.tsx
+++ b/packages/web/components/common/UserBox/index.tsx
@@ -9,12 +9,16 @@ export type UserBoxProps = {
sourceMember: SourceMemberType;
avatarSize?: string;
} & StackProps;
+
function UserBox({ sourceMember, avatarSize = '1.25rem', ...props }: UserBoxProps) {
const { t } = useTranslation();
+
return (
- {sourceMember.name}
+
+ {sourceMember.name}
+
{sourceMember.status === 'leave' && {t('common:user_leaved')}}
);
diff --git a/projects/app/src/pageComponents/dashboard/apps/List.tsx b/projects/app/src/pageComponents/dashboard/apps/List.tsx
index fe3bf7f8d..de92b4ef6 100644
--- a/projects/app/src/pageComponents/dashboard/apps/List.tsx
+++ b/projects/app/src/pageComponents/dashboard/apps/List.tsx
@@ -220,14 +220,8 @@ const ListItem = () => {
{app.intro || t('common:no_intro')}
-
-
+
+
{
w={'0.875rem'}
/>
-
{isPc && (
@@ -394,7 +387,7 @@ const ListItem = () => {
)}
-
+
);
diff --git a/projects/app/src/pages/dashboard/apps/index.tsx b/projects/app/src/pages/dashboard/apps/index.tsx
index d4eaad5e1..ef061e2b7 100644
--- a/projects/app/src/pages/dashboard/apps/index.tsx
+++ b/projects/app/src/pages/dashboard/apps/index.tsx
@@ -28,13 +28,11 @@ import MyBox from '@fastgpt/web/components/common/MyBox';
import { useSystem } from '@fastgpt/web/hooks/useSystem';
import MyIcon from '@fastgpt/web/components/common/Icon';
import JsonImportModal from '@/pageComponents/dashboard/apps/JsonImportModal';
-import { type PermissionValueType } from '@fastgpt/global/support/permission/type';
import DashboardContainer from '@/pageComponents/dashboard/Container';
import List from '@/pageComponents/dashboard/apps/List';
import MCPToolsEditModal from '@/pageComponents/dashboard/apps/MCPToolsEditModal';
import { getUtmWorkflow } from '@/web/support/marketing/utils';
import { useMount } from 'ahooks';
-import { type AppCollaboratorDeleteParams } from '@fastgpt/global/core/app/collaborator';
const CreateModal = dynamic(() => import('@/pageComponents/dashboard/apps/CreateModal'));
const EditFolderModal = dynamic(
diff --git a/test/cases/function/packages/service/core/ai/parseStreamResponse.test.ts b/test/cases/function/packages/service/core/ai/parseStreamResponse.test.ts
index a6a8b6c03..1e1268d5a 100644
--- a/test/cases/function/packages/service/core/ai/parseStreamResponse.test.ts
+++ b/test/cases/function/packages/service/core/ai/parseStreamResponse.test.ts
@@ -167,6 +167,90 @@ describe('Parse dataset cite content test', async () => {
responseContent: '知识库问答系统'
}
},
+ {
+ // 只要 objectId
+ data: [
+ { content: '知识库' },
+ { content: '问答系统' },
+ { content: '[67e517e747' },
+ { content: '67063e882d' },
+ { content: '6861]' }
+ ],
+ correct: {
+ content: '知识库问答系统[67e517e74767063e882d6861]',
+ responseContent: '知识库问答系统'
+ }
+ },
+ {
+ // 满足替换条件的
+ data: [
+ { content: '知识库' },
+ { content: '问答系统' },
+ { content: '[67e517e747' },
+ { content: '67063e882d' },
+ { content: '6861](' }
+ ],
+ correct: {
+ content: '知识库问答系统[67e517e74767063e882d6861](',
+ responseContent: '知识库问答系统'
+ }
+ },
+ {
+ // 满足替换条件的
+ data: [
+ { content: '知识库' },
+ { content: '问答系统' },
+ { content: '[67e517e747' },
+ { content: '67063e882d' },
+ { content: '6861](C' }
+ ],
+ correct: {
+ content: '知识库问答系统[67e517e74767063e882d6861](C',
+ responseContent: '知识库问答系统'
+ }
+ },
+ {
+ // 满足替换条件的
+ data: [
+ { content: '知识库' },
+ { content: '问答系统' },
+ { content: '[67e517e747' },
+ { content: '67063e882d' },
+ { content: '6861](CI' }
+ ],
+ correct: {
+ content: '知识库问答系统[67e517e74767063e882d6861](CI',
+ responseContent: '知识库问答系统'
+ }
+ },
+ {
+ // 满足替换条件的
+ data: [
+ { content: '知识库' },
+ { content: '问答系统' },
+ { content: '[67e517e747' },
+ { content: '67063e882d' },
+ { content: '6861](CIT' }
+ ],
+ correct: {
+ content: '知识库问答系统[67e517e74767063e882d6861](CIT',
+ responseContent: '知识库问答系统'
+ }
+ },
+ {
+ // 满足替换条件的
+ data: [
+ { content: '知识库' },
+ { content: '问答系统' },
+ { content: '[67e517e747' },
+ { content: '67063e882d' },
+ { content: '6861](CITE' }
+ ],
+ correct: {
+ content: '知识库问答系统[67e517e74767063e882d6861](CITE',
+ responseContent: '知识库问答系统'
+ }
+ },
{
// 缺失结尾
data: [
@@ -177,7 +261,7 @@ describe('Parse dataset cite content test', async () => {
],
correct: {
content: '知识库问答系统[67e517e74767063e882d6861](CITE',
- responseContent: '知识库问答系统[67e517e74767063e882d6861](CITE'
+ responseContent: '知识库问答系统'
}
},
{
@@ -265,7 +349,7 @@ describe('Parse dataset cite content test', async () => {
],
correct: {
content: '知识库问答系统[](https://fastgpt.cn)[67e517e74767063e882d6861](CIT',
- responseContent: '知识库问答系统[](https://fastgpt.cn)[67e517e74767063e882d6861](CIT'
+ responseContent: '知识库问答系统[](https://fastgpt.cn)'
}
},
{