Skip to content

Commit 2c7bf25

Browse files
committed
feat: api dataset support pdf parse;fix: chunk reader auth (#4117)
* feat: api dataset support pdf parse * fix: chunk reader auth
1 parent d4df77e commit 2c7bf25

File tree

27 files changed

+376
-353
lines changed

27 files changed

+376
-353
lines changed

docSite/content/zh-cn/docs/development/upgrading/491.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ weight: 799
1111

1212
1. 商业版支持单团队模式,更好的管理内部成员。
1313
2. 知识库分块阅读器。
14+
3. API 知识库支持 PDF 增强解析。
1415

1516
## ⚙️ 优化
1617

packages/service/core/dataset/apiDataset/api.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,13 @@ export const useApiDatasetRequest = ({ apiServer }: { apiServer: APIFileServer }
111111
const getFileContent = async ({
112112
teamId,
113113
tmbId,
114-
apiFileId
114+
apiFileId,
115+
customPdfParse
115116
}: {
116117
teamId: string;
117118
tmbId: string;
118119
apiFileId: string;
120+
customPdfParse?: boolean;
119121
}) => {
120122
const data = await request<APIFileContentResponse>(
121123
`/v1/file/content`,
@@ -133,7 +135,8 @@ export const useApiDatasetRequest = ({ apiServer }: { apiServer: APIFileServer }
133135
teamId,
134136
tmbId,
135137
url: previewUrl,
136-
relatedId: apiFileId
138+
relatedId: apiFileId,
139+
customPdfParse
137140
});
138141
return rawText;
139142
}

packages/service/core/dataset/read.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,24 @@ export const readApiServerFileContent = async ({
127127
yuqueServer,
128128
apiFileId,
129129
teamId,
130-
tmbId
130+
tmbId,
131+
customPdfParse
131132
}: {
132133
apiServer?: APIFileServer;
133134
feishuServer?: FeishuServer;
134135
yuqueServer?: YuqueServer;
135136
apiFileId: string;
136137
teamId: string;
137138
tmbId: string;
139+
customPdfParse?: boolean;
138140
}) => {
139141
if (apiServer) {
140-
return useApiDatasetRequest({ apiServer }).getFileContent({ teamId, tmbId, apiFileId });
142+
return useApiDatasetRequest({ apiServer }).getFileContent({
143+
teamId,
144+
tmbId,
145+
apiFileId,
146+
customPdfParse
147+
});
141148
}
142149

143150
if (feishuServer || yuqueServer) {

projects/app/src/components/core/chat/ChatContainer/ChatBox/components/QuoteList.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,17 @@ import { useChatStore } from '@/web/core/chat/context/useChatStore';
1111
import { getQuoteDataList } from '@/web/core/chat/api';
1212

1313
const QuoteList = React.memo(function QuoteList({
14-
chatItemId,
15-
rawSearch = [],
16-
chatTime
14+
chatItemDataId = '',
15+
rawSearch = []
1716
}: {
18-
chatItemId?: string;
17+
chatItemDataId?: string;
1918
rawSearch: SearchDataResponseItemType[];
20-
chatTime: Date;
2119
}) {
2220
const theme = useTheme();
2321
const { chatId, appId, outLinkAuthData } = useChatStore();
2422

2523
const RawSourceBoxProps = useContextSelector(ChatBoxContext, (v) => ({
26-
chatItemId,
24+
chatItemDataId,
2725
appId: v.appId,
2826
chatId: v.chatId,
2927
...(v.outLinkAuthData || {})
@@ -34,13 +32,12 @@ const QuoteList = React.memo(function QuoteList({
3432
(v) => v.showRouteToDatasetDetail
3533
);
3634

37-
const { data } = useRequest2(
35+
const { data: quoteList } = useRequest2(
3836
async () =>
3937
await getQuoteDataList({
4038
datasetDataIdList: rawSearch.map((item) => item.id),
41-
chatTime,
4239
collectionIdList: [...new Set(rawSearch.map((item) => item.collectionId))],
43-
chatItemId: chatItemId || '',
40+
chatItemDataId,
4441
appId,
4542
chatId,
4643
...outLinkAuthData
@@ -53,7 +50,7 @@ const QuoteList = React.memo(function QuoteList({
5350
const formatedDataList = useMemo(() => {
5451
return rawSearch
5552
.map((item) => {
56-
const currentFilterItem = data?.quoteList.find((res) => res._id === item.id);
53+
const currentFilterItem = quoteList?.find((res) => res._id === item.id);
5754

5855
return {
5956
...item,
@@ -66,7 +63,7 @@ const QuoteList = React.memo(function QuoteList({
6663
const bScore = formatScore(b.score);
6764
return (bScore.primaryScore?.value || 0) - (aScore.primaryScore?.value || 0);
6865
});
69-
}, [data?.quoteList, rawSearch]);
66+
}, [quoteList, rawSearch]);
7067

7168
return (
7269
<>

projects/app/src/components/core/chat/ChatContainer/ChatBox/components/ResponseTags.tsx

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ const ResponseTags = ({
4242
const [quoteFolded, setQuoteFolded] = useState<boolean>(true);
4343

4444
const chatType = useContextSelector(ChatBoxContext, (v) => v.chatType);
45+
const appId = useContextSelector(ChatBoxContext, (v) => v.appId);
46+
const chatId = useContextSelector(ChatBoxContext, (v) => v.chatId);
4547

4648
const setQuoteData = useContextSelector(ChatItemContext, (v) => v.setQuoteData);
4749

@@ -156,17 +158,15 @@ const ResponseTags = ({
156158
e.stopPropagation();
157159

158160
setQuoteData({
159-
chatTime,
160161
rawSearch: quoteList,
161162
metadata: {
163+
appId,
164+
chatId,
165+
chatItemDataId: dataId,
162166
collectionId: item.collectionId,
163-
collectionIdList: [
164-
...new Set(quoteList.map((item) => item.collectionId))
165-
],
166167
sourceId: item.sourceId || '',
167168
sourceName: item.sourceName,
168-
datasetId: item.datasetId,
169-
chatItemId: historyItem.dataId
169+
datasetId: item.datasetId
170170
}
171171
});
172172
}}
@@ -225,15 +225,12 @@ const ResponseTags = ({
225225
e.stopPropagation();
226226

227227
setQuoteData({
228-
chatTime,
229228
rawSearch: quoteList,
230229
metadata: {
231-
collectionId: '',
232-
collectionIdList: [...new Set(quoteList.map((item) => item.collectionId))],
233-
chatItemId: historyItem.dataId,
234-
sourceId: '',
235-
sourceName: '',
236-
datasetId: ''
230+
appId,
231+
chatId,
232+
chatItemDataId: dataId,
233+
collectionIdList: [...new Set(quoteList.map((item) => item.collectionId))]
237234
}
238235
});
239236
}}

projects/app/src/components/core/chat/components/WholeResponseModal.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,7 @@ export const WholeResponseContent = ({
265265
{activeModule.quoteList && activeModule.quoteList.length > 0 && (
266266
<Row
267267
label={t('common:core.chat.response.module quoteList')}
268-
rawDom={
269-
<QuoteList
270-
chatItemId={dataId}
271-
chatTime={chatTime || new Date()}
272-
rawSearch={activeModule.quoteList}
273-
/>
274-
}
268+
rawDom={<QuoteList chatItemDataId={dataId} rawSearch={activeModule.quoteList} />}
275269
/>
276270
)}
277271
</>

projects/app/src/components/core/dataset/QuoteItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ const QuoteItem = ({
243243
color={'primary.500'}
244244
href={`/dataset/detail?datasetId=${quoteItem.datasetId}&currentTab=dataCard&collectionId=${quoteItem.collectionId}`}
245245
>
246-
{t('common:core.dataset.Go Dataset')}
246+
{t('chat:to_dataset')}
247247
<MyIcon name={'common/rightArrowLight'} w={'10px'} />
248248
</Link>
249249
)}

projects/app/src/components/core/dataset/RawSourceBox.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const RawSourceBox = ({
2323
collectionId,
2424
appId,
2525
chatId,
26-
chatItemId,
26+
chatItemDataId,
2727
shareId,
2828
outLinkUid,
2929
teamId,
@@ -40,7 +40,7 @@ const RawSourceBox = ({
4040
collectionId,
4141
appId,
4242
chatId,
43-
chatItemId,
43+
chatItemDataId,
4444
shareId,
4545
outLinkUid,
4646
teamId,

projects/app/src/pageComponents/app/detail/Logs/DetailLogsModal.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ const DetailLogsModal = ({ appId, chatId, onClose }: Props) => {
184184
borderRadius={'md'}
185185
>
186186
<ChatQuoteList
187-
chatTime={quoteData.chatTime}
188187
rawSearch={quoteData.rawSearch}
189188
metadata={quoteData.metadata}
190189
onClose={() => setQuoteData(undefined)}

projects/app/src/pageComponents/app/detail/SimpleApp/ChatTest.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ const ChatTest = ({ appForm, setRenderEdit }: Props) => {
8888
{quoteData && (
8989
<Box flex={'1 0 0'} w={0} maxW={'560px'} {...cardStyles} boxShadow={'3'}>
9090
<ChatQuoteList
91-
chatTime={quoteData.chatTime}
9291
rawSearch={quoteData.rawSearch}
9392
metadata={quoteData.metadata}
9493
onClose={() => setQuoteData(undefined)}

0 commit comments

Comments
 (0)