fix(web): show builtin chunk methods in file pipeline dialog under Go backend (#17169)

This commit is contained in:
euvre
2026-07-22 15:14:02 +08:00
committed by GitHub
parent e0ae22e83b
commit a81b5057bb
2 changed files with 9 additions and 110 deletions

View File

@@ -1,108 +1,4 @@
import { useSelectParserList } from '@/hooks/use-user-setting-request';
import { useCallback, useMemo } from 'react';
const ParserListMap = new Map([
[
['pdf'],
[
'naive',
'resume',
'manual',
'paper',
'book',
'laws',
'presentation',
'one',
'qa',
'knowledge_graph',
],
],
[
['doc', 'docx'],
[
'naive',
'resume',
'book',
'laws',
'one',
'qa',
'manual',
'knowledge_graph',
],
],
[
['xlsx', 'xls'],
['naive', 'qa', 'table', 'one', 'knowledge_graph'],
],
[['ppt', 'pptx'], ['presentation']],
[
['jpg', 'jpeg', 'png', 'gif', 'bmp', 'tif', 'tiff', 'webp', 'svg', 'ico'],
['picture'],
],
[
['txt'],
[
'naive',
'resume',
'book',
'laws',
'one',
'qa',
'table',
'knowledge_graph',
],
],
[
['csv'],
[
'naive',
'resume',
'book',
'laws',
'one',
'qa',
'table',
'knowledge_graph',
],
],
[
['md', 'mdx'],
['naive', 'qa', 'knowledge_graph'],
],
[['json'], ['naive', 'knowledge_graph']],
[['eml'], ['email']],
]);
const getParserList = (
values: string[],
parserList: Array<{
value: string;
label: string;
}>,
) => {
return parserList.filter((x) => values?.some((y) => y === x.value));
};
export const useFetchParserListOnMount = (documentExtension: string) => {
const parserList = useSelectParserList();
const nextParserList = useMemo(() => {
const key = [...ParserListMap.keys()].find((x) =>
x.some((y) => y === documentExtension),
);
if (key) {
const values = ParserListMap.get(key);
return getParserList(values ?? [], parserList);
}
return getParserList(
['naive', 'resume', 'book', 'laws', 'one', 'qa', 'table'],
parserList,
);
}, [parserList, documentExtension]);
return { parserList: nextParserList };
};
import { useCallback } from 'react';
const hideAutoKeywords = ['qa', 'table', 'resume', 'knowledge_graph', 'tag'];

View File

@@ -163,12 +163,15 @@ export const useSelectParserList = (): Array<{
const parserList = useMemo(() => {
// Go backend: prefer the dynamic pipeline catalog from the API.
// GET /api/v1/pipelines?type=builtin responds with
// { code, data: { canvas: [{ id, title, description, filename }], total } }.
if (backendLang === 'go') {
const pipelineList: Array<{
parser_id: string;
id: string;
title: string;
dsl: Record<string, any>;
}> = pipelineListData?.data ?? [];
description?: string;
filename?: string;
}> = pipelineListData?.data?.canvas ?? [];
if (pipelineList.length > 0) {
const labelFromAPI = (parserId: string, title: string) => {
const key = `knowledgeConfiguration.parserLabel.${parserId}`;
@@ -176,8 +179,8 @@ export const useSelectParserList = (): Array<{
return translated !== key ? translated : title;
};
return pipelineList.map((item) => ({
value: item.parser_id,
label: labelFromAPI(item.parser_id, item.title),
value: item.id,
label: labelFromAPI(item.id, item.title),
}));
}
}