Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

refactor(web): remove Python backend compatibility code (#20375)

chanxd3e57be1fc14
diff --git a/web/.oxlintrc.json b/web/.oxlintrc.json
index 097846896a..9d5cc299e0 100644
--- a/web/.oxlintrc.json
+++ b/web/.oxlintrc.json
@@ -25,24 +25,6 @@
"react/react-in-jsx-scope": "off",
"react/no-unescaped-entities": "warn",
"no-console": ["warn", { "allow": ["warn", "error"] }],
- "no-unused-vars": ["warn", { "fix": { "imports": "safe-fix" } }],
- "no-restricted-imports": [
- "error",
- {
- "paths": [
- {
- "name": "@/utils/backend-runtime",
- "message": "Branch on the backend only through the dispatch primitives in @/utils/backend-variant (useIsGoBackend / <BackendVariant> / pickByBackend). backend-runtime may only be imported by backend-variant itself and the main.tsx bootstrap gate."
- }
- ]
- }
- ],
- "no-restricted-globals": [
- "error",
- {
- "name": "__API_PROXY_SCHEME__",
- "message": "Backend identity comes from runtime detection, not the dev-proxy env. Branch only through @/utils/backend-variant (useIsGoBackend / <BackendVariant> / pickByBackend); do not declare or read API_PROXY_SCHEME in app code."
- }
- ]
+ "no-unused-vars": ["warn", { "fix": { "imports": "safe-fix" } }]
}
}
diff --git a/web/AGENTS.md b/web/AGENTS.md
index d581ec1920..28c97eb3ea 100644
--- a/web/AGENTS.md
+++ b/web/AGENTS.md
@@ -29,25 +29,11 @@ npm run test # Jest tests
When tests are grouped in a dedicated directory, that directory is always named `__tests__/` — never `tests/`. Example: `src/pages/agent/utils/__tests__/extractor-transform.test.ts` for `src/pages/agent/utils/extractor-transform.ts`. Co-located `foo.test.ts(x)` files next to the source file are also fine. When you find an existing test under a `tests/` directory, move it into `__tests__/` (keep git history via `git mv`) rather than adding new tests there.
-### Dual-Backend Variant Conventions (Go / Python)
+### Backend Conventions
-The frontend serves two backends, Go and Python. The active one is detected at runtime by `src/utils/backend-runtime.ts` (`/api/v1/language`, fetched once; `src/main.tsx` gates first render on it, so below the gate the variant never changes for the session lifetime). In dev, `API_PROXY_SCHEME` in `.env.development` selects which backend the dev server proxies to.
+The frontend serves only the **Go** backend. There is no runtime backend detection and no per-backend branching in app code; the dev server proxies `/api` and `/v1` to the Go API (`vite.config.ts`).
-All divergence between the two backends is funneled through dispatch points. Business code never branches on backend identity.
-
-1. Never import `@/utils/backend-runtime` anywhere except its two sanctioned boundaries (enforced by oxlint `no-restricted-imports`):
- - `src/utils/backend-variant.tsx` — the dispatch primitives;
- - `src/main.tsx` — the bootstrap gate.
-2. Branch only through the primitives from `@/utils/backend-variant`:
- - JSX: `<BackendVariant go={...} python={...} />` inside a dispatcher file (a page `index.tsx` or form dispatcher) — never inline in business components.
- - Values (field names, defaults, payload transforms): `pickByBackend({ go, python })` inside an adapter file.
- - Hook-level needs (e.g. a query `enabled` flag): `useIsGoBackend()`.
-3. Routes never fork per backend: one route, one dispatcher component, with the variant implementations under `go/` and `python/` subdirectories. Reference example: `src/pages/dataset/setting/`.
-4. Variant file naming: `Xxx.go.tsx` / `Xxx.python.ts(x)` siblings behind a same-named dispatcher, or `go/` + `python/` subdirectories for whole pages. No temporal names (`Next`, `Legacy`, `New`).
-5. Small differences (a field's visibility, a field name) belong in capability-style adapter/config files reached through `pickByBackend`, not scattered inline ternaries in shared components.
-6. Runtime detection (`/api/v1/language`) is the ONLY source of backend identity in app code. Never read `API_PROXY_SCHEME` / `__API_PROXY_SCHEME__` or declare that global in `src/`, and never create another backend-detection helper (a deleted `api-proxy-scheme.ts` did exactly this — do not recreate it). The env var only configures the dev-server proxy in `vite.config.ts`; it is build-time, dev-only, and defaults to `python`, so it cannot say which backend is actually serving (enforced by oxlint `no-restricted-globals` for bare reads; the Vite `define` that injected it into the client bundle is removed).
-
-Migration status: complete. All former `isGoBackend()` call sites go through the primitives — per-variant transforms are dispatched inside `src/pages/agent/utils.ts` and `src/utils/pipeline-operator.ts`, extractor initial values inside `src/pages/agent/constant/pipeline.tsx`, the parser-change dialog inside `src/pages/dataset/dataset/change-parser-dialog.tsx`, and the dataset configuration route is a single dispatcher (`src/pages/dataset/setting/`). `no-restricted-imports` is enforced at `error`.
+Do not reintroduce backend-variant primitives or detection helpers (e.g. a `useIsGoBackend` hook, `pickByBackend`, `<BackendVariant>`, or an `/api/v1/language` probe) and do not create `go/`-vs-`python/` variant directories or files.
### CSS and Layout Debugging
diff --git a/web/src/components/chunk-method-dialog/dynamic-page-range.tsx b/web/src/components/chunk-method-dialog/dynamic-page-range.tsx
deleted file mode 100644
index 97382fbef0..0000000000
--- a/web/src/components/chunk-method-dialog/dynamic-page-range.tsx
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use client';
-
-import { Button } from '@/components/ui/button';
-import {
- FormControl,
- FormDescription,
- FormField,
- FormItem,
- FormLabel,
- FormMessage,
-} from '@/components/ui/form';
-import { Input } from '@/components/ui/input';
-import { LucidePlus, LucideTrash2 } from 'lucide-react';
-import { useFieldArray, useFormContext } from 'react-hook-form';
-import { useTranslation } from 'react-i18next';
-import { Separator } from '../ui/separator';
-
-export function DynamicPageRange() {
- const { t } = useTranslation();
- const form = useFormContext();
-
- const { fields, remove, append } = useFieldArray({
- name: 'parser_config.pages',
- control: form.control,
- });
-
- return (
- <div>
- <FormLabel tooltip={t('knowledgeDetails.pageRangesTip')}>
- {t('knowledgeDetails.pageRanges')}
- </FormLabel>
- {fields.map((field, index) => {
- const typeField = `parser_config.pages.${index}.from`;
- return (
- <div key={field.id} className="flex items-center gap-2 pt-2">
- <FormField
- control={form.control}
- name={typeField}
- render={({ field }) => (
- <FormItem className="w-2/5">
- <FormDescription />
- <FormControl>
- <Input
- type="number"
- placeholder={t('common.pleaseInput')}
- className="!m-0"
- {...field}
- />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
-
- <Separator className="w-3 "></Separator>
-
- <FormField
- control={form.control}
- name={`parser_config.pages.${index}.to`}
- render={({ field }) => (
- <FormItem className="flex-1">
- <FormDescription />
- <FormControl>
- <Input
- type="number"
- placeholder={t('common.pleaseInput')}
- className="!m-0"
- {...field}
- />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
-
- <Button
- className="ml-4"
- size="icon"
- variant="outline"
- onClick={() => remove(index)}
- >
- <LucideTrash2 />
- </Button>
- </div>
- );
- })}
-
- <Button
- onClick={() => append({ from: 1, to: 100 })}
- block
- className="mt-4"
- variant="dashed"
- type="button"
- >
- <LucidePlus />
- {t('knowledgeDetails.addPage')}
- </Button>
- </div>
- );
-}
diff --git a/web/src/components/chunk-method-dialog/hooks.ts b/web/src/components/chunk-method-dialog/hooks.ts
deleted file mode 100644
index c5ceb0c33c..0000000000
--- a/web/src/components/chunk-method-dialog/hooks.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import { useCallback } from 'react';
-
-const hideAutoKeywords = ['qa', 'table', 'resume', 'tag'];
-
-export const useShowAutoKeywords = () => {
- const showAutoKeywords = useCallback((selectedTag: string | undefined) => {
- return hideAutoKeywords.every((x) => selectedTag !== x);
- }, []);
-
- return showAutoKeywords;
-};
diff --git a/web/src/components/chunk-method-dialog/index.tsx b/web/src/components/chunk-method-dialog/index.tsx
deleted file mode 100644
index 5df2125ae4..0000000000
--- a/web/src/components/chunk-method-dialog/index.tsx
+++ /dev/null
@@ -1,437 +0,0 @@
-/*
- * Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import {
- Dialog,
- DialogContent,
- DialogFooter,
- DialogHeader,
- DialogTitle,
-} from '@/components/ui/dialog';
-import {
- Form,
- FormControl,
- FormField,
- FormItem,
- FormLabel,
- FormMessage,
-} from '@/components/ui/form';
-import { DocumentParserType, ParseType } from '@/constants/knowledge';
-import { useFetchKnowledgeBaseConfiguration } from '@/hooks/use-knowledge-request';
-import { IModalProps } from '@/interfaces/common';
-import { IParserConfig } from '@/interfaces/database/document';
-import { IChangeParserRequestBody } from '@/interfaces/request/document';
-import { MetadataType } from '@/pages/dataset/components/metedata/constant';
-import {
- AutoMetadata,
- ChunkMethodItem,
- ImageContextWindow,
-} from '@/pages/dataset/setting/python/configuration/common-item';
-import { zodResolver } from '@hookform/resolvers/zod';
-import omit from 'lodash/omit';
-import { useEffect, useMemo } from 'react';
-import { useForm, useWatch } from 'react-hook-form';
-import { useTranslation } from 'react-i18next';
-import { z } from 'zod';
-import {
- AutoKeywordsFormField,
- AutoQuestionsFormField,
-} from '../auto-keywords-form-field';
-import { ChildrenDelimiterForm } from '../children-delimiter-form';
-import { DataFlowSelect } from '../data-pipeline-select';
-import { DelimiterFormField } from '../delimiter-form-field';
-import { EntityTypesFormField } from '../entity-types-form-field';
-import { ExcelToHtmlFormField } from '../excel-to-html-form-field';
-import { LayoutRecognizeFormField } from '../layout-recognize-form-field';
-import { MaxTokenNumberFormField } from '../max-token-number-from-field';
-import { MinerUOptionsFormField } from '../mineru-options-form-field';
-import { ParseTypeItem } from '../parse-type-form-field';
-import { ButtonLoading } from '../ui/button';
-import { Input } from '../ui/input';
-import { DynamicPageRange } from './dynamic-page-range';
-import { useShowAutoKeywords } from './hooks';
-import {
- useDefaultParserValues,
- useFillDefaultValueOnMount,
-} from './use-default-parser-values';
-import { FormLayout } from '@/constants/form';
-
-const FormId = 'ChunkMethodDialogForm';
-
-interface IProps extends IModalProps<IChangeParserRequestBody> {
- loading: boolean;
- parserId: string;
- pipelineId?: string;
- parserConfig: IParserConfig;
- documentExtension: string;
- documentId: string;
-}
-
-const hidePagesChunkMethods = [
- DocumentParserType.Qa,
- DocumentParserType.Table,
- DocumentParserType.Picture,
- DocumentParserType.Resume,
- DocumentParserType.One,
- DocumentParserType.KnowledgeGraph,
-];
-
-export function ChunkMethodDialog({
- hideModal,
- onOk,
- parserId,
- pipelineId,
- documentExtension,
- visible,
- parserConfig,
- loading,
- documentId,
-}: IProps) {
- const { t } = useTranslation();
-
- const { data: knowledgeDetails } = useFetchKnowledgeBaseConfiguration();
-
- const useGraphRag = useMemo(() => {
- return knowledgeDetails.parser_config?.graphrag?.use_graphrag;
- }, [knowledgeDetails.parser_config?.graphrag?.use_graphrag]);
-
- const defaultParserValues = useDefaultParserValues();
-
- const fillDefaultParserValue = useFillDefaultValueOnMount();
-
- const FormSchema = z
- .object({
- parseType: z.nativeEnum(ParseType),
- parser_id: z.string().trim().optional(),
- pipeline_id: z.string().optional(),
- parser_config: z.object({
- task_page_size: z.coerce.number().optional(),
- layout_recognize: z.string().optional(),
- chunk_token_num: z.coerce.number().optional(),
- delimiter: z.string().optional(),
- enable_children: z.boolean().optional(),
- children_delimiter: z.string().optional(),
- auto_keywords: z.coerce.number().optional(),
- auto_questions: z.coerce.number().optional(),
- html4excel: z.boolean().optional(),
- image_table_context_window: z.coerce.number().optional(),
- mineru_parse_method: z.enum(['auto', 'txt', 'ocr']).optional(),
- mineru_formula_enable: z.boolean().optional(),
- mineru_table_enable: z.boolean().optional(),
- mineru_lang: z.string().optional(),
- raptor: z
- .object({
- use_raptor: z.boolean().optional(),
- prompt: z.string().optional(),
- max_token: z.coerce.number().optional(),
- threshold: z.coerce.number().optional(),
- max_cluster: z.coerce.number().optional(),
- random_seed: z.coerce.number().optional(),
- scope: z.string().optional(),
- clustering_method: z.enum(['gmm', 'ahc']).optional(),
- tree_builder: z.enum(['raptor', 'psi']).optional(),
- })
- .optional(),
- // graphrag: z.object({
- // use_graphrag: z.boolean().optional(),
- // }),
- entity_types: z.array(z.string()).optional(),
- pages: z
- .array(z.object({ from: z.coerce.number(), to: z.coerce.number() }))
- .refine(
- (ranges) =>
- ranges.every(
- (r) =>
- Number.isInteger(r.from) &&
- Number.isInteger(r.to) &&
- r.from >= 1 &&
- r.from <= r.to,
- ),
- {
- message:
- 'page range invalid: from/to must be integers, from >= 1, from <= to',
- },
- )
- .optional(),
- metadata: z.any().optional(),
- built_in_metadata: z
- .array(
- z.object({
- key: z.string().optional(),
- type: z.string().optional(),
- }),
- )
- .optional(),
- enable_metadata: z.boolean().optional(),
- }),
- })
- .superRefine((data, ctx) => {
- if (data.parseType === ParseType.BuiltIn && !data.parser_id) {
- ctx.addIssue({
- path: ['parser_id'],
- message: t('common.pleaseSelect'),
- code: 'custom',
- });
- }
- if (data.parseType === ParseType.Pipeline && !data.pipeline_id) {
- ctx.addIssue({
- path: ['pipeline_id'],
- message: t('common.pleaseSelect'),
- code: 'custom',
- });
- }
- });
-
- const form = useForm<z.infer<typeof FormSchema>>({
- resolver: zodResolver(FormSchema),
- defaultValues: {
- parser_id: parserId || '',
- pipeline_id: pipelineId || '',
- parseType: pipelineId ? ParseType.Pipeline : ParseType.BuiltIn,
- parser_config: defaultParserValues,
- },
- });
-
- const layoutRecognize = useWatch({
- name: 'parser_config.layout_recognize',
- control: form.control,
- });
-
- const selectedTag = useWatch({
- name: 'parser_id',
- control: form.control,
- });
- const isMineruSelected =
- selectedTag?.toLowerCase().includes('mineru') ||
- layoutRecognize?.toLowerCase?.()?.includes('mineru');
-
- const isPdf = documentExtension === 'pdf';
-
- const showPages = useMemo(() => {
- return isPdf && hidePagesChunkMethods.every((x) => x !== selectedTag);
- }, [selectedTag, isPdf]);
-
- const showOne = useMemo(() => {
- return (
- isPdf &&
- hidePagesChunkMethods
- .filter((x) => x !== DocumentParserType.One)
- .every((x) => x !== selectedTag)
- );
- }, [selectedTag, isPdf]);
-
- const showMaxTokenNumber =
- selectedTag === DocumentParserType.Naive ||
- selectedTag === DocumentParserType.KnowledgeGraph;
-
- const showEntityTypes = selectedTag === DocumentParserType.KnowledgeGraph;
-
- const showExcelToHtml =
- selectedTag === DocumentParserType.Naive && documentExtension === 'xlsx';
-
- const showAutoKeywords = useShowAutoKeywords();
-
- async function onSubmit(data: z.infer<typeof FormSchema>) {
- const parserConfig = { ...data.parser_config };
- const imageTableContextWindow = Number(
- parserConfig?.image_table_context_window || 0,
- );
- const nextData = {
- ...data,
- parser_id: data.parser_id || '',
- parser_config: {
- ...parserConfig,
- image_table_context_window: imageTableContextWindow,
- image_context_size: imageTableContextWindow,
- table_context_size: imageTableContextWindow,
- // Unset children delimiter if this option is not enabled
- children_delimiter: parserConfig.enable_children
- ? parserConfig.children_delimiter
- : '',
- pages: parserConfig?.pages?.map((x: any) => [x.from, x.to]) ?? [],
- },
- };
- const ret = await onOk?.(nextData);
- if (ret) {
- hideModal?.();
- }
- }
-
- useEffect(() => {
- if (visible) {
- const pages =
- parserConfig?.pages?.map((x) => ({ from: x[0], to: x[1] })) ?? [];
- form.reset({
- parser_id: parserId || '',
- pipeline_id: pipelineId || '',
- parseType: pipelineId ? ParseType.Pipeline : ParseType.BuiltIn,
- parser_config: fillDefaultParserValue({
- pages: pages.length > 0 ? pages : [{ from: 1, to: 100000 }],
- ...omit(parserConfig, 'pages'),
- image_table_context_window:
- parserConfig?.image_table_context_window ??
- parserConfig?.image_context_size ??
- parserConfig?.table_context_size,
- // graphrag: {
- // use_graphrag: get(
- // parserConfig,
- // 'graphrag.use_graphrag',
- // useGraphRag,
- // ),
- // },
- }),
- });
- }
- }, [
- fillDefaultParserValue,
- form,
- knowledgeDetails.parser_config,
- parserConfig,
- parserId,
- pipelineId,
- useGraphRag,
- visible,
- ]);
- const parseType = useWatch({
- control: form.control,
- name: 'parseType',
- defaultValue: pipelineId ? ParseType.Pipeline : ParseType.BuiltIn,
- });
- useEffect(() => {
- if (parseType === ParseType.BuiltIn) {
- form.setValue('pipeline_id', '');
- }
- }, [parseType, form]);
- return (
- <Dialog open onOpenChange={hideModal}>
- <DialogContent className="max-w-[50vw] text-text-primary">
- <DialogHeader>
- <DialogTitle>{t('knowledgeDetails.chunkMethod')}</DialogTitle>
- </DialogHeader>
-
- <Form {...form}>
- <form
- onSubmit={form.handleSubmit(onSubmit)}
- className="space-y-6 max-h-[70vh] overflow-auto -mx-6 px-10 py-5"
- id={FormId}
- >
- <div className="space-y-6">
- <ParseTypeItem />
- {parseType === ParseType.BuiltIn && <ChunkMethodItem />}
-
- {showPages && parseType === ParseType.BuiltIn && (
- <DynamicPageRange />
- )}
-
- {showPages &&
- parseType === ParseType.BuiltIn &&
- layoutRecognize && (
- <FormField
- control={form.control}
- name="parser_config.task_page_size"
- render={({ field }) => (
- <FormItem>
- <FormLabel
- tooltip={t('knowledgeDetails.taskPageSizeTip')}
- >
- {t('knowledgeDetails.taskPageSize')}
- </FormLabel>
- <FormControl>
- <Input {...field} type={'number'} min={1} max={128} />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
- )}
- </div>
-
- {parseType === ParseType.BuiltIn && (
- <>
- <div className="space-y-6 border-t-0.5 border-border-button pt-6 empty:hidden">
- {showOne && (
- <>
- <LayoutRecognizeFormField showMineruOptions={false} />
- {isMineruSelected && <MinerUOptionsFormField />}
- </>
- )}
-
- {showMaxTokenNumber && (
- <>
- <MaxTokenNumberFormField
- max={
- selectedTag === DocumentParserType.KnowledgeGraph
- ? 8192 * 2
- : 2048
- }
- />
- <DelimiterFormField />
- <ChildrenDelimiterForm />
- </>
- )}
- </div>
-
- <div className="space-y-6 border-t-0.5 border-border-button pt-6 empty:hidden">
- {selectedTag === DocumentParserType.Naive && (
- <ImageContextWindow />
- )}
-
- {showAutoKeywords(selectedTag) && (
- <>
- <AutoMetadata
- type={MetadataType.SingleFileSetting}
- otherData={{ documentId }}
- />
- <AutoKeywordsFormField
- layout={FormLayout.Horizontal}
- ></AutoKeywordsFormField>
- <AutoQuestionsFormField
- layout={FormLayout.Horizontal}
- ></AutoQuestionsFormField>
- </>
- )}
-
- {showExcelToHtml && (
- <ExcelToHtmlFormField></ExcelToHtmlFormField>
- )}
- </div>
-
- <div className="space-y-6 border-t-0.5 border-border-button pt-6 empty:hidden">
- {showEntityTypes && <EntityTypesFormField />}
- </div>
- </>
- )}
-
- <div className="space-y-6 empty:hidden">
- {parseType === ParseType.Pipeline && (
- <DataFlowSelect
- isMult={false}
- // toDataPipeline={navigateToAgents}
- formFieldName="pipeline_id"
- />
- )}
- </div>
- </form>
- </Form>
- <DialogFooter>
- <ButtonLoading type="submit" form={FormId} loading={loading}>
- {t('common.save')}
- </ButtonLoading>
- </DialogFooter>
- </DialogContent>
- </Dialog>
- );
-}
diff --git a/web/src/components/chunk-method-dialog/use-default-parser-values.ts b/web/src/components/chunk-method-dialog/use-default-parser-values.ts
deleted file mode 100644
index 79480c2206..0000000000
--- a/web/src/components/chunk-method-dialog/use-default-parser-values.ts
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import { IParserConfig } from '@/interfaces/database/document';
-import { useCallback, useMemo } from 'react';
-import { useTranslation } from 'react-i18next';
-import { ParseDocumentType } from '../layout-recognize-form-field';
-
-export function useDefaultParserValues() {
- const { t } = useTranslation();
-
- const defaultParserValues = useMemo(() => {
- const defaultParserValues = {
- task_page_size: 12,
- layout_recognize: ParseDocumentType.DeepDOC,
- chunk_token_num: 512,
- delimiter: '\n',
- enable_children: false,
- children_delimiter: '\n',
- auto_keywords: 0,
- auto_questions: 0,
- html4excel: false,
- image_table_context_window: 0,
- raptor: {
- use_raptor: false,
- prompt: t('knowledgeConfiguration.promptText'),
- max_token: 256,
- threshold: 0.1,
- max_cluster: 64,
- random_seed: 0,
- scope: 'file',
- clustering_method: 'gmm',
- tree_builder: 'raptor',
- },
- // graphrag: {
- // use_graphrag: false,
- // },
- entity_types: [],
- pages: [],
- metadata: [],
- built_in_metadata: [],
- enable_metadata: false,
- };
-
- return defaultParserValues as IParserConfig;
- }, [t]);
-
- return defaultParserValues;
-}
-
-export function useFillDefaultValueOnMount() {
- const defaultParserValues = useDefaultParserValues();
-
- const fillDefaultValue = useCallback(
- (parserConfig: IParserConfig) => {
- return Object.entries(defaultParserValues).reduce<Record<string, any>>(
- (pre, [key, value]) => {
- if (key in parserConfig) {
- pre[key] = parserConfig[key as keyof IParserConfig];
- } else {
- pre[key] = value;
- }
- return pre;
- },
- {},
- );
- },
- [defaultParserValues],
- );
-
- return fillDefaultValue;
-}
diff --git a/web/src/hooks/__tests__/parser-config-utils.test.ts b/web/src/hooks/__tests__/parser-config-utils.test.ts
index 1076ea8a61..c2a3afe7b7 100644
--- a/web/src/hooks/__tests__/parser-config-utils.test.ts
+++ b/web/src/hooks/__tests__/parser-config-utils.test.ts
@@ -16,13 +16,6 @@
import { normalizeParserConfig } from '@/hooks/parser-config-utils';
-// Drive the backend variant the same way the existing frontend tests do.
-let mockIsGoBackend = true;
-jest.mock('@/utils/backend-runtime', () => ({
- getBackendLanguage: () => (mockIsGoBackend ? 'go' : 'python'),
- subscribeBackendLanguage: jest.fn(),
-}));
-
const baseConfig = {
chunk_token_num: 128,
layout_recognize: 'DeepDOC',
@@ -66,25 +59,6 @@ describe('normalizeParserConfig backend awareness', () => {
expect(out).not.toHaveProperty('raptor');
});
- it('keeps the flat-key contract for the Python backend', () => {
- mockIsGoBackend = false;
- const out = normalizeParserConfig({
- ...baseConfig,
- }) as Record<string, any>;
-
- expect(out.metadata).toEqual({
- enabled: true,
- metadata: [],
- built_in_metadata: [],
- });
- expect(out.parent_child).toEqual({
- children_delimiter: '!?;',
- use_parent_child: true,
- });
- expect(out).not.toHaveProperty('Extractor:AutoExtractDefault');
- expect(out).not.toHaveProperty('GeneralChunker:SixApplesFall');
- });
-
it('does not scope anything when metadata/parent_child are absent but still re-homes chunk_token_num', () => {
const out = normalizeParserConfig({
chunk_token_num: 128,
diff --git a/web/src/hooks/__tests__/use-dataset-generate-status.test.tsx b/web/src/hooks/__tests__/use-dataset-generate-status.test.tsx
index 3ba50464ce..d7f16bfa3d 100644
--- a/web/src/hooks/__tests__/use-dataset-generate-status.test.tsx
+++ b/web/src/hooks/__tests__/use-dataset-generate-status.test.tsx
@@ -9,17 +9,13 @@ jest.mock('react-router', () => ({
useParams: jest.fn(() => ({ id: 'kb1' })),
}));
-jest.mock('@/utils/backend-variant', () => ({
- useIsGoBackend: jest.fn(() => true),
-}));
-
jest.mock('@/services/knowledge-service', () => ({
getDatasetCompilationStatus: jest.fn(),
}));
// use-dataset-generate imports agent-service (and transitively register-server /
// next-request / locales config that touch import.meta.env). Mock it so the
-// Go status path under test doesn't pull in that module graph.
+// status path under test doesn't pull in that module graph.
jest.mock('@/services/agent-service', () => ({
__esModule: true,
default: { cancelDataflow: jest.fn(), deletePipelineTask: jest.fn() },
@@ -30,7 +26,6 @@ jest.mock('react-i18next', () => ({
}));
import { getDatasetCompilationStatus } from '@/services/knowledge-service';
-import { useIsGoBackend } from '@/utils/backend-variant';
const mockStatus = jest.mocked(getDatasetCompilationStatus);
@@ -53,10 +48,9 @@ function makeWrapper() {
return Wrapper;
}
-describe('useTraceRunData (Go compile-status contract)', () => {
+describe('useTraceRunData (compile-status contract)', () => {
beforeEach(() => {
jest.clearAllMocks();
- (useIsGoBackend as jest.Mock).mockReturnValue(true);
});
it('maps a successful status to the scheduler contract fields', async () => {
diff --git a/web/src/hooks/__tests__/use-document-request-cancel-chain.test.tsx b/web/src/hooks/__tests__/use-document-request-cancel-chain.test.tsx
index 630122efc7..07a8ae8343 100644
--- a/web/src/hooks/__tests__/use-document-request-cancel-chain.test.tsx
+++ b/web/src/hooks/__tests__/use-document-request-cancel-chain.test.tsx
@@ -44,13 +44,6 @@ jest.mock('@/locales/config', () => ({
default: { t: (key: string) => key },
}));
-// `pickByBackend` keeps the real dataset predicates on the Go branch, which is
-// what the list's polling and the stop-loss read.
-jest.mock('@/utils/backend-variant', () => ({
- useIsGoBackend: () => true,
- pickByBackend: ({ go }: { go: unknown }) => go,
-}));
-
jest.mock('@/hooks/logic-hooks', () => ({
useGetPaginationWithRouter: () => ({
pagination: { current: 1, pageSize: 30, total: 0 },
diff --git a/web/src/hooks/parser-config-utils.test.ts b/web/src/hooks/parser-config-utils.test.ts
index 298bd86500..3ddb8ffdf7 100644
--- a/web/src/hooks/parser-config-utils.test.ts
+++ b/web/src/hooks/parser-config-utils.test.ts
@@ -16,23 +16,10 @@
import { normalizeParserConfig } from './parser-config-utils';
-// Force the Go backend branch inside normalizeParserConfig.
-let mockIsGo = true;
-
-jest.mock('@/utils/backend-variant', () => ({
- useIsGoBackend: () => mockIsGo,
- pickByBackend: (variants: { go: unknown; python: unknown }) =>
- mockIsGo ? variants.go : variants.python,
-}));
-
const CHUNKER = 'GeneralChunker:SixApplesFall';
const EXTRACTOR = 'Extractor:AutoExtractDefault';
-describe('normalizeParserConfig (Go backend)', () => {
- beforeEach(() => {
- mockIsGo = true;
- });
-
+describe('normalizeParserConfig', () => {
it('drops flat parser-level keys and keeps only component-scoped keys', () => {
const out = normalizeParserConfig({
chunk_token_num: 256,
diff --git a/web/src/hooks/parser-config-utils.ts b/web/src/hooks/parser-config-utils.ts
index 1884887b4c..c5308b25a6 100644
--- a/web/src/hooks/parser-config-utils.ts
+++ b/web/src/hooks/parser-config-utils.ts
@@ -14,8 +14,6 @@
* limitations under the License.
*/
-import { pickByBackend } from '@/utils/backend-variant';
-
/**
* Pipeline parser configs are keyed by operator id (e.g. "Parser:xxx"), so a
* top-level key containing ":" marks the pipeline structure, which must be
@@ -109,32 +107,10 @@ export const normalizeParserConfig = (
? { use_parent_child: false }
: undefined;
- // Python backend: keep the legacy flat-key contract unchanged.
- if (!pickByBackend({ go: true, python: false })) {
- return {
- auto_keywords,
- auto_questions,
- chunk_token_num,
- delimiter,
- html4excel,
- layout_recognize,
- tag_kb_ids,
- topn_tags,
- filename_embd_weight,
- task_page_size,
- pages,
- children_delimiter,
- enable_children,
- metadata,
- ...(parentChild ? { parent_child: parentChild } : {}),
- ...additionalParserConfig,
- };
- }
-
- // Go backend: emit ONLY component-scoped keys. The legacy flat parser-level
- // keys have no consumer on the Go backend (the built-in path reads component
- // nodes, e.g. GeneralChunker:SixApplesFall.chunk_token_size), so they are
- // dropped rather than forwarded. Already-scoped keys pass through untouched.
+ // Emit ONLY component-scoped keys. The legacy flat parser-level keys have no
+ // consumer (the built-in path reads component nodes, e.g.
+ // GeneralChunker:SixApplesFall.chunk_token_size), so they are dropped rather
+ // than forwarded. Already-scoped keys pass through untouched.
const scoped: Record<string, any> = {};
for (const [key, value] of Object.entries(additionalParserConfig)) {
if (key.includes(':')) {
diff --git a/web/src/hooks/use-dataset-generate.ts b/web/src/hooks/use-dataset-generate.ts
index 37cc75f57c..cd390b2147 100644
--- a/web/src/hooks/use-dataset-generate.ts
+++ b/web/src/hooks/use-dataset-generate.ts
@@ -18,19 +18,14 @@ import message from '@/components/ui/message';
import {
GenerateStatus,
GenerateType,
- GenerateTypeMap,
ProcessingType,
TraceType,
} from '@/constants/knowledge';
-import agentService from '@/services/agent-service';
import {
deletePipelineTask,
getDatasetCompilationStatus,
- runIndex,
- traceIndex,
} from '@/services/knowledge-service';
-import { useIsGoBackend } from '@/utils/backend-variant';
-import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
+import { useMutation, useQuery } from '@tanstack/react-query';
import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router';
@@ -66,11 +61,11 @@ export interface ITraceInfo {
to_page: number;
update_date: string;
update_time: number;
- // Go scheduler compile-status contract. These
- // replace the legacy task percentage for the Go backend: state is the raw
- // dataset-level lifecycle (idle/pending/running/completed), inflight/backlog
- // are the MySQL scheduling-entry counts, and error is the batch diagnostic
- // (NOT a peer state). Only populated by the Go branch of useTraceQuery.
+ // Scheduler compile-status contract. These replace the legacy task
+ // percentage: state is the raw dataset-level lifecycle
+ // (idle/pending/running/completed), inflight/backlog are the MySQL
+ // scheduling-entry counts, and error is the batch diagnostic (NOT a peer
+ // state).
compilationState?: string;
currentPhase?: string;
inflight?: number;
@@ -84,22 +79,15 @@ const useTraceQuery = (
open: boolean,
id?: string,
) => {
- const isGo = useIsGoBackend();
return useQuery<ITraceInfo>({
queryKey: DatasetGenerateKeys.trace(type, id, open),
gcTime: 0,
refetchInterval: (query) => {
- const progress = query.state.data?.progress;
- // Go: keep polling while the dataset compile is pending/running
+ // Keep polling while the dataset compile is pending/running
// (a failed batch is left for retry, so the row stays running/pending and
// we keep polling until it drains to completed).
- if (isGo) {
- const state = query.state.data?.compilationState;
- return state === 'pending' || state === 'running'
- ? PollIntervalMs
- : false;
- }
- return progress != null && progress >= 0 && progress < 1
+ const state = query.state.data?.compilationState;
+ return state === 'pending' || state === 'running'
? PollIntervalMs
: false;
},
@@ -107,40 +95,36 @@ const useTraceQuery = (
retryDelay: 1000,
enabled: open && !!id,
queryFn: async () => {
- if (isGo) {
- // Scheduler compile-status contract (dataset-level, variant-agnostic).
- // The status is NOT a task percentage: we carry the raw state, the
- // MySQL inflight/backlog entry counts and the error diagnostic, and
- // derive the display status in useGenerateStatus. progress is only set
- // so the shared refetch/status helpers keep their contract (idle->0,
- // running/pending->0, completed->1, error->0). The traceType doubles as
- // the backend `kind` alias, scoping state/counts/error to this compile
- // type so views don't leak each other's dataset-wide aggregate.
- const res = await getDatasetCompilationStatus(id!, traceType);
- const data = res?.data;
- // The handler returns HTTP 200 with a non-zero business code for
- // authorization/business errors (e.g. "no authorization"). The request
- // interceptor only shows a toast and does not reject, so without this
- // explicit check a failed read would be mapped to a misleading idle
- // state. Reject so the query surfaces the error instead.
- if (!data || data.code !== 0) {
- throw new Error(data?.message || 'Failed to read compilation status');
- }
- const st = data.data ?? {};
- const state: string = st.state ?? 'idle';
- const error: string = st.error ?? '';
- return {
- progress: state === 'completed' ? 1 : (st.progress ?? 0),
- progress_msg: st.progress_msg || error || state,
- compilationState: state,
- currentPhase: st.current_phase ?? '',
- inflight: st.inflight ?? 0,
- backlog: st.backlog ?? 0,
- compilationError: error,
- } as ITraceInfo;
+ // Scheduler compile-status contract (dataset-level). The status is NOT a
+ // task percentage: we carry the raw state, the MySQL inflight/backlog
+ // entry counts and the error diagnostic, and derive the display status
+ // in useGenerateStatus. progress is only set so the shared
+ // refetch/status helpers keep their contract (idle->0,
+ // running/pending->0, completed->1, error->0). The traceType doubles as
+ // the backend `kind` alias, scoping state/counts/error to this compile
+ // type so views don't leak each other's dataset-wide aggregate.
+ const res = await getDatasetCompilationStatus(id!, traceType);
+ const data = res?.data;
+ // The handler returns HTTP 200 with a non-zero business code for
+ // authorization/business errors (e.g. "no authorization"). The request
+ // interceptor only shows a toast and does not reject, so without this
+ // explicit check a failed read would be mapped to a misleading idle
+ // state. Reject so the query surfaces the error instead.
+ if (!data || data.code !== 0) {
+ throw new Error(data?.message || 'Failed to read compilation status');
}
- const { data } = await traceIndex(id!, traceType);
- return data?.data ?? {};
+ const st = data.data ?? {};
+ const state: string = st.state ?? 'idle';
+ const error: string = st.error ?? '';
+ return {
+ progress: state === 'completed' ? 1 : (st.progress ?? 0),
+ progress_msg: st.progress_msg || error || state,
+ compilationState: state,
+ currentPhase: st.current_phase ?? '',
+ inflight: st.inflight ?? 0,
+ backlog: st.backlog ?? 0,
+ compilationError: error,
+ } as ITraceInfo;
},
});
};
@@ -189,118 +173,57 @@ export const useUnBindTask = () => {
};
export const useDatasetGenerate = () => {
- const queryClient = useQueryClient();
- const { id } = useParams();
- const { handleUnbindTask } = useUnBindTask();
const { t } = useTranslation();
- const isGo = useIsGoBackend();
+ // Dataset compilation is driven automatically by the scheduler on document
+ // completion; there is no manual trigger, so a manual "generate" must NOT
+ // pretend to succeed. The UI hides/disables the control; if it is ever
+ // invoked, reject loudly so callers don't mistake it for a real run.
const {
data,
isPending: loading,
mutateAsync,
} = useMutation({
mutationKey: [DatasetKey.generate],
- mutationFn: async ({ type }: { type: GenerateType }) => {
- // Go: dataset compilation is driven automatically by the scheduler
- // on document completion; there is no manual RunIndex trigger, so a manual
- // "generate" must NOT pretend to succeed. The UI hides/disables the
- // control; if it is ever invoked, reject loudly so callers don't mistake
- // it for a real run (plan v4.1 §4.2).
- if (isGo) {
- throw new Error(t('message.compileNotSupported'));
- }
- const { data } = await runIndex(id!, TraceTypeMap[type]);
- if (data.code === 0) {
- message.success(t('message.operated'));
- queryClient.invalidateQueries({
- queryKey: DatasetGenerateKeys.traceById(type, id),
- });
- }
- return data;
+ mutationFn: async (_: { type: GenerateType }) => {
+ throw new Error(t('message.compileNotSupported'));
},
});
+ // The scheduler has no task-level cancel; dataset compilation is
+ // auto-driven. There is no pause to perform, so reject rather than report
+ // success (the UI hides the pause control).
const { mutateAsync: pauseGenerate } = useMutation({
mutationKey: [DatasetKey.pauseGenerate],
- mutationFn: async ({
- task_id,
- type,
- }: {
- task_id: string;
- type: GenerateType;
- }) => {
- // Go: the scheduler has no task-level cancel; dataset compilation
- // is auto-driven. There is no pause to perform, so reject rather than
- // report success (the UI hides the pause control — plan v4.1 §4.2).
- if (isGo) {
- throw new Error(t('message.compileNotSupported'));
- }
- const { data } = await agentService.cancelDataflow(task_id);
-
- // For GraphRAG, pause must preserve partial progress (subgraphs,
- // entities, relations, community reports) so the next run_graphrag
- // call can resume instead of redoing hours of LLM extraction. Raptor
- // keeps the prior wipe-on-pause behaviour for now.
- const unbindData = await handleUnbindTask({
- type: GenerateTypeMap[type as GenerateType],
- wipe: type === GenerateType.KnowledgeGraph ? false : undefined,
- });
- if (data.code === 0 && unbindData.code === 0) {
- queryClient.invalidateQueries({
- queryKey: DatasetGenerateKeys.traceById(type, id),
- });
- }
- return data;
+ mutationFn: async (_: { task_id: string; type: GenerateType }) => {
+ throw new Error(t('message.compileNotSupported'));
},
});
return { runGenerate: mutateAsync, pauseGenerate, data, loading };
};
export function useGenerateStatus(data?: ITraceInfo) {
- const isGo = useIsGoBackend();
const status = useMemo(() => {
if (!data) {
return GenerateStatus.Start;
}
- if (isGo) {
- // Go: derive from the scheduler contract, not a fake task
- // percentage. Error diagnostic takes priority; otherwise map the raw
- // dataset-level state (completed->Completed, idle->Start, running/pending
- // ->Running).
- if (data.compilationError) {
- return GenerateStatus.Failed;
- }
- const st = data.compilationState;
- if (st === 'completed') return GenerateStatus.Completed;
- if (st === 'running' || st === 'pending') return GenerateStatus.Running;
- return GenerateStatus.Start;
- }
- if (data.progress >= 1) {
- return GenerateStatus.Completed;
- } else if (!data.progress && data.progress !== 0) {
- return GenerateStatus.Start;
- } else if (data.progress < 0) {
+ // Derive from the scheduler contract, not a fake task percentage. Error
+ // diagnostic takes priority; otherwise map the raw dataset-level state
+ // (completed->Completed, idle->Start, running/pending->Running).
+ if (data.compilationError) {
return GenerateStatus.Failed;
- } else if (data.progress < 1) {
- return GenerateStatus.Running;
}
+ const st = data.compilationState;
+ if (st === 'completed') return GenerateStatus.Completed;
+ if (st === 'running' || st === 'pending') return GenerateStatus.Running;
return GenerateStatus.Start;
- }, [data, isGo]);
+ }, [data]);
- const percent = useMemo(() => {
- if (isGo) {
- return status === GenerateStatus.Failed
- ? 100
- : (data?.progress ?? 0) * 100;
- }
- if (status === GenerateStatus.Failed) {
- return 100;
- } else if (status === GenerateStatus.Running) {
- return data!.progress * 100;
- }
- return 0;
- }, [status, data, isGo]);
+ const percent = useMemo(
+ () =>
+ status === GenerateStatus.Failed ? 100 : (data?.progress ?? 0) * 100,
+ [status, data],
+ );
return { status, percent };
}
diff --git a/web/src/hooks/use-dataset-nav-request.ts b/web/src/hooks/use-dataset-nav-request.ts
index 608cc04f0b..347ba13055 100644
--- a/web/src/hooks/use-dataset-nav-request.ts
+++ b/web/src/hooks/use-dataset-nav-request.ts
@@ -14,11 +14,10 @@
* limitations under the License.
*/
-import message from '@/components/ui/message';
import { DatasetNavList } from '@/interfaces/database/dataset-nav';
import i18n from '@/locales/config';
import datasetNavService from '@/services/dataset-nav-service';
-import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
+import { useQuery } from '@tanstack/react-query';
import { trim } from 'lodash';
import { useKnowledgeBaseId } from './use-knowledge-request';
@@ -117,54 +116,3 @@ export function useFetchDatasetNavChildren(
return { data, loading, isError, error, refetch };
}
-
-export function useDeleteDatasetNav() {
- const kbId = useKnowledgeBaseId();
- const queryClient = useQueryClient();
-
- const {
- data,
- isPending: loading,
- mutateAsync,
- } = useMutation({
- mutationFn: async () => {
- const { data } = await datasetNavService.deleteNav({ datasetId: kbId });
- if (data?.code === 0) {
- message.success(i18n.t('message.deleted'));
- queryClient.invalidateQueries({
- queryKey: DatasetNavKeys.all(kbId),
- });
- }
- return data;
- },
- });
-
- return { data, loading, deleteNav: mutateAsync };
-}
-
-export function useDeleteDatasetNavNode() {
- const kbId = useKnowledgeBaseId();
- const queryClient = useQueryClient();
-
- const {
- data,
- isPending: loading,
- mutateAsync,
- } = useMutation({
- mutationFn: async (name: string) => {
- const { data } = await datasetNavService.deleteNavNode({
- datasetId: kbId,
- name,
- });
- if (data?.code === 0) {
- message.success(i18n.t('message.deleted'));
- queryClient.invalidateQueries({
- queryKey: DatasetNavKeys.all(kbId),
- });
- }
- return data;
- },
- });
-
- return { data, loading, deleteNavNode: mutateAsync };
-}
diff --git a/web/src/hooks/use-dataset-skill-request.ts b/web/src/hooks/use-dataset-skill-request.ts
index 2541261218..241faf42c4 100644
--- a/web/src/hooks/use-dataset-skill-request.ts
+++ b/web/src/hooks/use-dataset-skill-request.ts
@@ -14,14 +14,12 @@
* limitations under the License.
*/
-import message from '@/components/ui/message';
import {
DatasetSkillPage,
DatasetSkillTree,
} from '@/interfaces/database/dataset-skill';
-import i18n from '@/locales/config';
import datasetSkillService from '@/services/dataset-skill-service';
-import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
+import { useQuery } from '@tanstack/react-query';
import { useKnowledgeBaseId } from './use-knowledge-request';
@@ -69,56 +67,3 @@ export function useFetchDatasetSkillPage(skillKwd: string | null | undefined) {
return { data, loading };
}
-
-export function useDeleteDatasetSkillTree() {
- const kbId = useKnowledgeBaseId();
- const queryClient = useQueryClient();
-
- const {
- data,
- isPending: loading,
- mutateAsync,
- } = useMutation({
- mutationFn: async () => {
- const { data } = await datasetSkillService.deleteTree({
- datasetId: kbId,
- });
- if (data?.code === 0) {
- message.success(i18n.t('message.deleted'));
- queryClient.invalidateQueries({
- queryKey: DatasetSkillKeys.all(kbId),
- });
- }
- return data;
- },
- });
-
- return { data, loading, deleteSkillTree: mutateAsync };
-}
-
-export function useDeleteDatasetSkillPage() {
- const kbId = useKnowledgeBaseId();
- const queryClient = useQueryClient();
-
- const {
- data,
- isPending: loading,
- mutateAsync,
- } = useMutation({
- mutationFn: async (skillKwd: string) => {
- const { data } = await datasetSkillService.deletePage({
- datasetId: kbId,
- skillKwd,
- });
- if (data?.code === 0) {
- message.success(i18n.t('message.deleted'));
- queryClient.invalidateQueries({
- queryKey: DatasetSkillKeys.all(kbId),
- });
- }
- return data;
- },
- });
-
- return { data, loading, deleteSkillPage: mutateAsync };
-}
diff --git a/web/src/hooks/use-document-request.ts b/web/src/hooks/use-document-request.ts
index 060b468010..1f73b0140f 100644
--- a/web/src/hooks/use-document-request.ts
+++ b/web/src/hooks/use-document-request.ts
@@ -17,7 +17,7 @@
import { useHandleFilterSubmit } from '@/components/list-filter-bar/use-handle-filter-submit';
import message from '@/components/ui/message';
-import { IngestionTaskStatus, RunningStatus } from '@/constants/knowledge';
+import { IngestionTaskStatus } from '@/constants/knowledge';
import { ResponseType } from '@/interfaces/database/base';
import { IReferenceChunk } from '@/interfaces/database/chat';
import { IChunk } from '@/interfaces/database/dataset';
@@ -56,7 +56,6 @@ import kbService, {
uploadDocument,
} from '@/services/knowledge-service';
import { restAPIv1 } from '@/utils/api';
-import { useIsGoBackend } from '@/utils/backend-variant';
import { buildChunkHighlights } from '@/utils/document-util';
import {
keepPreviousData,
@@ -197,7 +196,6 @@ export const useFetchDocumentList = (loop = true) => {
const { pagination, setPagination } = useGetPaginationWithRouter();
const { id } = useParams();
const queryClient = useQueryClient();
- const isGo = useIsGoBackend();
const debouncedSearchString = useDebounce(searchString, { wait: 500 });
const { filterValue, handleFilterSubmit, checkValue } =
useHandleFilterSubmit();
@@ -294,9 +292,6 @@ export const useFetchDocumentList = (loop = true) => {
// data.docs reference-identical while a stopped document's fields no longer
// change, which is exactly the stuck case this has to fire in.
useEffect(() => {
- if (!isGo) {
- return;
- }
const overdueIds = observeStoppingDocuments(
data.docs.map((doc) => doc.id),
data.docs.filter(isDocumentStopping).map((doc) => doc.id),
@@ -317,7 +312,7 @@ export const useFetchDocumentList = (loop = true) => {
},
() => {},
);
- }, [data.docs, dataUpdatedAt, isGo, queryClient]);
+ }, [data.docs, dataUpdatedAt, queryClient]);
return {
loading,
@@ -457,7 +452,6 @@ export const useSetDocumentStatus = () => {
// This hook is used to run a document by its IDs
export const useRunDocument = () => {
const queryClient = useQueryClient();
- const isGo = useIsGoBackend();
const {
data,
@@ -476,10 +470,9 @@ export const useRunDocument = () => {
}) => {
// Optimistically move started documents into an active state so the
// 5s list polling starts immediately and the row leaves its idle
- // action. Python drives the worker through the legacy run field
- // (RUNNING); Go has no run field and reports the task lifecycle via
- // ingestion_status, so CREATED renders as QUEUED until the next poll
- // observes the real status (SCHEDULED/RUNNING/COMPLETED/...).
+ // action. The task lifecycle is reported via ingestion_status, so
+ // CREATED renders as QUEUED until the next poll observes the real
+ // status (SCHEDULED/RUNNING/COMPLETED/...).
if (run === 1) {
const documentIdSet = new Set(documentIds);
queryClient.setQueriesData<{
@@ -495,9 +488,7 @@ export const useRunDocument = () => {
documentIdSet.has(doc.id)
? {
...doc,
- ...(isGo
- ? { ingestion_status: IngestionTaskStatus.CREATED }
- : { run: RunningStatus.RUNNING }),
+ ingestion_status: IngestionTaskStatus.CREATED,
progress: 0,
process_duration: 0,
process_begin_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
@@ -520,9 +511,7 @@ export const useRunDocument = () => {
// all() prefix also covers the byIds views, so their in-flight
// refetches are dropped the same way.
await queryClient.cancelQueries({ queryKey: DocumentKeys.all() });
- if (isGo) {
- markCancelRequested(documentIds);
- }
+ markCancelRequested(documentIds);
const documentIdSet = new Set(documentIds);
queryClient.setQueriesData<{
docs: IDocumentInfo[];
@@ -537,9 +526,7 @@ export const useRunDocument = () => {
documentIdSet.has(doc.id)
? {
...doc,
- ...(isGo
- ? { ingestion_status: IngestionTaskStatus.STOPPING }
- : { run: RunningStatus.CANCEL }),
+ ingestion_status: IngestionTaskStatus.STOPPING,
}
: doc,
),
@@ -652,65 +639,10 @@ export const useSaveDocumentName = () => {
return { loading, saveName: mutateAsync, data };
};
-export const useSetDocumentParser = () => {
- const queryClient = useQueryClient();
-
- const {
- data,
- isPending: loading,
- mutateAsync,
- } = useMutation({
- mutationKey: [DocumentApiAction.SetDocumentParser],
- mutationFn: async ({
- parserId,
- pipelineId,
- documentId,
- datasetId,
- parserConfig,
- }: {
- parserId: string;
- pipelineId: string;
- documentId: string;
- datasetId: string;
- parserConfig?: IChangeParserConfigRequestBody;
- }) => {
- // Build update payload
- const updateData: Record<string, unknown> = {};
- if (pipelineId) {
- updateData.pipeline_id = pipelineId;
- } else if (parserId) {
- updateData.chunk_method = parserId;
- }
-
- if (parserConfig) {
- updateData.parser_config = normalizeParserConfig(parserConfig);
- }
-
- const { data } = await changeDocumentParser(
- datasetId,
- documentId,
- updateData,
- );
- if (data.code === 0) {
- queryClient.invalidateQueries({
- queryKey: DocumentKeys.all(),
- });
-
- message.success(i18n.t('message.modified'));
- }
- return data.code;
- },
- });
-
- return { setDocumentParser: mutateAsync, data, loading };
-};
-
/**
- * Go-backend variant of useSetDocumentParser. The Go document endpoint takes
- * `parser_id` (instead of the legacy `chunk_method`) and expects the
- * pipeline-shaped parser_config (keyed by operator id) to be sent as-is.
- * Keep it parallel to the Python version — the original hook stays untouched
- * and can be dropped once the Python backend is retired.
+ * Change a document's parser. The document endpoint takes `parser_id`
+ * (instead of the legacy `chunk_method`) and expects the pipeline-shaped
+ * parser_config (keyed by operator id) to be sent as-is.
*/
export const useSetDocumentPipelineParser = () => {
const queryClient = useQueryClient();
diff --git a/web/src/hooks/use-knowledge-request.ts b/web/src/hooks/use-knowledge-request.ts
index 8faa7e08a2..55a6d4ad7e 100644
--- a/web/src/hooks/use-knowledge-request.ts
+++ b/web/src/hooks/use-knowledge-request.ts
@@ -16,15 +16,13 @@
import { useHandleFilterSubmit } from '@/components/list-filter-bar/use-handle-filter-submit';
import message from '@/components/ui/message';
-import { useIsGoBackend } from '@/utils/backend-variant';
import { isDatasetId } from '@/utils/dataset-util';
import { markListItemsDeleted } from '@/utils/list-deletion-util';
-import { GenerateType, ParseType } from '@/constants/knowledge';
+import { ParseType } from '@/constants/knowledge';
import { ListDeletionKey } from '@/constants/list-deletion';
import { ResponsePostType, ResponseType } from '@/interfaces/database/base';
import {
IArtifact,
- IArtifactAlteration,
IArtifactGraph,
IArtifactPage,
IArtifactTopic,
@@ -49,9 +47,7 @@ import i18n from '@/locales/config';
import kbService, {
checkEmbedding,
clearWiki,
- deleteArtifactsStructure,
deleteKnowledgeGraph,
- getArtifactsAlteration,
getArtifactGraph,
getArtifactPage,
getArtifactsStructure,
@@ -67,7 +63,6 @@ import kbService, {
listWikiCommits,
removeTag,
renameTag,
- runIndex,
updateArtifactPage,
updateKb,
} from '@/services/knowledge-service';
@@ -93,7 +88,6 @@ import {
normalizeParserConfig,
} from './parser-config-utils';
import { useSetPaginationParams } from './route-hook';
-import { DatasetGenerateKeys } from './use-dataset-generate';
export const enum KnowledgeApiAction {
FetchKnowledgeListByPage = 'fetchKnowledgeListByPage',
@@ -492,28 +486,6 @@ export const ArtifactTopicKeys = {
[KnowledgeApiAction.FetchArtifactTopicList, datasetId] as const,
};
-export const ArtifactAlterationKeys = {
- detail: (datasetId: string, kind: string) =>
- [KnowledgeApiAction.FetchArtifactAlteration, datasetId, kind] as const,
-};
-
-export function useFetchArtifactAlteration(kind: string) {
- const knowledgeBaseId = useKnowledgeBaseId();
-
- const { data, isFetching: loading } = useQuery<IArtifactAlteration | null>({
- queryKey: ArtifactAlterationKeys.detail(knowledgeBaseId, kind),
- initialData: null,
- enabled: !!knowledgeBaseId && !!kind,
- gcTime: 0,
- queryFn: async () => {
- const { data } = await getArtifactsAlteration(knowledgeBaseId, kind);
- return data?.data ?? null;
- },
- });
-
- return { data, loading };
-}
-
const wikiCommitKeys = {
list: (datasetId: string, pageType: string, slug: string) =>
[KnowledgeApiAction.FetchWikiCommits, datasetId, pageType, slug] as const,
@@ -880,31 +852,6 @@ export function useFetchDatasetStructureGraph(kind: string, keywords?: string) {
return { data, loading };
}
-export const useDeleteDatasetStructure = () => {
- const knowledgeBaseId = useKnowledgeBaseId();
- const queryClient = useQueryClient();
-
- const {
- data,
- isPending: loading,
- mutateAsync,
- } = useMutation({
- mutationKey: [KnowledgeApiAction.DeleteDatasetStructure],
- mutationFn: async (kind: string) => {
- const { data } = await deleteArtifactsStructure(knowledgeBaseId, kind);
- if (data?.code === 0) {
- message.success(i18n.t('message.deleted'));
- queryClient.invalidateQueries({
- queryKey: DatasetStructureKeys.all(knowledgeBaseId),
- });
- }
- return data?.code;
- },
- });
-
- return { data, loading, deleteDatasetStructure: mutateAsync };
-};
-
export function useFetchKnowledgeMetadata(kbIds: string[] = []) {
const { data, isFetching: loading } = useQuery<
Record<string, Record<string, string[]>>
@@ -998,11 +945,7 @@ export const useClearWiki = () => {
return { data, loading, clearWiki: mutateAsync };
};
-export const useRunArtifactIndex = (kind: string) => {
- const knowledgeBaseId = useKnowledgeBaseId();
- const queryClient = useQueryClient();
- const isGo = useIsGoBackend();
-
+export const useRunArtifactIndex = () => {
const {
data,
isPending: loading,
@@ -1010,33 +953,11 @@ export const useRunArtifactIndex = (kind: string) => {
} = useMutation({
mutationKey: [KnowledgeApiAction.RunArtifactIndex],
mutationFn: async () => {
- // Go: wiki compilation is auto-driven by the scheduler; there is no
- // legacy RunIndex endpoint. Reject instead of reporting success so a wiki
- // update can't be mistaken for a real re-merge (the UI hides/disables the
- // update control — plan v4.1 §4.2).
- if (isGo) {
- throw new Error(i18n.t('message.compileNotSupported'));
- }
- const { data } = await runIndex(knowledgeBaseId, 'wiki');
- if (data?.code === 0) {
- message.success(i18n.t('message.operated'));
- queryClient.invalidateQueries({
- queryKey: ArtifactAlterationKeys.detail(knowledgeBaseId, kind),
- });
- queryClient.invalidateQueries({
- queryKey: ArtifactKeys.listByDataset(knowledgeBaseId),
- });
- queryClient.invalidateQueries({
- queryKey: ArtifactTopicKeys.listByDataset(knowledgeBaseId),
- });
- queryClient.invalidateQueries({
- queryKey: DatasetGenerateKeys.traceById(
- GenerateType.Artifact,
- knowledgeBaseId,
- ),
- });
- }
- return data;
+ // Wiki compilation is auto-driven by the scheduler; there is no
+ // legacy RunIndex endpoint. Reject instead of reporting success so a
+ // wiki update can't be mistaken for a real re-merge (the UI hides/
+ // disables the update control).
+ throw new Error(i18n.t('message.compileNotSupported'));
},
});
diff --git a/web/src/hooks/use-user-setting-request.tsx b/web/src/hooks/use-user-setting-request.tsx
index 3e9d4ca734..1337ee4cda 100644
--- a/web/src/hooks/use-user-setting-request.tsx
+++ b/web/src/hooks/use-user-setting-request.tsx
@@ -34,7 +34,6 @@ import userService, {
listTenant,
listTenantUser,
} from '@/services/user-service';
-import { useIsGoBackend } from '@/utils/backend-variant';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -107,14 +106,9 @@ export const useSelectParserList = (): Array<{
value: string;
label: string;
}> => {
- const { data: tenantInfo } = useFetchTenantInfo();
const { t } = useTranslation();
- // Detect backend runtime language (Go vs Python) so we can choose
- // the matching parser-list code path at runtime.
- const isGo = useIsGoBackend();
-
- // Go backend: fetch pipeline catalog dynamically.
+ // Fetch the pipeline catalog dynamically.
const { data: pipelineListData } = useQuery({
queryKey: [UserSettingApiAction.ListPipelines],
queryFn: async () => {
@@ -122,7 +116,6 @@ export const useSelectParserList = (): Array<{
return data;
},
staleTime: Infinity,
- enabled: isGo,
});
useFetchDefaultModelDictionary(true);
@@ -159,43 +152,30 @@ export const useSelectParserList = (): Array<{
);
const parserList = useMemo(() => {
- // Go backend: prefer the dynamic pipeline catalog from the API.
+ // 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 (isGo) {
- const pipelineList: Array<{
- id: string;
- title: string;
- description?: string;
- filename?: string;
- }> = pipelineListData?.data?.canvas ?? [];
- if (pipelineList.length > 0) {
- const labelFromAPI = (parserId: string, title: string) => {
- const key = `knowledgeConfiguration.parserLabel.${parserId}`;
- const translated = t(key);
- return translated !== key ? translated : title;
- };
- return pipelineList.map((item) => ({
- value: item.id,
- label: labelFromAPI(item.id, item.title),
- }));
- }
- }
-
- // Python backend (or fallback): use tenant-level parser_ids or
- // the hardcoded default parsers.
- const parserArray: Array<string> = tenantInfo?.parser_ids?.split(',') ?? [];
- const filteredArray = parserArray.filter((x) => x.trim() !== '');
-
- if (filteredArray.length === 0) {
- return defaultParsers;
+ const pipelineList: Array<{
+ id: string;
+ title: string;
+ description?: string;
+ filename?: string;
+ }> = pipelineListData?.data?.canvas ?? [];
+ if (pipelineList.length > 0) {
+ const labelFromAPI = (parserId: string, title: string) => {
+ const key = `knowledgeConfiguration.parserLabel.${parserId}`;
+ const translated = t(key);
+ return translated !== key ? translated : title;
+ };
+ return pipelineList.map((item) => ({
+ value: item.id,
+ label: labelFromAPI(item.id, item.title),
+ }));
}
- return filteredArray.map((x) => {
- const arr = x.split(':');
- return { value: arr[0], label: arr[1] };
- });
- }, [tenantInfo, defaultParsers, isGo, pipelineListData, t]);
+ // Fallback: the hardcoded default parsers.
+ return defaultParsers;
+ }, [defaultParsers, pipelineListData, t]);
return parserList;
};
diff --git a/web/src/locales/az.ts b/web/src/locales/az.ts
index cdc50b5db9..6044eec847 100644
--- a/web/src/locales/az.ts
+++ b/web/src/locales/az.ts
@@ -2794,8 +2794,6 @@ Nümunə: Virtual host üslubu`,
delimiters: 'Ayırıcılar',
delimitersTip:
'Hər sətirdə bir ayırıcı; çoxsimvollu ayırıcılar olduğu kimi yazıla bilər (məsələn, ##). Tərs dırnaq içində olduqda (məsələn, `##`): sərt bölünmə — hər ayırıcı öz hissəsini başladır və token ölçüsünə görə birləşdirmə tətbiq edilmir. Tərs dırnaq olmadan: yumşaq bölünmə — ayırıcı yalnız bölünmə nöqtəsidir və parçalar yenə də hissənin token ölçüsünə qədər birləşdirilir, buna görə qısa sənədlərdə görünən dəyişiklik olmaya bilər.',
- delimitersTipPython:
- 'Hər sətirdə bir ayırıcı. Yalnız tərs dırnaq içindəki dəyərlər (məsələn, `##`) qüvvəyə minir: hər ayırıcı öz hissəsini başladır və token ölçüsünə görə birləşdirmə tətbiq edilmir. Tərs dırnaq içində olmayan dəyərlər nəzərə alınmır.',
childrenDelimitersTip:
'Alt hissələrə bölünmə: hər üst hissə bu ayırıcılar üzrə yenidən axtarış üçün istifadə olunan alt hissələrə bölünür; hissənin token ölçüsü tətbiq edilmir.',
one: 'Bir',
diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts
index 8ce33ff7db..c82ab72d8c 100644
--- a/web/src/locales/en.ts
+++ b/web/src/locales/en.ts
@@ -2758,8 +2758,6 @@ Best for: Documents with flowing, contextually connected content — such as boo
delimiters: 'Delimiters',
delimitersTip:
'One delimiter per row; multi-character delimiters can be typed as-is (e.g. ##). With backticks (e.g. `##`): hard split — every delimiter starts its own chunk and no token-size merge is applied. Without backticks: soft split — the delimiter is only a split point, and the pieces are still merged up to the chunk token size, so short documents may show no visible change.',
- delimitersTipPython:
- 'One delimiter per row. Only backtick-wrapped entries (e.g. `##`) take effect: every delimiter starts its own chunk and no token-size merge is applied. Entries without backticks are ignored.',
childrenDelimitersTip:
'Child split: each parent chunk is split again at these delimiters into child chunks used for retrieval; the chunk token size does not apply.',
one: 'One',
diff --git a/web/src/locales/tr.ts b/web/src/locales/tr.ts
index a84d9cf013..63914cac4a 100644
--- a/web/src/locales/tr.ts
+++ b/web/src/locales/tr.ts
@@ -2729,8 +2729,6 @@ En uygun olduğu durumlar: Anlatı bütünlüğünün bitişik paragrafları bir
delimiters: 'Sınırlayıcılar',
delimitersTip:
'Her satıra bir sınırlayıcı; çok karakterli sınırlayıcılar olduğu gibi yazılabilir (örneğin ##). Ters tırnakla (örneğin `##`): sert bölme — her sınırlayıcı kendi parçasını başlatır ve token boyutuna göre birleştirme uygulanmaz. Ters tırnaksız: yumuşak bölme — sınırlayıcı yalnızca bir bölme noktasıdır ve parçalar yine parça token boyutuna kadar birleştirilir, bu nedenle kısa belgelerde gözle görülür bir değişiklik olmayabilir.',
- delimitersTipPython:
- 'Her satıra bir sınırlayıcı. Yalnızca ters tırnak içine alınmış girdiler (örneğin `##`) etkili olur: her sınırlayıcı kendi parçasını başlatır ve token boyutuna göre birleştirme uygulanmaz. Ters tırnaksız girdiler yok sayılır.',
childrenDelimitersTip:
'Alt bölme: her üst parça, alım için kullanılan alt parçalara ayrılmak üzere bu sınırlayıcılarda yeniden bölünür; parça token boyutu burada geçerli değildir.',
one: 'Tek',
diff --git a/web/src/locales/uz.ts b/web/src/locales/uz.ts
index 36dc2f2d7f..4b89262cd0 100644
--- a/web/src/locales/uz.ts
+++ b/web/src/locales/uz.ts
@@ -2695,8 +2695,6 @@ export default {
delimiters: 'Ajratgichlar',
delimitersTip:
'Har bir qatorga bitta ajratuvchi; ko‘p belgili ajratuvchilar shu holatda yozilishi mumkin (masalan, ##). Bektiklar bilan (masalan, `##`): qattiq bo‘lish — har bir ajratuvchi o‘z bo‘lagini boshlaydi va token hajmiga qo‘shilish qo‘llanilmaydi. Bektiksiz: yumshoq bo‘lish — ajratuvchi faqat bo‘lish nuqtasi bo‘lib, bo‘laklar bo‘lak token hajmiga qadar birlashtiriladi, shuning uchun qisqa hujjatlarda ko‘rinadigan o‘zgarish bo‘lmasligi mumkin.',
- delimitersTipPython:
- 'Har bir qatorga bitta ajratuvchi. Faqat bektik bilan o‘ralgan yozuvlar (masalan, `##`) kuchga kiradi: har bir ajratuvchi o‘z bo‘lagini boshlaydi va token hajmiga qo‘shilish qo‘llanilmaydi. Bektiksiz yozuvlar e’tiborga olinmaydi.',
childrenDelimitersTip:
'Bola bo‘lish: har bir ota bo‘lak bu ajratuvchilar bo‘yicha qidiruvda ishlatiladigan bola bo‘laklarga yana bo‘linadi; bo‘lak token hajmi qo‘llanilmaydi.',
one: 'Bitta',
diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts
index d80118a6aa..e893e24ed4 100644
--- a/web/src/locales/zh.ts
+++ b/web/src/locales/zh.ts
@@ -2338,8 +2338,6 @@ NER:使用 spaCy NER 和基于规则的关键词提取来抽取 Entities 和 R
delimiters: '分隔符',
delimitersTip:
'每行一个分隔符,多字符分隔符可直接填写(如 ##)。加反引号(如 `##`):强制切分,每个分隔符处独立成块,不再按 token 大小合并;不加反引号:只作为切分点,切出的段落仍会按 chunk_token_size 合并,因此短文本可能看不出效果。',
- delimitersTipPython:
- '每行一个分隔符。只有用反引号包裹的条目(如 `##`)生效:每个分隔符处独立成块,不再按 token 大小合并;不加反引号的条目会被忽略。',
childrenDelimitersTip:
'子块切分:每个父块会再按这些分隔符切成子块(子块用于检索),不受 chunk_token_size 影响。',
one: 'One',
diff --git a/web/src/main.tsx b/web/src/main.tsx
index df3c7cd74a..cad2f00370 100644
--- a/web/src/main.tsx
+++ b/web/src/main.tsx
@@ -21,12 +21,8 @@ import '../tailwind.css';
import App from './app';
import './global.less';
import { initLanguage } from './locales/config';
-// oxlint-disable-next-line no-restricted-imports -- bootstrap gate: resolve the backend variant before first render
-import { fetchBackendLanguage } from './utils/backend-runtime';
-// Gate first render on the backend-language probe so every variant dispatch
-// below sees a concrete value (no python-flash-then-switch).
-Promise.all([initLanguage(), fetchBackendLanguage()]).then(() => {
+initLanguage().then(() => {
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<Inspector keys={['alt', 'c']} />
diff --git a/web/src/pages/agent/__tests__/chunker-delimiter-hints.test.ts b/web/src/pages/agent/__tests__/chunker-delimiter-hints.test.ts
index d5b2072766..5fd0cc102d 100644
--- a/web/src/pages/agent/__tests__/chunker-delimiter-hints.test.ts
+++ b/web/src/pages/agent/__tests__/chunker-delimiter-hints.test.ts
@@ -1,65 +1,25 @@
-// Kept out of the co-located utils.test.ts: files containing jest.mock are
-// transformed through the babel path (see jest-esbuild-transformer.cjs), which
-// cannot handle an imported type used in a type annotation.
import {
getChunkerChildrenDelimiterPreview,
getChunkerDelimiterPreview,
getChunkerDelimiterTipKey,
} from '../utils';
-// Dispatch on the mutable flag so each scenario can exercise either the
-// Go or the Python branch without mounting React.
-let mockIsGoBackend = false;
-jest.mock('@/utils/backend-variant', () => ({
- pickByBackend: ({ go, python }: { go: unknown; python: unknown }) =>
- mockIsGoBackend ? go : python,
-}));
-
describe('getChunkerDelimiterTipKey', () => {
- afterEach(() => {
- mockIsGoBackend = false;
- });
-
- it('points at the Go delimiter tip on the Go backend', () => {
- mockIsGoBackend = true;
+ it('points at the delimiter tip', () => {
expect(getChunkerDelimiterTipKey()).toBe('flow.delimitersTip');
});
-
- it('points at the Python delimiter tip on the Python backend', () => {
- expect(getChunkerDelimiterTipKey()).toBe('flow.delimitersTipPython');
- });
});
describe('getChunkerDelimiterPreview', () => {
- afterEach(() => {
- mockIsGoBackend = false;
- });
-
- it('previews every non-empty row as one delimiter on the Go backend', () => {
- mockIsGoBackend = true;
+ it('previews every non-empty row as one delimiter', () => {
expect(
getChunkerDelimiterPreview(['\n', '`##`']).map((d) => d.raw),
).toEqual(['##', '\n']);
});
-
- it('previews only backtick-wrapped rows on the Python backend', () => {
- expect(
- getChunkerDelimiterPreview(['\n', '`##`']).map((d) => d.raw),
- ).toEqual(['##']);
- });
});
describe('getChunkerChildrenDelimiterPreview', () => {
- afterEach(() => {
- mockIsGoBackend = false;
- });
-
- it('keeps bare rows on both backends', () => {
- expect(
- getChunkerChildrenDelimiterPreview(['\n', '`##`']).map((d) => d.raw),
- ).toEqual(['##', '\n']);
-
- mockIsGoBackend = true;
+ it('keeps bare rows', () => {
expect(
getChunkerChildrenDelimiterPreview(['\n', '`##`']).map((d) => d.raw),
).toEqual(['##', '\n']);
diff --git a/web/src/pages/agent/canvas/index.tsx b/web/src/pages/agent/canvas/index.tsx
index 2fa0de7c8b..41aee17311 100644
--- a/web/src/pages/agent/canvas/index.tsx
+++ b/web/src/pages/agent/canvas/index.tsx
@@ -1,5 +1,4 @@
import { useTheme } from '@/components/theme-provider';
-import { useIsGoBackend } from '@/utils/backend-variant';
import {
Tooltip,
TooltipContent,
@@ -30,9 +29,7 @@ import {
import FormSheet from '../form-sheet/next';
import { useIsPipeline } from '../hooks/use-is-pipeline';
-import {
- hasPipelineNextOperators,
-} from '../utils/pipeline-connection';
+import { hasPipelineNextOperators } from '../utils/pipeline-connection';
import { useSelectCanvasData, useValidateConnection } from '../hooks';
import { useAddNode } from '../hooks/use-add-node';
import { useBeforeDelete } from '../hooks/use-before-delete';
@@ -236,14 +233,13 @@ function AgentCanvas({ drawerVisible, hideDrawer }: IProps) {
const { calculateDropdownPosition } = useDropdownPosition(reactFlowInstance);
- const isGoBackend = useIsGoBackend();
const isPipeline = useIsPipeline();
const { findNodeByName, getOperatorTypeFromId } = useGraphStore(
(state) => state,
);
// Whether the "next step" menu offers anything for the drag source. On a
- // pipeline, single-instance operators already on canvas plus the Go
+ // pipeline, single-instance operators already on canvas plus the
// topology rules can leave the menu empty; such a drag is aborted.
const hasNextStepOperators = useCallback(
(sourceNodeId: string) => {
@@ -252,11 +248,10 @@ function AgentCanvas({ drawerVisible, hideDrawer }: IProps) {
}
return hasPipelineNextOperators(
getOperatorTypeFromId(sourceNodeId) as Operator | undefined,
- isGoBackend,
(operator) => !!findNodeByName(operator),
);
},
- [findNodeByName, getOperatorTypeFromId, isGoBackend, isPipeline],
+ [findNodeByName, getOperatorTypeFromId, isPipeline],
);
const {
diff --git a/web/src/pages/agent/canvas/node/dropdown/accordion-operators.tsx b/web/src/pages/agent/canvas/node/dropdown/accordion-operators.tsx
index 3a760d49a7..85c7a5eecd 100644
--- a/web/src/pages/agent/canvas/node/dropdown/accordion-operators.tsx
+++ b/web/src/pages/agent/canvas/node/dropdown/accordion-operators.tsx
@@ -5,7 +5,6 @@ import {
AccordionTrigger,
} from '@/components/ui/accordion';
import { Operator } from '@/constants/agent';
-import { useIsGoBackend } from '@/utils/backend-variant';
import { PropsWithChildren, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import useGraphStore from '../../../store';
@@ -154,19 +153,15 @@ export function PipelineAccordionOperators({
const { findNodeByName, getOperatorTypeFromId } = useGraphStore(
(state) => state,
);
- const isGoBackend = useIsGoBackend();
- const sourceOperator = getOperatorTypeFromId(nodeId) as
- | Operator
- | undefined;
+ const sourceOperator = getOperatorTypeFromId(nodeId) as Operator | undefined;
const { operators, chunkerOperators, showChunker } = useMemo(
() =>
buildPipelineNextOperators(
sourceOperator,
- isGoBackend,
(operator) => !!findNodeByName(operator),
),
- [findNodeByName, isGoBackend, sourceOperator],
+ [findNodeByName, sourceOperator],
);
return (
diff --git a/web/src/pages/agent/constant/pipeline.tsx b/web/src/pages/agent/constant/pipeline.tsx
index 7467c291d7..2c3f7f4afa 100644
--- a/web/src/pages/agent/constant/pipeline.tsx
+++ b/web/src/pages/agent/constant/pipeline.tsx
@@ -2,7 +2,6 @@ import { ParseDocumentType } from '@/components/layout-recognize-form-field';
import { initialLlmBaseValues, Operator } from '@/constants/agent';
import { FileType } from '@/constants/file';
import { ModelTypeToField } from '@/constants/llm';
-import { pickByBackend } from '@/utils/backend-variant';
import { cloneDeep } from 'lodash';
export enum PdfOutputFormat {
@@ -415,12 +414,7 @@ export const initialGoExtractorValues = {
};
export function getInitialExtractorValues() {
- return pickByBackend<
- typeof initialGoExtractorValues | typeof initialExtractorValues
- >({
- go: initialGoExtractorValues,
- python: initialExtractorValues,
- });
+ return initialGoExtractorValues;
}
export const initialCompilationValues = {
diff --git a/web/src/pages/agent/form/extractor-form/index.tsx b/web/src/pages/agent/form/extractor-form/index.tsx
index eb9205df12..99a8c5fad3 100644
--- a/web/src/pages/agent/form/extractor-form/index.tsx
+++ b/web/src/pages/agent/form/extractor-form/index.tsx
@@ -1,36 +1,3 @@
-/*
- * Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import { BackendVariant } from '@/utils/backend-variant';
-import { memo } from 'react';
-import { INextOperatorForm } from '../../interface';
-import GoExtractorForm from './go-form';
-import PythonExtractorForm from './python-form';
-
+export { default } from './go-form';
export { FormSchema } from './go-form';
export type { ExtractorFormSchemaType } from './go-form';
-
-// The Go backend supports the modularized extractor config (per-feature
-// sub-tabs with nested params), while the Python backend only understands the
-// legacy flat fields — pick the matching form per backend.
-const ExtractorForm = (props: INextOperatorForm) => (
- <BackendVariant
- go={<GoExtractorForm {...props} />}
- python={<PythonExtractorForm {...props} />}
- />
-);
-
-export default memo(ExtractorForm);
diff --git a/web/src/pages/agent/form/extractor-form/python-form.tsx b/web/src/pages/agent/form/extractor-form/python-form.tsx
deleted file mode 100644
index 991da88005..0000000000
--- a/web/src/pages/agent/form/extractor-form/python-form.tsx
+++ /dev/null
@@ -1,127 +0,0 @@
-import { ConfirmDeleteDialog } from '@/components/confirm-delete-dialog';
-import { LargeModelFormField } from '@/components/large-model-form-field';
-import { LlmSettingSchema } from '@/components/llm-setting-items/next';
-import { SelectWithSearch } from '@/components/originui/select-with-search';
-import { RAGFlowFormItem } from '@/components/ragflow-form';
-import { Form } from '@/components/ui/form';
-import { PromptEditor } from '@/pages/agent/form/components/prompt-editor';
-import { buildOptions } from '@/utils/form';
-import { zodResolver } from '@hookform/resolvers/zod';
-import { memo } from 'react';
-import { useForm } from 'react-hook-form';
-import { useTranslation } from 'react-i18next';
-import { z } from 'zod';
-import {
- ContextGeneratorFieldName,
- initialExtractorValues,
-} from '../../constant/pipeline';
-import { useOwnerTenantId } from '../../context';
-import { useBuildNodeOutputOptions } from '../../hooks/use-build-options';
-import { useFormChangeCallback } from '../../hooks/use-form-change-callback';
-import { useFormValues } from '../../hooks/use-form-values';
-import { useWatchFormChange } from '../../hooks/use-watch-form-change';
-import { INextOperatorForm } from '../../interface';
-import { buildOutputList } from '../../utils/build-output-list';
-import { FormWrapper } from '../components/form-wrapper';
-import { Output } from '../components/output';
-import { useSwitchPrompt } from './use-switch-prompt';
-
-// Python-backend extractor form: the Python Extractor component only reads
-// the legacy flat fields (field_name / sys_prompt / prompts), so this form
-// is kept unchanged from before the Go modularization.
-const FormSchema = z.object({
- field_name: z.string(),
- sys_prompt: z.string(),
- prompts: z.string().optional(),
- auto_tags: z.number().optional(),
- tag_file_id: z.string().optional(),
- ...LlmSettingSchema,
-});
-
-type ExtractorFormSchemaType = z.infer<typeof FormSchema>;
-
-const outputList = buildOutputList(initialExtractorValues.outputs);
-
-const PythonExtractorForm = ({
- node,
- onValuesChange,
- hideOutputs,
-}: INextOperatorForm) => {
- const defaultValues = useFormValues(initialExtractorValues, node);
- const { t } = useTranslation();
-
- const form = useForm<ExtractorFormSchemaType>({
- defaultValues,
- resolver: zodResolver(FormSchema),
- // mode: 'onChange',
- });
-
- const promptOptions = useBuildNodeOutputOptions(node?.id);
-
- const options = buildOptions(ContextGeneratorFieldName, t, 'flow');
-
- const {
- handleFieldNameChange,
- confirmSwitch,
- hideModal,
- visible,
- cancelSwitch,
- } = useSwitchPrompt(form);
-
- useWatchFormChange(node?.id, form);
- useFormChangeCallback(form, onValuesChange);
-
- const ownerTenantId = useOwnerTenantId();
-
- return (
- <Form {...form}>
- <FormWrapper>
- <LargeModelFormField
- ownerTenantId={ownerTenantId}
- ></LargeModelFormField>
-
- <RAGFlowFormItem label={t('flow.fieldName')} name="field_name">
- {(field) => (
- <SelectWithSearch
- onChange={(value) => {
- field.onChange(value);
- handleFieldNameChange(value);
- }}
- value={field.value}
- placeholder={t('dataFlowPlaceholder')}
- options={options}
- ></SelectWithSearch>
- )}
- </RAGFlowFormItem>
-
- <RAGFlowFormItem label={t('flow.systemPrompt')} name="sys_prompt">
- <PromptEditor
- placeholder={t('flow.messagePlaceholder')}
- showToolbar={true}
- baseOptions={promptOptions}
- ></PromptEditor>
- </RAGFlowFormItem>
-
- <RAGFlowFormItem label={t('flow.userPrompt')} name="prompts">
- <PromptEditor
- showToolbar={true}
- baseOptions={promptOptions}
- ></PromptEditor>
- </RAGFlowFormItem>
-
- {!hideOutputs && <Output list={outputList}></Output>}
- </FormWrapper>
- {visible && (
- <ConfirmDeleteDialog
- title={t('flow.switchPromptMessage')}
- open
- onOpenChange={hideModal}
- onOk={confirmSwitch}
- onCancel={cancelSwitch}
- ></ConfirmDeleteDialog>
- )}
- </Form>
- );
-};
-
-export default memo(PythonExtractorForm);
diff --git a/web/src/pages/agent/form/parser-form/pdf-form-fields.tsx b/web/src/pages/agent/form/parser-form/pdf-form-fields.tsx
index a3fbb2a022..3d197a5ec8 100644
--- a/web/src/pages/agent/form/parser-form/pdf-form-fields.tsx
+++ b/web/src/pages/agent/form/parser-form/pdf-form-fields.tsx
@@ -8,7 +8,6 @@ import {
SelectWithSearchFlagOptionType,
} from '@/components/originui/select-with-search';
import { RAGFlowFormItem } from '@/components/ragflow-form';
-import { useIsGoBackend } from '@/utils/backend-variant';
import { isEmpty } from 'lodash';
import { useEffect, useMemo } from 'react';
import { useFormContext, useWatch } from 'react-hook-form';
@@ -41,7 +40,6 @@ export function PdfFormFields({ prefix }: CommonProps) {
const { t } = useTranslation();
const form = useFormContext();
const ownerTenantId = useOwnerTenantId();
- const isGo = useIsGoBackend();
const parseMethodName = buildFieldNameWithPrefix('parse_method', prefix);
const parseMethod = useWatch({
@@ -101,7 +99,7 @@ export function PdfFormFields({ prefix }: CommonProps) {
<RmdirFormField prefix={prefix} />
<RemoveHeaderFooterFormField prefix={prefix} />
<ParserMethodFormField prefix={prefix}></ParserMethodFormField>
- {isGo && <DynamicPageRange prefix={prefix} />}
+ <DynamicPageRange prefix={prefix} />
<FlattenMediaToTextFormField prefix={prefix} />
{!flattenMediaToText && (
<ModelTreeSelectFormField
diff --git a/web/src/pages/agent/hooks.tsx b/web/src/pages/agent/hooks.tsx
index a9fdcb2c4a..ed473bed33 100644
--- a/web/src/pages/agent/hooks.tsx
+++ b/web/src/pages/agent/hooks.tsx
@@ -3,7 +3,6 @@ import React, { useCallback, useEffect } from 'react';
// import { shallow } from 'zustand/shallow';
import { settledModelVariableMap } from '@/constants/knowledge';
import { RAGFlowNodeType } from '@/interfaces/database/agent';
-import { useIsGoBackend } from '@/utils/backend-variant';
import { get, lowerFirst, omit } from 'lodash';
import { UseFormReturn } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
@@ -11,7 +10,7 @@ import { Operator, RestrictedUpstreamMap } from './constant';
import { useIsPipeline } from './hooks/use-is-pipeline';
import useGraphStore, { RFState } from './store';
import { buildCategorizeObjectFromList, replaceIdWithText } from './utils';
-import { isValidGoPipelineConnection } from './utils/pipeline-connection';
+import { isValidPipelineConnection } from './utils/pipeline-connection';
const selector = (state: RFState) => ({
nodes: state.nodes,
@@ -131,9 +130,8 @@ export const useHandleFormValuesChange = (
export const useValidateConnection = () => {
const { getOperatorTypeFromId, getParentIdById, edges, nodes } =
useGraphStore((state) => state);
- const isGoBackend = useIsGoBackend();
const isPipeline = useIsPipeline();
- const restrictPipelineTopology = isGoBackend && isPipeline;
+ const restrictPipelineTopology = isPipeline;
const isSameNodeChild = useCallback(
(connection: Connection | Edge) => {
@@ -189,7 +187,7 @@ export const useValidateConnection = () => {
isSameNodeChild(connection) &&
hasCanvasCycle(connection) &&
(!restrictPipelineTopology ||
- isValidGoPipelineConnection(
+ isValidPipelineConnection(
getOperatorTypeFromId(connection.source) as Operator,
getOperatorTypeFromId(connection.target) as Operator,
));
diff --git a/web/src/pages/agent/hooks/use-add-node.ts b/web/src/pages/agent/hooks/use-add-node.ts
index 77e682c8ca..b41f8a9ad8 100644
--- a/web/src/pages/agent/hooks/use-add-node.ts
+++ b/web/src/pages/agent/hooks/use-add-node.ts
@@ -1,5 +1,4 @@
import { useFetchDefaultModelDictionary } from '@/hooks/use-llm-request';
-import { pickByBackend } from '@/utils/backend-variant';
import { Connection, Node, Position, ReactFlowInstance } from '@xyflow/react';
import humanId from 'human-id';
import { t } from 'i18next';
@@ -191,16 +190,6 @@ export const useInitializeOperatorParams = () => {
[Operator.Extractor]: {
...getInitialExtractorValues(),
llm_id: llmId,
- // sys_prompt/prompts belong to the Python extractor form. The Go
- // form seeds summary.system_prompt itself, and the Go extractor
- // falls back to a built-in prompt when it is empty.
- ...pickByBackend({
- go: {},
- python: {
- sys_prompt: t('flow.prompts.system.summary'),
- prompts: t('flow.prompts.user.summary'),
- },
- }),
},
[Operator.Compiler]: { ...initialCompilationValues, llm_id: llmId },
[Operator.DataOperations]: initialDataOperationsValues,
diff --git a/web/src/pages/agent/index.tsx b/web/src/pages/agent/index.tsx
index 46b18ea7d7..aba9f76ffe 100644
--- a/web/src/pages/agent/index.tsx
+++ b/web/src/pages/agent/index.tsx
@@ -25,7 +25,6 @@ import { SharedFrom } from '@/constants/chat';
import { useSetModalState } from '@/hooks/common-hooks';
import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks';
import { useSetAgent } from '@/hooks/use-agent-request';
-import { useIsGoBackend } from '@/utils/backend-variant';
import { ReactFlowProvider } from '@xyflow/react';
import {
ChevronDown,
@@ -106,15 +105,13 @@ export default function Agent() {
} = useSetModalState();
const { t } = useTranslation();
useAgentHistoryManager();
- const isGoBackend = useIsGoBackend();
- // Resolves the i18n key for the canvas "Run" tooltip describing the Go-side
+ // Resolves the i18n key for the canvas "Run" tooltip describing the
// debug preview limits. It is shown ONLY for a dataflow (ingestion pipeline)
- // canvas on the golang backend — an agent canvas runs the agent, not an
- // ingestion debug preview, so it must never show this tooltip.
- const runTooltipKey = debugRunLimitsTooltipKey(isGoBackend, isPipeline);
- // The golang backend's ingestion (dataflow) canvas hides the Run/test-run
- // entry entirely; the agent canvas keeps its Run button on both backends.
- const showRunButton = !(isGoBackend && isPipeline);
+ // canvas — an agent canvas runs the agent, not an ingestion debug preview.
+ const runTooltipKey = debugRunLimitsTooltipKey(isPipeline);
+ // The ingestion (dataflow) canvas hides the Run/test-run entry entirely;
+ // the agent canvas keeps its Run button.
+ const showRunButton = !isPipeline;
const { handleExportJson } = useHandleExportJsonFile();
const { saveGraph, loading } = useSaveGraph();
diff --git a/web/src/pages/agent/utils.ts b/web/src/pages/agent/utils.ts
index 5f1c8c0832..042a2a1e37 100644
--- a/web/src/pages/agent/utils.ts
+++ b/web/src/pages/agent/utils.ts
@@ -9,7 +9,6 @@ import {
ICategorizeItemResult,
RAGFlowNodeType,
} from '@/interfaces/database/agent';
-import { pickByBackend } from '@/utils/backend-variant';
import { buildSelectOptions } from '@/utils/component-util';
import { parseDelimiterListForDisplay } from '@/utils/delimiter-preview';
import { buildOptions, removeUselessFieldsFromValues } from '@/utils/form';
@@ -233,10 +232,7 @@ export function transformParserParams(params: ParserFormSchemaType) {
enable_multi_column: cur.enable_multi_column,
remove_toc: cur.remove_toc,
remove_header_footer: cur.remove_header_footer || false,
- ...pickByBackend({
- go: { pages: cur.pages?.map((x) => [x.from, x.to]) ?? [] },
- python: {},
- }),
+ pages: cur.pages?.map((x) => [x.from, x.to]) ?? [],
};
// Only include TCADP parameters if TCADP Parser is selected
if (cur.parse_method?.toLowerCase() === 'tcadp parser') {
@@ -337,12 +333,8 @@ export function transformParserParams(params: ParserFormSchemaType) {
return pre;
}, {});
- // The Go backend expects the setups map flattened into top-level params,
- // while the Python backend reads them from the nested `setups` object.
- return pickByBackend({
- go: { ...omit(params, ['setups']), ...setups },
- python: { ...params, setups },
- });
+ // Flatten the setups map into the top-level params.
+ return { ...omit(params, ['setups']), ...setups };
}
// Decides whether an empty delimiter list should be re-seeded with the
@@ -413,23 +405,15 @@ export function transformTokenChunkerParams(
};
}
-// The two backends honor the chunker's delimiter list differently: the Go
-// chunker treats a bare entry as a soft split point (the split pieces are still
-// merged up to the chunk token size) while the Python flow TokenChunker only
-// activates backtick-wrapped entries. The shared chunker form shows the tip
-// that matches the running backend.
+// The Go chunker treats a bare entry as a soft split point (the split pieces
+// are still merged up to the chunk token size). The shared chunker form shows
+// the matching tip.
export function getChunkerDelimiterTipKey() {
- return pickByBackend({
- go: 'flow.delimitersTip',
- python: 'flow.delimitersTipPython',
- });
+ return 'flow.delimitersTip';
}
export function getChunkerDelimiterPreview(values: (string | undefined)[]) {
- return pickByBackend({
- go: parseDelimiterListForDisplay(values, { keepBare: true }),
- python: parseDelimiterListForDisplay(values, { keepBare: false }),
- });
+ return parseDelimiterListForDisplay(values, { keepBare: true });
}
// The child split activates every non-empty entry on both backends, so the
@@ -510,14 +494,6 @@ export const LlmSettingParamKeys = [
'maxTokensEnabled',
];
-// The Python extractor only reads the legacy flat fields.
-function transformExtractorParamsPython(
- params: ExtractorFormSchemaType,
-): Record<string, any> {
- const raw = params as Record<string, any>;
- return { ...params, prompts: [{ content: raw.prompts, role: 'user' }] };
-}
-
// An unopened legacy node can still flow through here with flat keys
// (auto_keywords, keywords_sys_prompt, enable_metadata + metadata[],
// the transitional "metadata_config", ...). Accept them as read
@@ -597,10 +573,7 @@ function transformExtractorParamsGo(
export function transformExtractorParams(
params: ExtractorFormSchemaType,
): Record<string, any> {
- return pickByBackend({
- go: transformExtractorParamsGo,
- python: transformExtractorParamsPython,
- })(params);
+ return transformExtractorParamsGo(params);
}
// The Compiler reads the compilation template group plus the same LLM runtime
diff --git a/web/src/pages/agent/utils/__tests__/extractor-transform.test.ts b/web/src/pages/agent/utils/__tests__/extractor-transform.test.ts
index 9a64835112..52eef04afa 100644
--- a/web/src/pages/agent/utils/__tests__/extractor-transform.test.ts
+++ b/web/src/pages/agent/utils/__tests__/extractor-transform.test.ts
@@ -1,16 +1,7 @@
import { transformExtractorConfigToForm } from '@/utils/pipeline-operator';
import { transformExtractorParams } from '../../utils';
-let mockIsGoBackend = true;
-jest.mock('@/utils/backend-runtime', () => ({
- getBackendLanguage: () => (mockIsGoBackend ? 'go' : 'python'),
-}));
-
describe('Extractor parameter transformations & precedence', () => {
- beforeEach(() => {
- mockIsGoBackend = true;
- });
-
describe('transformExtractorParams', () => {
it('emits only the LLM settings and the nested groups the Go extractor reads', () => {
const input: any = {
@@ -217,52 +208,4 @@ describe('Extractor parameter transformations & precedence', () => {
});
});
});
-
- describe('python backend keeps the legacy flat shape', () => {
- beforeEach(() => {
- mockIsGoBackend = false;
- });
-
- it('transformExtractorParams only wraps prompts, without nested configs', () => {
- const input: any = {
- field_name: 'summary',
- sys_prompt: 'sys',
- prompts: 'user prompt',
- auto_keywords: 3,
- auto_questions: 2,
- auto_tags: 1,
- tag_file_id: 'tag-1',
- llm_id: 'gpt-4',
- };
-
- const result = transformExtractorParams(input);
-
- expect(result).toEqual({
- ...input,
- prompts: [{ content: 'user prompt', role: 'user' }],
- });
- expect(result).not.toHaveProperty('keywords');
- expect(result).not.toHaveProperty('questions');
- expect(result).not.toHaveProperty('tags');
- expect(result).not.toHaveProperty('summary');
- expect(result).not.toHaveProperty('metadata_config');
- });
-
- it('transformExtractorConfigToForm only unwraps prompts, without nested configs', () => {
- const config = {
- prompts: [{ content: 'user prompt', role: 'user' }],
- auto_keywords: 4,
- auto_tags: 1,
- };
-
- const result = transformExtractorConfigToForm(config);
-
- expect(result.prompts).toBe('user prompt');
- expect(result).not.toHaveProperty('keywords');
- expect(result).not.toHaveProperty('summary');
- expect(result).not.toHaveProperty('metadata_config');
- expect(result).not.toHaveProperty('enable_summary');
- expect(result).not.toHaveProperty('enable_metadata');
- });
- });
});
diff --git a/web/src/pages/agent/utils/debug-run-limits.test.ts b/web/src/pages/agent/utils/debug-run-limits.test.ts
index 14e08ff4f9..757e3dd2f3 100644
--- a/web/src/pages/agent/utils/debug-run-limits.test.ts
+++ b/web/src/pages/agent/utils/debug-run-limits.test.ts
@@ -1,19 +1,11 @@
import { debugRunLimitsTooltipKey } from './debug-run-limits';
describe('debugRunLimitsTooltipKey', () => {
- it('returns the key only for a dataflow (ingestion pipeline) canvas on golang', () => {
- expect(debugRunLimitsTooltipKey(true, true)).toBe('flow.debugRunLimits');
+ it('returns the key for a dataflow (ingestion pipeline) canvas', () => {
+ expect(debugRunLimitsTooltipKey(true)).toBe('flow.debugRunLimits');
});
- it('returns null for an agent canvas even on golang (no ingestion debug preview)', () => {
- expect(debugRunLimitsTooltipKey(true, false)).toBeNull();
- });
-
- it('returns null on the python backend even for a dataflow canvas', () => {
- expect(debugRunLimitsTooltipKey(false, true)).toBeNull();
- });
-
- it('returns null when neither condition holds', () => {
- expect(debugRunLimitsTooltipKey(false, false)).toBeNull();
+ it('returns null for an agent canvas (no ingestion debug preview)', () => {
+ expect(debugRunLimitsTooltipKey(false)).toBeNull();
});
});
diff --git a/web/src/pages/agent/utils/debug-run-limits.ts b/web/src/pages/agent/utils/debug-run-limits.ts
index 91c8dd9924..cbe19004fd 100644
--- a/web/src/pages/agent/utils/debug-run-limits.ts
+++ b/web/src/pages/agent/utils/debug-run-limits.ts
@@ -3,19 +3,9 @@
* tooltip describing the debug (dry-run) preview limits, or null when the
* tooltip should not be shown.
*
- * The tooltip applies ONLY to a dataflow (ingestion pipeline) canvas on the
- * golang backend. An agent canvas runs the agent/chat, not an ingestion
- * debug preview, so it must never show this tooltip. The python backend's
- * debug semantics also differ and are out of scope.
- *
- * It is a pure function of (backend language, is-pipeline) so it can be
- * unit-tested without mocking; the caller reads the backend through
- * `useIsGoBackend()`.
- *
- * The tooltip copy itself never names the backend language; only its
- * visibility is gated on these conditions.
+ * The tooltip applies ONLY to a dataflow (ingestion pipeline) canvas. An
+ * agent canvas runs the agent/chat, not an ingestion debug preview, so it
+ * must never show this tooltip.
*/
-export const debugRunLimitsTooltipKey = (
- isGo: boolean,
- isPipeline: boolean,
-): string | null => (isGo && isPipeline ? 'flow.debugRunLimits' : null);
+export const debugRunLimitsTooltipKey = (isPipeline: boolean): string | null =>
+ isPipeline ? 'flow.debugRunLimits' : null;
diff --git a/web/src/pages/agent/utils/pipeline-connection.test.ts b/web/src/pages/agent/utils/pipeline-connection.test.ts
index 5e65cf11e3..8159bc0e00 100644
--- a/web/src/pages/agent/utils/pipeline-connection.test.ts
+++ b/web/src/pages/agent/utils/pipeline-connection.test.ts
@@ -3,7 +3,7 @@ import {
buildPipelineNextOperators,
isChunkerOperator,
isSingleInstanceOperator,
- isValidGoPipelineConnection,
+ isValidPipelineConnection,
} from './pipeline-connection';
describe('isChunkerOperator', () => {
@@ -22,67 +22,67 @@ describe('isChunkerOperator', () => {
});
});
-describe('isValidGoPipelineConnection', () => {
+describe('isValidPipelineConnection', () => {
it('allows a Parser to feed a chunker', () => {
expect(
- isValidGoPipelineConnection(Operator.Parser, Operator.TokenChunker),
+ isValidPipelineConnection(Operator.Parser, Operator.TokenChunker),
).toBe(true);
expect(
- isValidGoPipelineConnection(Operator.Parser, Operator.TitleChunker),
+ isValidPipelineConnection(Operator.Parser, Operator.TitleChunker),
).toBe(true);
});
it('rejects a Parser feeding any non-chunker operator', () => {
- expect(
- isValidGoPipelineConnection(Operator.Parser, Operator.Tokenizer),
- ).toBe(false);
- expect(
- isValidGoPipelineConnection(Operator.Parser, Operator.Extractor),
- ).toBe(false);
- expect(
- isValidGoPipelineConnection(Operator.Parser, Operator.Compiler),
- ).toBe(false);
- expect(isValidGoPipelineConnection(Operator.Parser, Operator.Parser)).toBe(
+ expect(isValidPipelineConnection(Operator.Parser, Operator.Tokenizer)).toBe(
+ false,
+ );
+ expect(isValidPipelineConnection(Operator.Parser, Operator.Extractor)).toBe(
+ false,
+ );
+ expect(isValidPipelineConnection(Operator.Parser, Operator.Compiler)).toBe(
+ false,
+ );
+ expect(isValidPipelineConnection(Operator.Parser, Operator.Parser)).toBe(
false,
);
expect(
- isValidGoPipelineConnection(Operator.Parser, Operator.GeneralChunker),
+ isValidPipelineConnection(Operator.Parser, Operator.GeneralChunker),
).toBe(false);
});
it('rejects a chunker feeding another chunker', () => {
expect(
- isValidGoPipelineConnection(Operator.TokenChunker, Operator.TitleChunker),
+ isValidPipelineConnection(Operator.TokenChunker, Operator.TitleChunker),
).toBe(false);
expect(
- isValidGoPipelineConnection(Operator.TitleChunker, Operator.TokenChunker),
+ isValidPipelineConnection(Operator.TitleChunker, Operator.TokenChunker),
).toBe(false);
expect(
- isValidGoPipelineConnection(Operator.TokenChunker, Operator.TokenChunker),
+ isValidPipelineConnection(Operator.TokenChunker, Operator.TokenChunker),
).toBe(false);
});
it('allows a chunker to feed non-chunker operators', () => {
expect(
- isValidGoPipelineConnection(Operator.TokenChunker, Operator.Tokenizer),
+ isValidPipelineConnection(Operator.TokenChunker, Operator.Tokenizer),
).toBe(true);
expect(
- isValidGoPipelineConnection(Operator.TitleChunker, Operator.Extractor),
+ isValidPipelineConnection(Operator.TitleChunker, Operator.Extractor),
).toBe(true);
expect(
- isValidGoPipelineConnection(Operator.TokenChunker, Operator.Compiler),
+ isValidPipelineConnection(Operator.TokenChunker, Operator.Compiler),
).toBe(true);
});
it('leaves unrelated pairs unrestricted', () => {
- expect(isValidGoPipelineConnection(Operator.File, Operator.Parser)).toBe(
+ expect(isValidPipelineConnection(Operator.File, Operator.Parser)).toBe(
true,
);
expect(
- isValidGoPipelineConnection(Operator.Tokenizer, Operator.Extractor),
+ isValidPipelineConnection(Operator.Tokenizer, Operator.Extractor),
).toBe(true);
expect(
- isValidGoPipelineConnection(Operator.Extractor, Operator.Compiler),
+ isValidPipelineConnection(Operator.Extractor, Operator.Compiler),
).toBe(true);
});
});
@@ -110,21 +110,17 @@ describe('buildPipelineNextOperators', () => {
const hasExtractor = (operator: Operator) =>
operator === Operator.Extractor;
expect(
- buildPipelineNextOperators(undefined, true, hasExtractor).operators,
+ buildPipelineNextOperators(undefined, hasExtractor).operators,
).toContain(Operator.Extractor);
});
it('offers Compiler only when none is on the canvas', () => {
- const offered = buildPipelineNextOperators(
- undefined,
- true,
- noOperator,
- ).operators;
+ const offered = buildPipelineNextOperators(undefined, noOperator).operators;
expect(offered).toContain(Operator.Compiler);
const hasCompiler = (operator: Operator) => operator === Operator.Compiler;
expect(
- buildPipelineNextOperators(undefined, true, hasCompiler).operators,
+ buildPipelineNextOperators(undefined, hasCompiler).operators,
).not.toContain(Operator.Compiler);
});
@@ -133,7 +129,6 @@ describe('buildPipelineNextOperators', () => {
operator === Operator.TokenChunker;
const result = buildPipelineNextOperators(
Operator.TokenChunker,
- false,
hasTokenChunker,
);
expect(result.showChunker).toBe(false);
@@ -141,11 +136,7 @@ describe('buildPipelineNextOperators', () => {
});
it('offers both chunker variants while the chunker slot is free', () => {
- const result = buildPipelineNextOperators(
- Operator.Tokenizer,
- true,
- noOperator,
- );
+ const result = buildPipelineNextOperators(Operator.Tokenizer, noOperator);
expect(result.showChunker).toBe(true);
expect(result.chunkerOperators).toEqual([
Operator.TokenChunker,
diff --git a/web/src/pages/agent/utils/pipeline-connection.ts b/web/src/pages/agent/utils/pipeline-connection.ts
index ff2d493c69..ba1647f924 100644
--- a/web/src/pages/agent/utils/pipeline-connection.ts
+++ b/web/src/pages/agent/utils/pipeline-connection.ts
@@ -25,22 +25,21 @@ export interface PipelineNextOperators {
/**
* Build the "next step" operator menu for a pipeline source node. Mirrors the
- * Go topology rules from `isValidGoPipelineConnection`: on the Go backend a
- * Parser offers only the chunker group, and Extractor/Compiler/chunker sources
- * never offer the chunker group. Single-instance operators are filtered out
- * through `hasOperator`. Pure function so both the menu component and the
+ * topology rules from `isValidPipelineConnection`: a Parser offers only the
+ * chunker group, and Extractor/Compiler/chunker sources never offer the
+ * chunker group. Single-instance operators are filtered out through
+ * `hasOperator`. Pure function so both the menu component and the
* connection-drag gate can reuse it.
*/
export function buildPipelineNextOperators(
source: Operator | undefined,
- isGoBackend: boolean,
hasOperator: (operator: Operator) => boolean,
): PipelineNextOperators {
const operators: Operator[] = [];
- // Go pipelines require a Parser to feed a chunker, so from a Parser node
- // the menu offers only the chunker group.
- if (!(isGoBackend && source === Operator.Parser)) {
+ // Pipelines require a Parser to feed a chunker, so from a Parser node the
+ // menu offers only the chunker group.
+ if (source !== Operator.Parser) {
[Operator.Parser, Operator.Tokenizer, Operator.Compiler].forEach(
(operator) => {
if (!hasOperator(operator)) {
@@ -57,12 +56,12 @@ export function buildPipelineNextOperators(
const chunkerSlotTaken = ChunkerOperators.some(hasOperator);
const chunkerOperators = chunkerSlotTaken ? [] : ChunkerOperators;
- // Go pipelines forbid chunker -> chunker, mirroring the existing rule
- // that Extractor/Compiler never offer the chunker group.
+ // Pipelines forbid chunker -> chunker, mirroring the rule that
+ // Extractor/Compiler never offer the chunker group.
const sourceExcluded =
source === Operator.Extractor ||
source === Operator.Compiler ||
- (isGoBackend && !!source && isChunkerOperator(source));
+ (!!source && isChunkerOperator(source));
return {
operators,
@@ -78,22 +77,19 @@ export function buildPipelineNextOperators(
*/
export function hasPipelineNextOperators(
source: Operator | undefined,
- isGoBackend: boolean,
hasOperator: (operator: Operator) => boolean,
): boolean {
const { operators, chunkerOperators, showChunker } =
- buildPipelineNextOperators(source, isGoBackend, hasOperator);
+ buildPipelineNextOperators(source, hasOperator);
return operators.length > 0 || (showChunker && chunkerOperators.length > 0);
}
/**
- * Go-backend pipeline topology rules, enforced when a connection is created:
+ * Pipeline topology rules, enforced when a connection is created:
* a Parser may only feed a chunker, and a chunker may not feed another
- * chunker. All other source/target pairs are unrestricted. Pure function so
- * it can be unit-tested without mocking; callers gate on the backend through
- * `useIsGoBackend()`.
+ * chunker. All other source/target pairs are unrestricted.
*/
-export function isValidGoPipelineConnection(
+export function isValidPipelineConnection(
source: Operator,
target: Operator,
): boolean {
diff --git a/web/src/pages/chunk/parsed-result/add-knowledge/components/knowledge-chunk/components/chunk-creating-modal/tag-feature-item.tsx b/web/src/pages/chunk/parsed-result/add-knowledge/components/knowledge-chunk/components/chunk-creating-modal/tag-feature-item.tsx
index a63dc896d9..801d1c1fea 100644
--- a/web/src/pages/chunk/parsed-result/add-knowledge/components/knowledge-chunk/components/chunk-creating-modal/tag-feature-item.tsx
+++ b/web/src/pages/chunk/parsed-result/add-knowledge/components/knowledge-chunk/components/chunk-creating-modal/tag-feature-item.tsx
@@ -12,7 +12,6 @@ import {
useFetchKnowledgeBaseConfiguration,
useFetchTagListByKnowledgeIds,
} from '@/hooks/use-knowledge-request';
-import { useIsGoBackend } from '@/utils/backend-variant';
import { CircleMinus, Plus } from 'lucide-react';
import { useCallback, useEffect, useMemo } from 'react';
import { useFieldArray, useFormContext } from 'react-hook-form';
@@ -25,25 +24,19 @@ export const TagFeatureItem = () => {
const { t } = useTranslation();
const { setKnowledgeIds, list } = useFetchTagListByKnowledgeIds();
const { data: knowledgeConfiguration } = useFetchKnowledgeBaseConfiguration();
- const isGoBackend = useIsGoBackend();
const form = useFormContext();
const tagKnowledgeIds = useMemo(() => {
const configuredIds =
knowledgeConfiguration?.parser_config?.tag_kb_ids ?? [];
- // The Go ingestion pipeline keeps the tag vocabulary on the dataset's own
+ // The ingestion pipeline keeps the tag vocabulary on the dataset's own
// chunks and never writes tag-set references into parser_config.tag_kb_ids,
- // so fall back to aggregating the current dataset's tags through the Go
+ // so fall back to aggregating the current dataset's tags through the
// aggregation endpoint (GET /datasets/tags/aggregation).
- if (
- isGoBackend &&
- configuredIds.length === 0 &&
- knowledgeConfiguration?.id
- ) {
+ if (configuredIds.length === 0 && knowledgeConfiguration?.id) {
return [knowledgeConfiguration.id];
}
return configuredIds;
}, [
- isGoBackend,
knowledgeConfiguration?.id,
knowledgeConfiguration?.parser_config?.tag_kb_ids,
]);
diff --git a/web/src/pages/chunk/representation/index.tsx b/web/src/pages/chunk/representation/index.tsx
index 729158c210..dc3ad64251 100644
--- a/web/src/pages/chunk/representation/index.tsx
+++ b/web/src/pages/chunk/representation/index.tsx
@@ -1,15 +1,8 @@
-import { ConfirmDeleteDialog } from '@/components/confirm-delete-dialog';
import { ExpandableSearchInput } from '@/components/expandable-search-input';
import { SelectWithSearch } from '@/components/originui/select-with-search';
import { SkeletonCard } from '@/components/skeleton-card';
-import { Button } from '@/components/ui/button';
import { CompilationTemplateKind } from '@/constants/compilation';
-import {
- useDeleteDocumentStructureGraph,
- useFetchDocumentClaims,
-} from '@/hooks/use-document-request';
-import { useIsGoBackend } from '@/utils/backend-variant';
-import { Trash2 } from 'lucide-react';
+import { useFetchDocumentClaims } from '@/hooks/use-document-request';
import { memo, useCallback, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import {
@@ -44,9 +37,6 @@ function Representation({
onEvidencePanelChange,
}: RepresentationProps) {
const { t } = useTranslation();
- const isGo = useIsGoBackend();
- const { deleteDocumentStructureGraph, loading: deleting } =
- useDeleteDocumentStructureGraph();
const [claimsLeaf, setClaimsLeaf] = useState<ClickableNode | null>(null);
const [evidenceDetail, setEvidenceDetail] = useState<ClickableNode | null>(
@@ -204,11 +194,6 @@ function Representation({
[handleNodeClick, supportsClaims],
);
- const handleDelete = useCallback(async () => {
- if (!selectedTemplateId) return;
- await deleteDocumentStructureGraph(selectedTemplateId);
- }, [deleteDocumentStructureGraph, selectedTemplateId]);
-
return (
<section className="p-5 rounded-2xl h-full flex flex-col">
<div className="flex items-center gap-2">
@@ -236,20 +221,6 @@ function Representation({
/>
)}
</div>
- {templates.length > 0 && !isGo && (
- <ConfirmDeleteDialog onOk={handleDelete}>
- <Button
- variant="ghost"
- size="icon"
- type="button"
- disabled={deleting}
- aria-label={t('common.delete', 'Delete')}
- className="ml-auto shrink-0"
- >
- <Trash2 className="h-5 w-5" />
- </Button>
- </ConfirmDeleteDialog>
- )}
</div>
{loading && !data && <SkeletonCard className="mt-6" />}
{!(loading && !data) && templates.length === 0 && (
diff --git a/web/src/pages/dataflow-result/components/chunk-creating-modal/tag-feature-item.tsx b/web/src/pages/dataflow-result/components/chunk-creating-modal/tag-feature-item.tsx
index 118f7a5ff2..24a208d24b 100644
--- a/web/src/pages/dataflow-result/components/chunk-creating-modal/tag-feature-item.tsx
+++ b/web/src/pages/dataflow-result/components/chunk-creating-modal/tag-feature-item.tsx
@@ -12,7 +12,6 @@ import {
useFetchKnowledgeBaseConfiguration,
useFetchTagListByKnowledgeIds,
} from '@/hooks/use-knowledge-request';
-import { useIsGoBackend } from '@/utils/backend-variant';
import { CircleMinus, Plus } from 'lucide-react';
import { useCallback, useEffect, useMemo } from 'react';
import { useFieldArray, useFormContext } from 'react-hook-form';
@@ -25,25 +24,19 @@ export const TagFeatureItem = () => {
const { t } = useTranslation();
const { setKnowledgeIds, list } = useFetchTagListByKnowledgeIds();
const { data: knowledgeConfiguration } = useFetchKnowledgeBaseConfiguration();
- const isGoBackend = useIsGoBackend();
const form = useFormContext();
const tagKnowledgeIds = useMemo(() => {
const configuredIds =
knowledgeConfiguration?.parser_config?.tag_kb_ids ?? [];
- // The Go ingestion pipeline keeps the tag vocabulary on the dataset's own
+ // The ingestion pipeline keeps the tag vocabulary on the dataset's own
// chunks and never writes tag-set references into parser_config.tag_kb_ids,
- // so fall back to aggregating the current dataset's tags through the Go
+ // so fall back to aggregating the current dataset's tags through the
// aggregation endpoint (GET /datasets/tags/aggregation).
- if (
- isGoBackend &&
- configuredIds.length === 0 &&
- knowledgeConfiguration?.id
- ) {
+ if (configuredIds.length === 0 && knowledgeConfiguration?.id) {
return [knowledgeConfiguration.id];
}
return configuredIds;
}, [
- isGoBackend,
knowledgeConfiguration?.id,
knowledgeConfiguration?.parser_config?.tag_kb_ids,
]);
diff --git a/web/src/pages/dataset/compilation/constants.ts b/web/src/pages/dataset/compilation/constants.ts
index 77f7001a5c..06852bf604 100644
--- a/web/src/pages/dataset/compilation/constants.ts
+++ b/web/src/pages/dataset/compilation/constants.ts
@@ -1,7 +1,7 @@
import { GenerateType, ProcessingType } from '@/constants/knowledge';
import {
BookOpenText,
- CalendarChevronsRight,
+ CalendarRange,
ListIndentDecrease,
ListTree,
Waypoints,
@@ -50,7 +50,7 @@ export const ViewModeIconMap: Partial<Record<ViewMode, LucideIcon>> = {
[ViewMode.Tree]: ListTree,
[ViewMode.Graph]: Waypoints,
[ViewMode.MindMap]: ListIndentDecrease,
- [ViewMode.Timeline]: CalendarChevronsRight,
+ [ViewMode.Timeline]: CalendarRange,
};
// Dataset-log task_type values that correspond to a compilation view.
diff --git a/web/src/pages/dataset/compilation/dataset-structure-view.tsx b/web/src/pages/dataset/compilation/dataset-structure-view.tsx
index 4bd28d2b44..db3bd636bc 100644
--- a/web/src/pages/dataset/compilation/dataset-structure-view.tsx
+++ b/web/src/pages/dataset/compilation/dataset-structure-view.tsx
@@ -2,46 +2,29 @@ import {
SelectWithSearch,
SelectWithSearchFlagOptionType,
} from '@/components/originui/select-with-search';
-import { ConfirmDeleteDialog } from '@/components/confirm-delete-dialog';
import {
findEntityDisplayNameByKeyword,
getEntityDisplayName,
} from '@/components/structure-graph/adapters';
import { RepresentationRenderer } from '@/components/structure-graph/representation-renderer';
-import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';
-import { GenerateStatus } from '@/constants/knowledge';
import {
- useDatasetGenerate,
useGenerateStatus,
useTraceRunData,
} from '@/hooks/use-dataset-generate';
import {
- ArtifactAlterationKeys,
DatasetStructureKeys,
- useDeleteDatasetStructure,
- useFetchArtifactAlteration,
useFetchDatasetStructureGraph,
- useFetchKnowledgeBaseConfiguration,
useKnowledgeBaseId,
} from '@/hooks/use-knowledge-request';
-import { useIsGoBackend } from '@/utils/backend-variant';
import { useQueryClient } from '@tanstack/react-query';
-import { Trash2 } from 'lucide-react';
import { useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import {
- StructureKind,
- ViewMode,
- ViewModeGenerateTypeMap,
- ViewModeLabelKeyMap,
-} from './constants';
-import CompilationEmptyState from './empty-state';
+import { StructureKind, ViewMode, ViewModeGenerateTypeMap } from './constants';
import { useRunEndEffect } from './hooks/use-run-end-effect';
+import CompilationEmptyState from './empty-state';
import { CompilationLoadingCard } from './loading-card';
-import { CompilationUpdateButton } from './update-button';
-import { UpdateLogSheet } from './update-log-sheet';
interface DatasetStructureViewProps {
kind: StructureKind;
@@ -49,39 +32,22 @@ interface DatasetStructureViewProps {
export function DatasetStructureView({ kind }: DatasetStructureViewProps) {
const { t } = useTranslation();
- const isGo = useIsGoBackend();
const queryClient = useQueryClient();
const knowledgeBaseId = useKnowledgeBaseId();
- const { data: knowledgeBase } = useFetchKnowledgeBaseConfiguration();
const [graphKeywords, setGraphKeywords] = useState('');
const [selectedNodeId, setSelectedNodeId] = useState('');
const { data, loading } = useFetchDatasetStructureGraph(kind, graphKeywords);
const template = data?.templates?.[0];
- const { deleteDatasetStructure, loading: deleting } =
- useDeleteDatasetStructure();
const generateType = ViewModeGenerateTypeMap[kind];
const { data: structureRunData } = useTraceRunData(generateType);
const { status: structureStatus } = useGenerateStatus(structureRunData);
- const { data: alteration, loading: alterationLoading } =
- useFetchArtifactAlteration(kind);
- const { runGenerate, loading: runLoading } = useDatasetGenerate();
- const [updateSheetOpen, setUpdateSheetOpen] = useState(false);
-
- const newlyUploaded = alteration?.newly_uploaded ?? 0;
- const removed = alteration?.removed ?? 0;
- const retryPageCount = alteration?.retry_page_count ?? 0;
- const hasChanges = newlyUploaded > 0 || removed > 0 || retryPageCount > 0;
-
const handleRunEnd = useCallback(() => {
queryClient.invalidateQueries({
queryKey: DatasetStructureKeys.kind(knowledgeBaseId, kind),
});
- queryClient.invalidateQueries({
- queryKey: ArtifactAlterationKeys.detail(knowledgeBaseId, kind),
- });
- }, [queryClient, knowledgeBaseId, kind]);
+ }, [knowledgeBaseId, kind]);
useRunEndEffect(structureStatus, handleRunEnd);
@@ -134,70 +100,17 @@ export function DatasetStructureView({ kind }: DatasetStructureViewProps) {
[template?.entities, handleSelectEntity],
);
- const handleDeleteStructure = useCallback(async () => {
- const code = await deleteDatasetStructure(kind);
- if (code === 0) {
- setGraphKeywords('');
- setSelectedNodeId('');
- }
- }, [deleteDatasetStructure, kind]);
-
- const handleUpdateClick = useCallback(async () => {
- setUpdateSheetOpen(true);
- if (structureStatus === GenerateStatus.Running) {
- return;
- }
- await runGenerate({ type: generateType }).catch(() => {});
- }, [structureStatus, runGenerate, generateType]);
-
- const canGenerate = (knowledgeBase?.chunk_count ?? 0) > 0;
-
if (loading && !data) {
return <CompilationLoadingCard />;
}
if (!template && !graphKeywords) {
- return (
- <CompilationEmptyState
- type={kind}
- disabled={!canGenerate}
- data={structureRunData}
- />
- );
+ return <CompilationEmptyState type={kind} data={structureRunData} />;
}
return (
<Card className="flex-1 min-h-0 overflow-hidden flex border-border-button rounded-xl flex-col">
<div className="flex justify-between gap-4 px-4 pt-4">
- {!isGo && (
- <div className="flex items-center gap-2">
- <ConfirmDeleteDialog
- title={t('knowledgeCompilation.deleteStructureConfirm', {
- name: t(ViewModeLabelKeyMap[kind]),
- })}
- onOk={handleDeleteStructure}
- >
- <Button variant="outline" size="sm" disabled={deleting}>
- <Trash2 />
- </Button>
- </ConfirmDeleteDialog>
- <CompilationUpdateButton
- traceData={structureRunData}
- generateType={generateType}
- hasChanges={hasChanges}
- newlyUploaded={newlyUploaded}
- removed={removed}
- retryPageCount={retryPageCount}
- loading={alterationLoading || runLoading}
- tooltip={t('knowledgeCompilation.updateStructureTooltip', {
- newlyUploaded,
- removed,
- name: t(ViewModeLabelKeyMap[kind]),
- })}
- onClick={handleUpdateClick}
- />
- </div>
- )}
{kind === ViewMode.Graph && (
<SelectWithSearch
options={entityOptions}
@@ -218,14 +131,6 @@ export function DatasetStructureView({ kind }: DatasetStructureViewProps) {
totalEntities={data?.total_entities}
returnedEntities={data?.returned_entities}
/>
- <UpdateLogSheet
- open={updateSheetOpen}
- onOpenChange={setUpdateSheetOpen}
- data={structureRunData}
- title={t('knowledgeCompilation.updateStructureSheetTitle', {
- name: t(ViewModeLabelKeyMap[kind]),
- })}
- />
</Card>
);
}
diff --git a/web/src/pages/dataset/compilation/empty-state.tsx b/web/src/pages/dataset/compilation/empty-state.tsx
index 1b877769e1..8cb5d4a0b6 100644
--- a/web/src/pages/dataset/compilation/empty-state.tsx
+++ b/web/src/pages/dataset/compilation/empty-state.tsx
@@ -1,31 +1,14 @@
-import { CircleX, WandSparkles } from 'lucide-react';
-import { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
-import { IconFontFill } from '@/components/icon-font';
-import { Button } from '@/components/ui/button';
-import {
- ITraceInfo,
- useDatasetGenerate,
- useGenerateStatus,
-} from '@/hooks/use-dataset-generate';
-import { useIsGoBackend } from '@/utils/backend-variant';
+import { ITraceInfo, useGenerateStatus } from '@/hooks/use-dataset-generate';
-import {
- GenerableViewMode,
- ViewMode,
- ViewModeGenerateTypeMap,
- ViewModeLabelKeyMap,
-} from './constants';
+import { GenerableViewMode, ViewMode, ViewModeLabelKeyMap } from './constants';
import { CompileProgressBoard } from './compile-progress-board';
-import { ProgressLogPanel } from './progress-log-panel';
-import { ProgressRing } from './progress-ring';
type EmptyStateType = GenerableViewMode;
interface ICompilationEmptyStateProps {
type: EmptyStateType;
- disabled?: boolean;
data?: ITraceInfo;
}
@@ -39,82 +22,28 @@ const TitleKeyMap: Record<EmptyStateType, string> = {
export function CompilationEmptyState({
type,
- disabled,
data,
}: ICompilationEmptyStateProps) {
const { t } = useTranslation();
- const generateType = ViewModeGenerateTypeMap[type];
- const { runGenerate, pauseGenerate } = useDatasetGenerate();
- const { status, percent } = useGenerateStatus(data);
-
- const handleGenerate = useCallback(() => {
- runGenerate({ type: generateType }).catch(() => {});
- }, [runGenerate, generateType]);
-
- const handlePause = useCallback(() => {
- if (data?.id) {
- pauseGenerate({ task_id: data.id, type: generateType }).catch(() => {});
- }
- }, [pauseGenerate, data?.id, generateType]);
+ const { status } = useGenerateStatus(data);
const showProgress = status === 'running' || status === 'failed';
- const isGo = useIsGoBackend();
return (
<div className="flex-1 min-h-0 flex flex-col items-center justify-center border border-dashed border-border-button rounded-xl">
{!showProgress ? (
<div className="flex flex-col items-center gap-4">
<p className="text-text-secondary text-lg">{t(TitleKeyMap[type])}</p>
- {!isGo && (
- <Button
- variant="outline"
- onClick={handleGenerate}
- disabled={disabled}
- >
- <WandSparkles className="mr-2 size-4" />
- {t('knowledgeCompilation.generate')}
- </Button>
- )}
- {isGo && (
- <p className="text-sm text-text-secondary">
- {t('knowledgeCompilation.autoCompiled')}
- </p>
- )}
+ <p className="text-sm text-text-secondary">
+ {t('knowledgeCompilation.autoCompiled')}
+ </p>
</div>
- ) : isGo ? (
+ ) : (
<CompileProgressBoard
status={status}
data={data}
label={t(ViewModeLabelKeyMap[type])}
/>
- ) : (
- <div className="grid h-full w-full grid-cols-[1fr_auto_1fr] items-center gap-8 p-6">
- <div />
- <div className="flex flex-col items-center gap-5">
- <ProgressRing percent={percent} failed={status === 'failed'} />
- <div className="flex items-center gap-2 text-text-primary">
- <span>{t(ViewModeLabelKeyMap[type])}</span>
- {status === 'failed' ? (
- <span className="cursor-pointer" onClick={handleGenerate}>
- <IconFontFill
- name="reparse"
- className="text-accent-primary"
- />
- </span>
- ) : (
- <span
- className="text-state-error cursor-pointer"
- onClick={handlePause}
- >
- <CircleX className="size-5 text-state-error" />
- </span>
- )}
- </div>
- </div>
- <div className="flex min-h-0 h-full justify-end">
- <ProgressLogPanel progressMsg={data?.progress_msg} />
- </div>
- </div>
)}
</div>
);
diff --git a/web/src/pages/dataset/compilation/hooks/use-compilation-nav.ts b/web/src/pages/dataset/compilation/hooks/use-compilation-nav.ts
index 90011d3274..2f7a9aa0da 100644
--- a/web/src/pages/dataset/compilation/hooks/use-compilation-nav.ts
+++ b/web/src/pages/dataset/compilation/hooks/use-compilation-nav.ts
@@ -5,8 +5,6 @@ import {
} from '@/hooks/use-dataset-generate';
import {
DatasetNavKeys,
- useDeleteDatasetNav,
- useDeleteDatasetNavNode,
useFetchDatasetNav,
useFetchDatasetNavChildren,
} from '@/hooks/use-dataset-nav-request';
@@ -14,7 +12,6 @@ import { useFetchDocumentStructureGraphById } from '@/hooks/use-document-request
import { useKnowledgeBaseId } from '@/hooks/use-knowledge-request';
import { DatasetNavNode } from '@/interfaces/database/dataset-nav';
import { IStructureGraphTemplate } from '@/interfaces/database/document-structure';
-import { useIsGoBackend } from '@/utils/backend-variant';
import { useQueryClient } from '@tanstack/react-query';
import { useDebounce } from 'ahooks';
import { trim } from 'lodash';
@@ -45,9 +42,6 @@ export function useCompilationNav() {
loading: navLoading,
isError: navError,
} = useFetchDatasetNav(debouncedKeywords);
- const { deleteNav, loading: deleteNavLoading } = useDeleteDatasetNav();
- const { deleteNavNode, loading: deleteNodeLoading } =
- useDeleteDatasetNavNode();
const [loadingParent, setLoadingParent] = useState<string | null>(null);
const [childrenMap, setChildrenMap] = useState<
@@ -138,12 +132,11 @@ export function useCompilationNav() {
}, [activeKeywords, clearExpandedData]);
const queryClient = useQueryClient();
- const isGo = useIsGoBackend();
- // Go: the nav tree is a by-product of tree/structure knowledge compilation.
+ // The nav tree is a by-product of tree/structure knowledge compilation.
// Poll the Tree-scoped scheduler status (kind "raptor" normalizes to "Tree")
// so the view can surface compile progress/logs and refresh the tree when a
- // run ends. Python keeps the read-only behavior (no polling, no log UI).
- const { data: navRunData } = useTraceRunData(GenerateType.Raptor, isGo);
+ // run ends.
+ const { data: navRunData } = useTraceRunData(GenerateType.Raptor);
const { status: navStatus } = useGenerateStatus(navRunData);
const handleCompileRunEnd = useCallback(() => {
@@ -181,54 +174,6 @@ export function useCompilationNav() {
[structureMap],
);
- const removeChild = useCallback((parentName: string, childName: string) => {
- setChildrenMap((prev) => {
- const children = prev[parentName];
- if (!children) {
- return prev;
- }
- return {
- ...prev,
- [parentName]: children.filter((node) => node.name !== childName),
- };
- });
- }, []);
-
- const dropChildren = useCallback((name: string) => {
- setChildrenMap((prev) => {
- if (!(name in prev)) {
- return prev;
- }
- const next = { ...prev };
- delete next[name];
- return next;
- });
- setChildrenErrorParents((prev) => {
- if (!(name in prev)) {
- return prev;
- }
- const next = { ...prev };
- delete next[name];
- return next;
- });
- }, []);
-
- const dropStructure = useCallback((docId: string) => {
- setStructureMap((prev) => {
- if (!(docId in prev)) {
- return prev;
- }
- const next = { ...prev };
- delete next[docId];
- return next;
- });
- }, []);
-
- const resetNav = useCallback(() => {
- setSelectedNode(null);
- clearExpandedData();
- }, [clearExpandedData]);
-
const handleKeywordsChange = useCallback(
(e: React.ChangeEvent<HTMLInputElement>) => {
setKeywords(e.target.value);
@@ -274,52 +219,6 @@ export function useCompilationNav() {
[],
);
- const handleDeleteAll = useCallback(async () => {
- const data = await deleteNav();
- if (data?.code === 0) {
- resetNav();
- }
- }, [deleteNav, resetNav]);
-
- const handleDeleteNode = useCallback(
- async (name: string, parentName: string | null) => {
- const removed = parentName
- ? childrenMap[parentName]?.find((node) => node.name === name)
- : undefined;
- const data = await deleteNavNode(name);
- if (data?.code === 0) {
- if (parentName) {
- // The children query of this parent may have no active observer, so
- // invalidation alone would not refetch — filter the local map too.
- removeChild(parentName, name);
- // A deleted sub-cluster may have loaded children; a deleted document
- // may have a loaded structure graph. Drop both from the local maps.
- dropChildren(name);
- if (removed?.doc_id) {
- dropStructure(removed.doc_id);
- }
- setSelectedNode((current) =>
- (current?.parentName === parentName && current?.name === name) ||
- (removed?.doc_id && current?.docId === removed.doc_id)
- ? null
- : current,
- );
- } else {
- dropChildren(name);
- // Clear the selection when the deleted root is the selected node
- // itself or the parent of the selected child.
- setSelectedNode((current) =>
- current?.parentName === name ||
- (current?.parentName === null && current?.name === name)
- ? null
- : current,
- );
- }
- }
- },
- [deleteNavNode, childrenMap, removeChild, dropChildren, dropStructure],
- );
-
return {
navList,
navLoading,
@@ -330,15 +229,11 @@ export function useCompilationNav() {
childrenErrorParents,
structureMap,
selectedNode,
- deleteNavLoading,
- deleteNodeLoading,
navRunData,
navStatus,
handleKeywordsChange,
handleNodeClick,
handleNodeExpand,
handleEntityClick,
- handleDeleteAll,
- handleDeleteNode,
};
}
diff --git a/web/src/pages/dataset/compilation/hooks/use-run-end-effect.ts b/web/src/pages/dataset/compilation/hooks/use-run-end-effect.ts
index 3d80e0f5f8..0bfe96ae6c 100644
--- a/web/src/pages/dataset/compilation/hooks/use-run-end-effect.ts
+++ b/web/src/pages/dataset/compilation/hooks/use-run-end-effect.ts
@@ -7,7 +7,10 @@ import { useEffect, useRef } from 'react';
// so the trace resets and Running -> Start), or failed. Views refresh their
// data through this single path so pausing behaves exactly like completion.
// Debounced to fire 1s after the run settles, so the refetch reads final state.
-export function useRunEndEffect(status: GenerateStatus, onRunEnd: () => void) {
+export function useRunEndEffect(
+ status: GenerateStatus,
+ onRunEnd: () => void = () => {},
+) {
const prevStatusRef = useRef(status);
const { run: scheduleRunEnd } = useDebounceFn(onRunEnd, { wait: 2000 });
diff --git a/web/src/pages/dataset/compilation/llm-wiki-view.tsx b/web/src/pages/dataset/compilation/llm-wiki-view.tsx
index 784fcf6715..92ada20d09 100644
--- a/web/src/pages/dataset/compilation/llm-wiki-view.tsx
+++ b/web/src/pages/dataset/compilation/llm-wiki-view.tsx
@@ -10,30 +10,22 @@ import {
useTraceRunData,
} from '@/hooks/use-dataset-generate';
import {
- ArtifactAlterationKeys,
- ArtifactKeys,
- ArtifactTopicKeys,
useFetchArtifactTopicList,
useFetchKnowledgeBaseConfiguration,
} from '@/hooks/use-knowledge-request';
-import { useQueryClient } from '@tanstack/react-query';
-import { useCallback, useState } from 'react';
-import { useParams } from 'react-router';
+import { useState } from 'react';
import { LeftPanelTab, ViewMode } from './constants';
import CompilationEmptyState from './empty-state';
import { useCompilationArtifact } from './hooks/use-compilation-artifact';
import { useRunEndEffect } from './hooks/use-run-end-effect';
import { CompilationLoadingCard } from './loading-card';
-import { canGenerateWiki } from './wiki-generation-eligibility';
import { WikiDetailContent } from './wiki-detail-content';
import { WikiLeftPanel } from './wiki-left-panel';
export function LlmWikiView() {
- const { id } = useParams();
- const queryClient = useQueryClient();
const [leftTab, setLeftTab] = useState<LeftPanelTab>(LeftPanelTab.Contents);
- const { data: knowledgeBase } = useFetchKnowledgeBaseConfiguration();
+ useFetchKnowledgeBaseConfiguration();
const { topics, loading: topicListLoading } = useFetchArtifactTopicList();
const {
selectedArtifact,
@@ -45,26 +37,13 @@ export function LlmWikiView() {
const { data: artifactRunData } = useTraceRunData(GenerateType.Artifact);
const { status: artifactStatus } = useGenerateStatus(artifactRunData);
- const [updateSheetOpen, setUpdateSheetOpen] = useState(false);
- const handleRunEnd = useCallback(() => {
- queryClient.invalidateQueries({
- queryKey: ArtifactAlterationKeys.detail(id!, 'wiki'),
- });
- queryClient.invalidateQueries({
- queryKey: ArtifactKeys.listByDataset(id!),
- });
- queryClient.invalidateQueries({
- queryKey: ArtifactTopicKeys.listByDataset(id!),
- });
- }, [queryClient, id]);
- useRunEndEffect(artifactStatus, handleRunEnd);
+ useRunEndEffect(artifactStatus);
- const handleLeftTabChange = useCallback((value: string) => {
+ const handleLeftTabChange = (value: string) => {
setLeftTab(value as LeftPanelTab);
- }, []);
+ };
- const canGenerate = canGenerateWiki(knowledgeBase);
const isLoading = topicListLoading && topics.length === 0;
const isEmpty = topics.length === 0 && !topicListLoading;
@@ -74,11 +53,7 @@ export function LlmWikiView() {
if (isEmpty) {
return (
- <CompilationEmptyState
- type={ViewMode.LlmWiki}
- disabled={!canGenerate}
- data={artifactRunData}
- />
+ <CompilationEmptyState type={ViewMode.LlmWiki} data={artifactRunData} />
);
}
@@ -92,10 +67,6 @@ export function LlmWikiView() {
selectedArtifact={selectedArtifact}
onSelectArtifact={handleSelectArtifact}
onClearArtifact={clearSelectedArtifact}
- onClearWiki={clearSelectedArtifact}
- updateSheetOpen={updateSheetOpen}
- onUpdateSheetOpenChange={setUpdateSheetOpen}
- traceData={artifactRunData}
/>
</ResizablePanel>
{selectedArtifact && (
diff --git a/web/src/pages/dataset/compilation/nav-tree-left-panel.test.tsx b/web/src/pages/dataset/compilation/nav-tree-left-panel.test.tsx
index 4dac2a3302..2004d82c88 100644
--- a/web/src/pages/dataset/compilation/nav-tree-left-panel.test.tsx
+++ b/web/src/pages/dataset/compilation/nav-tree-left-panel.test.tsx
@@ -16,12 +16,6 @@ jest.mock('@/components/ui/tree-view', () => ({
),
}));
-jest.mock('@/components/confirm-delete-dialog', () => ({
- ConfirmDeleteDialog: ({ children }: { children: React.ReactNode }) => (
- <>{children}</>
- ),
-}));
-
jest.mock('@/components/ui/input', () => ({
SearchInput: () => <input data-testid="nav-search" />,
}));
@@ -34,10 +28,6 @@ jest.mock('react-i18next', () => ({
useTranslation: () => ({ t: (key: string) => key }),
}));
-jest.mock('@/utils/backend-variant', () => ({
- useIsGoBackend: () => true,
-}));
-
const mockCompileStatus = { value: GenerateStatus.Start };
jest.mock('@/hooks/use-dataset-generate', () => ({
@@ -62,8 +52,6 @@ const PanelHandlers = {
onNodeClick: jest.fn(),
onNodeExpand: jest.fn(),
onEntityClick: jest.fn(),
- onDeleteAll: jest.fn(),
- onDeleteNode: jest.fn(),
};
describe('NavTreeLeftPanel', () => {
@@ -81,8 +69,6 @@ describe('NavTreeLeftPanel', () => {
activeKeywords=""
childrenMap={{}}
structureMap={{}}
- deleteNavLoading={false}
- deleteNodeLoading={false}
{...PanelHandlers}
/>,
);
@@ -103,8 +89,6 @@ describe('NavTreeLeftPanel', () => {
activeKeywords=""
childrenMap={{}}
structureMap={{}}
- deleteNavLoading={false}
- deleteNodeLoading={false}
{...PanelHandlers}
/>,
);
@@ -115,7 +99,7 @@ describe('NavTreeLeftPanel', () => {
expect(screen.queryByTestId('nav-tree')).not.toBeInTheDocument();
});
- it('shows no compile log entry when no Go compile is running', () => {
+ it('shows no compile log entry when no compile is running', () => {
render(
<NavTreeLeftPanel
navList={{ total: 1, items: [NavItem] }}
@@ -124,8 +108,6 @@ describe('NavTreeLeftPanel', () => {
activeKeywords=""
childrenMap={{}}
structureMap={{}}
- deleteNavLoading={false}
- deleteNodeLoading={false}
{...PanelHandlers}
/>,
);
@@ -135,7 +117,7 @@ describe('NavTreeLeftPanel', () => {
).not.toBeInTheDocument();
});
- it('opens the log sheet from the compile log entry while a Go compile runs', () => {
+ it('opens the log sheet from the compile log entry while a compile runs', () => {
mockCompileStatus.value = GenerateStatus.Running;
render(
<NavTreeLeftPanel
@@ -145,8 +127,6 @@ describe('NavTreeLeftPanel', () => {
activeKeywords=""
childrenMap={{}}
structureMap={{}}
- deleteNavLoading={false}
- deleteNodeLoading={false}
traceData={{ compilationState: 'running' } as any}
{...PanelHandlers}
/>,
@@ -159,7 +139,7 @@ describe('NavTreeLeftPanel', () => {
);
});
- it('shows the error diagnostic on the log entry when a Go compile failed', () => {
+ it('shows the error diagnostic on the log entry when a compile failed', () => {
mockCompileStatus.value = GenerateStatus.Failed;
render(
<NavTreeLeftPanel
@@ -169,8 +149,6 @@ describe('NavTreeLeftPanel', () => {
activeKeywords=""
childrenMap={{}}
structureMap={{}}
- deleteNavLoading={false}
- deleteNodeLoading={false}
traceData={{ compilationError: 'embed boom' } as any}
{...PanelHandlers}
/>,
diff --git a/web/src/pages/dataset/compilation/nav-tree-left-panel.tsx b/web/src/pages/dataset/compilation/nav-tree-left-panel.tsx
index d27779c156..0509df2a37 100644
--- a/web/src/pages/dataset/compilation/nav-tree-left-panel.tsx
+++ b/web/src/pages/dataset/compilation/nav-tree-left-panel.tsx
@@ -1,4 +1,3 @@
-import { ConfirmDeleteDialog } from '@/components/confirm-delete-dialog';
import { Button } from '@/components/ui/button';
import { SearchInput } from '@/components/ui/input';
import { Spin } from '@/components/ui/spin';
@@ -11,8 +10,7 @@ import {
} from '@/interfaces/database/dataset-nav';
import { IStructureGraphTemplate } from '@/interfaces/database/document-structure';
import { cn } from '@/lib/utils';
-import { useIsGoBackend } from '@/utils/backend-variant';
-import { CircleX, FileText, Folder, Loader2, Trash2 } from 'lucide-react';
+import { CircleX, FileText, Folder, Loader2 } from 'lucide-react';
import { useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { UpdateLogSheet } from './update-log-sheet';
@@ -21,63 +19,9 @@ import { buildNavTreeData, NavEntityClickHandler } from './utils/nav-tree';
// TreeView only computes expandedItemIds when initialSelectedItemId is truthy;
// combined with expandAll, any truthy id makes every branch mount open. A
// sentinel that matches no real node forces expand-all without highlighting any
-// row as selected (same trick as skills-left-panel).
+// row as selected.
const NavExpandAllSentinelId = '__nav-tree-expand-all-sentinel__';
-type NavNodeDeleteActionProps = {
- name: string;
- parentName: string | null;
- deleteLoading: boolean;
- onDelete: (name: string, parentName: string | null) => void;
-};
-
-function NavNodeDeleteAction({
- name,
- parentName,
- deleteLoading,
- onDelete,
-}: NavNodeDeleteActionProps) {
- const { t } = useTranslation();
- const isGo = useIsGoBackend();
-
- const handleTriggerClick = useCallback(
- (e: React.MouseEvent<HTMLButtonElement>) => {
- // TreeView does not guard action clicks: without this the row would
- // also get selected and a branch row would toggle its accordion.
- e.stopPropagation();
- },
- [],
- );
-
- const handleConfirmDelete = useCallback(() => {
- onDelete(name, parentName);
- }, [name, parentName, onDelete]);
-
- // The Go backend does not support deleting nav nodes; don't mount the action.
- if (isGo) return null;
-
- return (
- <ConfirmDeleteDialog
- title={t('knowledgeCompilation.navDeleteNodeTitle')}
- content={{ title: t('knowledgeCompilation.navDeleteNodeDescription') }}
- onOk={handleConfirmDelete}
- >
- <Button
- variant="ghost"
- size="icon-sm"
- disabled={deleteLoading}
- onClick={handleTriggerClick}
- // TreeActions keeps actions always visible on the selected row;
- // hide again so the button only appears while hovering the row.
- // `hidden` (not opacity-0) so no invisible click target remains.
- className="hidden group-hover:inline-flex"
- >
- <Trash2 />
- </Button>
- </ConfirmDeleteDialog>
- );
-}
-
type NavTreeLeftPanelProps = {
navList: DatasetNavList | null;
navLoading: boolean;
@@ -92,15 +36,11 @@ type NavTreeLeftPanelProps = {
childrenMap: Record<string, DatasetNavNode[]>;
childrenErrorParents?: Record<string, boolean>;
structureMap: Record<string, IStructureGraphTemplate[]>;
- deleteNavLoading: boolean;
- deleteNodeLoading: boolean;
traceData?: ITraceInfo;
onKeywordsChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
onNodeClick: (node: DatasetNavNode, parentName: string | null) => void;
onNodeExpand: (node: DatasetNavNode) => void;
onEntityClick: NavEntityClickHandler;
- onDeleteAll: () => void;
- onDeleteNode: (name: string, parentName: string | null) => void;
};
export function NavTreeLeftPanel({
@@ -112,46 +52,28 @@ export function NavTreeLeftPanel({
childrenMap,
childrenErrorParents = {},
structureMap,
- deleteNavLoading,
- deleteNodeLoading,
traceData,
onKeywordsChange,
onNodeClick,
onNodeExpand,
onEntityClick,
- onDeleteAll,
- onDeleteNode,
}: NavTreeLeftPanelProps) {
const { t } = useTranslation();
- const isGo = useIsGoBackend();
const { status: compileStatus } = useGenerateStatus(traceData);
const [logSheetOpen, setLogSheetOpen] = useState(false);
- // Go: an incremental compile is running while a tree is already on screen —
+ // An incremental compile is running while a tree is already on screen —
// surface it as a log entry point in the header (the full-view placeholder
// covers the first compile, when no tree exists).
const compiling =
- isGo &&
- (compileStatus === GenerateStatus.Running ||
- compileStatus === GenerateStatus.Failed);
+ compileStatus === GenerateStatus.Running ||
+ compileStatus === GenerateStatus.Failed;
const compileFailed = compiling && compileStatus === GenerateStatus.Failed;
const handleOpenLogSheet = useCallback(() => {
setLogSheetOpen(true);
}, []);
- const renderNavActions = useCallback(
- (node: DatasetNavNode, parentName: string | null) => (
- <NavNodeDeleteAction
- name={node.name}
- parentName={parentName}
- deleteLoading={deleteNodeLoading}
- onDelete={onDeleteNode}
- />
- ),
- [deleteNodeLoading, onDeleteNode],
- );
-
const treeData = useMemo(
() =>
buildNavTreeData(navList?.items, {
@@ -162,7 +84,6 @@ export function NavTreeLeftPanel({
// them), so it is nested from the payload instead of being fetched
// branch by branch.
searchMode: !!activeKeywords,
- getActions: renderNavActions,
onNodeClick,
onNodeExpand,
onEntityClick,
@@ -175,7 +96,6 @@ export function NavTreeLeftPanel({
childrenMap,
childrenErrorParents,
structureMap,
- renderNavActions,
onNodeClick,
onNodeExpand,
onEntityClick,
@@ -189,24 +109,6 @@ export function NavTreeLeftPanel({
<span className="text-sm font-medium text-text-primary">
{t('knowledgeCompilation.navTitle')} ({navList?.total ?? 0})
</span>
- {!isGo && treeData.length > 0 && (
- <ConfirmDeleteDialog
- title={t('knowledgeCompilation.navDeleteAllTitle')}
- content={{
- title: t('knowledgeCompilation.navDeleteAllDescription'),
- }}
- onOk={onDeleteAll}
- >
- <Button
- variant="ghost"
- size="icon-sm"
- disabled={deleteNavLoading}
- data-testid="nav-tree-clear-trigger"
- >
- <Trash2 />
- </Button>
- </ConfirmDeleteDialog>
- )}
{compiling && (
<Button
variant="ghost"
diff --git a/web/src/pages/dataset/compilation/nav-tree-view.tsx b/web/src/pages/dataset/compilation/nav-tree-view.tsx
index d99f076c23..de05e0960a 100644
--- a/web/src/pages/dataset/compilation/nav-tree-view.tsx
+++ b/web/src/pages/dataset/compilation/nav-tree-view.tsx
@@ -5,7 +5,6 @@ import {
ResizablePanelGroup,
} from '@/components/ui/resizable';
import { GenerateStatus } from '@/constants/knowledge';
-import { useIsGoBackend } from '@/utils/backend-variant';
import { useTranslation } from 'react-i18next';
import { useCompilationNav } from './hooks/use-compilation-nav';
@@ -14,7 +13,6 @@ import { NavTreeLeftPanel } from './nav-tree-left-panel';
export function NavTreeView() {
const { t } = useTranslation();
- const isGo = useIsGoBackend();
const {
navList,
navLoading,
@@ -25,22 +23,16 @@ export function NavTreeView() {
childrenErrorParents,
structureMap,
selectedNode,
- deleteNavLoading,
- deleteNodeLoading,
navRunData,
navStatus,
handleKeywordsChange,
handleNodeClick,
handleNodeExpand,
handleEntityClick,
- handleDeleteAll,
- handleDeleteNode,
} = useCompilationNav();
const compiling =
- isGo &&
- (navStatus === GenerateStatus.Running ||
- navStatus === GenerateStatus.Failed);
+ navStatus === GenerateStatus.Running || navStatus === GenerateStatus.Failed;
// First compile: no tree content to show yet, so replace the panels with
// the progress board. A keywords-filtered empty result keeps the panels so
// the user can keep editing the filter.
@@ -68,15 +60,11 @@ export function NavTreeView() {
childrenMap={childrenMap}
childrenErrorParents={childrenErrorParents}
structureMap={structureMap}
- deleteNavLoading={deleteNavLoading}
- deleteNodeLoading={deleteNodeLoading}
traceData={navRunData}
onKeywordsChange={handleKeywordsChange}
onNodeClick={handleNodeClick}
onNodeExpand={handleNodeExpand}
onEntityClick={handleEntityClick}
- onDeleteAll={handleDeleteAll}
- onDeleteNode={handleDeleteNode}
/>
</ResizablePanel>
<ResizableHandle withHandle />
diff --git a/web/src/pages/dataset/compilation/skills-left-panel.tsx b/web/src/pages/dataset/compilation/skills-left-panel.tsx
index af99b0f12e..3a7e8a8274 100644
--- a/web/src/pages/dataset/compilation/skills-left-panel.tsx
+++ b/web/src/pages/dataset/compilation/skills-left-panel.tsx
@@ -1,16 +1,9 @@
-import { ConfirmDeleteDialog } from '@/components/confirm-delete-dialog';
-import { Button } from '@/components/ui/button';
import { SearchInput } from '@/components/ui/input';
import { Spin } from '@/components/ui/spin';
import { TreeDataItem, TreeView } from '@/components/ui/tree-view';
-import {
- useDeleteDatasetSkillPage,
- useDeleteDatasetSkillTree,
- useFetchDatasetSkillTree,
-} from '@/hooks/use-dataset-skill-request';
-import { useIsGoBackend } from '@/utils/backend-variant';
+import { useFetchDatasetSkillTree } from '@/hooks/use-dataset-skill-request';
import { useDebounce } from 'ahooks';
-import { FileText, Folder, Trash2 } from 'lucide-react';
+import { FileText, Folder } from 'lucide-react';
import { useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import {
@@ -30,69 +23,12 @@ type SkillsLeftPanelProps = {
onSelectSkill: (skillKwd: string | null) => void;
};
-type SkillDeleteActionProps = {
- skillKwd: string;
- deleteLoading: boolean;
- onDelete: (skillKwd: string) => void;
-};
-
-function SkillDeleteAction({
- skillKwd,
- deleteLoading,
- onDelete,
-}: SkillDeleteActionProps) {
- const { t } = useTranslation();
- const isGo = useIsGoBackend();
-
- const handleTriggerClick = useCallback(
- (e: React.MouseEvent<HTMLButtonElement>) => {
- // TreeView does not guard action clicks: without this the row would
- // also get selected and a branch row would toggle its accordion.
- e.stopPropagation();
- },
- [],
- );
-
- const handleConfirmDelete = useCallback(() => {
- onDelete(skillKwd);
- }, [skillKwd, onDelete]);
-
- // The Go backend does not support deleting skill pages; don't mount the action.
- if (isGo) return null;
-
- return (
- <ConfirmDeleteDialog
- title={t('knowledgeCompilation.skillDeleteTitle')}
- content={{ title: t('knowledgeCompilation.skillDeleteDescription') }}
- onOk={handleConfirmDelete}
- >
- <Button
- variant="ghost"
- size="icon-sm"
- disabled={deleteLoading}
- onClick={handleTriggerClick}
- // TreeActions keeps actions always visible on the selected row;
- // hide again so the button only appears while hovering the row.
- // `hidden` (not opacity-0) so no invisible click target remains.
- className="hidden group-hover:inline-flex"
- >
- <Trash2 />
- </Button>
- </ConfirmDeleteDialog>
- );
-}
-
export function SkillsLeftPanel({
- selectedSkill,
+ selectedSkill: _selectedSkill,
onSelectSkill,
}: SkillsLeftPanelProps) {
const { t } = useTranslation();
- const isGo = useIsGoBackend();
const { data: tree, loading } = useFetchDatasetSkillTree();
- const { deleteSkillTree, loading: deleteTreeLoading } =
- useDeleteDatasetSkillTree();
- const { deleteSkillPage, loading: deletePageLoading } =
- useDeleteDatasetSkillPage();
const [searchString, setSearchString] = useState('');
const debouncedSearchString = useDebounce(searchString, { wait: 500 });
@@ -108,37 +44,9 @@ export function SkillsLeftPanel({
[],
);
- const handleDeleteAll = useCallback(async () => {
- const data = await deleteSkillTree();
- if (data?.code === 0) {
- onSelectSkill(null);
- }
- }, [deleteSkillTree, onSelectSkill]);
-
- const handleDeleteSkill = useCallback(
- async (skillKwd: string) => {
- const data = await deleteSkillPage(skillKwd);
- if (data?.code === 0 && selectedSkill === skillKwd) {
- onSelectSkill(null);
- }
- },
- [deleteSkillPage, selectedSkill, onSelectSkill],
- );
-
- const renderSkillActions = useCallback(
- (skillKwd: string) => (
- <SkillDeleteAction
- skillKwd={skillKwd}
- deleteLoading={deletePageLoading}
- onDelete={handleDeleteSkill}
- />
- ),
- [deletePageLoading, handleDeleteSkill],
- );
-
const treeData = useMemo(
- () => buildSkillTreeData(tree?.skill_with_weight, renderSkillActions),
- [tree?.skill_with_weight, renderSkillActions],
+ () => buildSkillTreeData(tree?.skill_with_weight),
+ [tree?.skill_with_weight],
);
const filteredTreeData = useMemo(
@@ -159,24 +67,6 @@ export function SkillsLeftPanel({
<span className="text-sm font-medium text-text-primary">
{t('knowledgeCompilation.skillFolders')} ({totalCount})
</span>
- {!isGo && (
- <ConfirmDeleteDialog
- title={t('knowledgeCompilation.skillDeleteAllTitle')}
- content={{
- title: t('knowledgeCompilation.skillDeleteAllDescription'),
- }}
- onOk={handleDeleteAll}
- >
- <Button
- variant="ghost"
- size="icon-sm"
- disabled={deleteTreeLoading}
- data-testid="skills-clear-trigger"
- >
- <Trash2 />
- </Button>
- </ConfirmDeleteDialog>
- )}
</section>
<div className="px-3 py-2">
diff --git a/web/src/pages/dataset/compilation/update-button.tsx b/web/src/pages/dataset/compilation/update-button.tsx
deleted file mode 100644
index d89f67b4af..0000000000
--- a/web/src/pages/dataset/compilation/update-button.tsx
+++ /dev/null
@@ -1,103 +0,0 @@
-import { WandSparkles } from 'lucide-react';
-import { useTranslation } from 'react-i18next';
-
-import { Badge } from '@/components/ui/badge';
-import { Button } from '@/components/ui/button';
-import {
- Tooltip,
- TooltipContent,
- TooltipProvider,
- TooltipTrigger,
-} from '@/components/ui/tooltip';
-import { GenerateStatus, GenerateType } from '@/constants/knowledge';
-import { ITraceInfo, useGenerateStatus } from '@/hooks/use-dataset-generate';
-import { useIsGoBackend } from '@/utils/backend-variant';
-
-import { UpdateRunProgress } from './update-run-progress';
-
-type CompilationUpdateButtonProps = {
- traceData?: ITraceInfo;
- generateType: GenerateType;
- hasChanges: boolean;
- newlyUploaded: number;
- removed: number;
- changed?: number;
- retryPageCount?: number;
- loading: boolean;
- tooltip: string;
- onClick: () => void;
-};
-
-export function CompilationUpdateButton({
- traceData,
- generateType,
- hasChanges,
- newlyUploaded,
- removed,
- changed = 0,
- retryPageCount = 0,
- loading,
- tooltip,
- onClick,
-}: CompilationUpdateButtonProps) {
- const { t } = useTranslation();
- const isGo = useIsGoBackend();
- const { status } = useGenerateStatus(traceData);
- const isRunning = status === GenerateStatus.Running;
- const isFailed = status === GenerateStatus.Failed;
- const isGenerating = isRunning || isFailed;
-
- // A failed trace persists (progress stays < 0) until the next run, so on
- // Python it must not keep the button visible on its own — only real changes
- // or a live run should. On Go a failed batch is surfaced until retry drains
- // it, so failure keeps the button visible there.
- if (!hasChanges && !isRunning && !(isGo && isFailed)) {
- return null;
- }
-
- return (
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button variant={'outline'} onClick={onClick} disabled={loading}>
- {isGenerating ? (
- <UpdateRunProgress data={traceData} generateType={generateType} />
- ) : (
- <>
- {t('knowledgeCompilation.update', { defaultValue: 'Update' })}
- {newlyUploaded > 0 && (
- <Badge variant="success" className="ml-1">
- {newlyUploaded}
- </Badge>
- )}
- {removed > 0 && (
- <Badge variant="destructive" className="ml-1">
- {removed}
- </Badge>
- )}
- {changed > 0 && (
- <Badge variant="secondary" className="ml-1">
- {changed}
- </Badge>
- )}
- {retryPageCount > 0 && (
- <Badge variant="destructive" className="ml-1">
- {retryPageCount}
- </Badge>
- )}
- <WandSparkles />
- </>
- )}
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- {isGenerating
- ? t('knowledgeCompilation.viewUpdateLogs', {
- defaultValue: 'View update logs',
- })
- : tooltip}
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- );
-}
diff --git a/web/src/pages/dataset/compilation/update-run-progress.tsx b/web/src/pages/dataset/compilation/update-run-progress.tsx
deleted file mode 100644
index 62752ec075..0000000000
--- a/web/src/pages/dataset/compilation/update-run-progress.tsx
+++ /dev/null
@@ -1,101 +0,0 @@
-import { CircleX } from 'lucide-react';
-import { useCallback, type MouseEvent } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { IconFontFill } from '@/components/icon-font';
-import { GenerateType } from '@/constants/knowledge';
-import {
- ITraceInfo,
- useDatasetGenerate,
- useGenerateStatus,
-} from '@/hooks/use-dataset-generate';
-import { useIsGoBackend } from '@/utils/backend-variant';
-import { cn } from '@/lib/utils';
-import { toFixed } from '@/utils/common-util';
-
-type UpdateRunProgressProps = {
- data?: ITraceInfo;
- generateType: GenerateType;
-};
-
-export function UpdateRunProgress({
- data,
- generateType,
-}: UpdateRunProgressProps) {
- const { t } = useTranslation();
- const { pauseGenerate } = useDatasetGenerate();
- const { status, percent } = useGenerateStatus(data);
- const isGo = useIsGoBackend();
-
- const handlePause = useCallback(
- (e: MouseEvent) => {
- e.stopPropagation();
- if (data?.id) {
- pauseGenerate({ task_id: data.id, type: generateType }).catch(() => {});
- }
- },
- [pauseGenerate, data?.id, generateType],
- );
-
- // Go: no scheduler task-level cancel, and no stable terminal state, so
- // show the MySQL inflight/backlog entry counts instead of a percentage and no
- // pause button. Error diagnostic takes priority (see plan v4.1 §4.2).
- if (isGo && status === 'running') {
- return (
- <span className="flex items-center gap-2 text-sm text-text-secondary">
- <span className="size-2 rounded-full bg-accent-primary" />
- {data?.compilationError
- ? data.compilationError
- : data?.currentPhase ||
- t('knowledgeCompilation.compiling', {
- defaultValue: 'Compiling…',
- })}
- {!data?.compilationError && (
- <span>
- {t('knowledgeCompilation.compilingCounts', {
- inflight: data?.inflight ?? 0,
- backlog: data?.backlog ?? 0,
- defaultValue: '{{inflight}} processing / {{backlog}} queued',
- })}
- </span>
- )}
- </span>
- );
- }
- if (isGo && status === 'failed') {
- return (
- <span className="flex items-center gap-2 text-sm text-state-error">
- <IconFontFill name="reparse" className="text-accent-primary" />
- {data?.compilationError || t('message.operated')}
- </span>
- );
- }
-
- return (
- <span className="flex items-center gap-2">
- <span className="bg-border-button h-1 w-16 rounded-full">
- <span
- className={cn('block h-1 rounded-full', {
- 'bg-state-error': status === 'failed',
- 'bg-accent-primary': status === 'running',
- })}
- style={{ width: `${toFixed(percent)}%` }}
- />
- </span>
- {status === 'running' && (
- <>
- <span>{(toFixed(percent) as string) + '%'}</span>
- <span
- className="text-state-error cursor-pointer"
- onClick={handlePause}
- >
- <CircleX className="size-4" />
- </span>
- </>
- )}
- {status === 'failed' && (
- <IconFontFill name="reparse" className="text-accent-primary" />
- )}
- </span>
- );
-}
diff --git a/web/src/pages/dataset/compilation/utils/nav-tree.ts b/web/src/pages/dataset/compilation/utils/nav-tree.ts
index 80e11317e9..0d310a6643 100644
--- a/web/src/pages/dataset/compilation/utils/nav-tree.ts
+++ b/web/src/pages/dataset/compilation/utils/nav-tree.ts
@@ -11,12 +11,6 @@ import {
IStructureGraphTemplate,
} from '@/interfaces/database/document-structure';
import trim from 'lodash/trim';
-import { ReactNode } from 'react';
-
-export type NavTreeActionsFactory = (
- node: DatasetNavNode,
- parentName: string | null,
-) => ReactNode;
export type NavEntityClickHandler = (
docNode: DatasetNavNode,
@@ -34,7 +28,6 @@ type BuildNavTreeDataOptions = {
* so branches come from the payload instead of a lazy /children request.
*/
searchMode?: boolean;
- getActions?: NavTreeActionsFactory;
onNodeClick: (node: DatasetNavNode, parentName: string | null) => void;
onNodeExpand: (node: DatasetNavNode) => void;
onEntityClick?: NavEntityClickHandler;
@@ -215,14 +208,13 @@ function buildNavSearchTreeData(
parentName: string | null,
idPrefix: string,
): TreeDataItem[] {
- const { getActions, onNodeClick, onNodeExpand } = options;
+ const { onNodeClick, onNodeExpand } = options;
return nodes.map((node) => {
const identity = navNodeIdentity(node);
const id = idPrefix ? `${idPrefix}/${identity}` : identity;
const item: TreeDataItem = {
id,
name: trim(node.name),
- actions: getActions?.(node, parentName),
onClick: () => onNodeClick(node, parentName),
};
@@ -267,7 +259,6 @@ export function buildNavTreeData(
const {
childrenMap,
childrenErrorParents,
- getActions,
onNodeClick,
onNodeExpand,
loadingPlaceholder,
@@ -279,7 +270,6 @@ export function buildNavTreeData(
const item: TreeDataItem = {
id,
name: trim(node.name),
- actions: getActions?.(node, parentName),
onClick: () => onNodeClick(node, parentName),
onExpand: () => onNodeExpand(node),
};
diff --git a/web/src/pages/dataset/compilation/utils/skill-tree.ts b/web/src/pages/dataset/compilation/utils/skill-tree.ts
index a5751b96f2..01011f2b28 100644
--- a/web/src/pages/dataset/compilation/utils/skill-tree.ts
+++ b/web/src/pages/dataset/compilation/utils/skill-tree.ts
@@ -1,24 +1,19 @@
import type { TreeDataItem } from '@/components/ui/tree-view';
import type { DatasetSkillTreeNode } from '@/interfaces/database/dataset-skill';
-import type { ReactNode } from 'react';
-
-export type SkillTreeActionsFactory = (skillKwd: string) => ReactNode;
export function buildSkillTreeData(
nodes: DatasetSkillTreeNode[] = [],
- getActions?: SkillTreeActionsFactory,
): TreeDataItem[] {
return nodes.map((node) => {
const item: TreeDataItem = {
id: node.skill_kwd,
name: node.skill_kwd,
- actions: getActions?.(node.skill_kwd),
};
// Only set children when non-empty: TreeView branches on
// `item.children ? TreeNode : TreeLeaf` and [] is truthy, so an empty
// array would render a leaf as a branch with a chevron and no children.
if (node.children_kwd?.length) {
- item.children = buildSkillTreeData(node.children_kwd, getActions);
+ item.children = buildSkillTreeData(node.children_kwd);
}
return item;
});
diff --git a/web/src/pages/dataset/compilation/wiki-left-panel/hooks/use-wiki-clear.ts b/web/src/pages/dataset/compilation/wiki-left-panel/hooks/use-wiki-clear.ts
deleted file mode 100644
index 171ca27832..0000000000
--- a/web/src/pages/dataset/compilation/wiki-left-panel/hooks/use-wiki-clear.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { useClearWiki } from '@/hooks/use-knowledge-request';
-import { useCallback, useState } from 'react';
-
-type UseWikiClearOptions = {
- onClearWiki?: () => void;
-};
-
-export function useWikiClear({ onClearWiki }: UseWikiClearOptions = {}) {
- const { clearWiki, loading } = useClearWiki();
- const [open, setOpen] = useState(false);
-
- const handleConfirm = useCallback(async () => {
- setOpen(false);
- const data = await clearWiki();
- if (data?.code === 0) {
- onClearWiki?.();
- }
- }, [clearWiki, onClearWiki]);
-
- return { open, setOpen, handleConfirm, loading };
-}
diff --git a/web/src/pages/dataset/compilation/wiki-left-panel/hooks/use-wiki-update.ts b/web/src/pages/dataset/compilation/wiki-left-panel/hooks/use-wiki-update.ts
deleted file mode 100644
index 64bf000516..0000000000
--- a/web/src/pages/dataset/compilation/wiki-left-panel/hooks/use-wiki-update.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-import { useCallback } from 'react';
-import {
- useFetchArtifactAlteration,
- useRunArtifactIndex,
-} from '@/hooks/use-knowledge-request';
-
-type UseWikiUpdateOptions = {
- onUpdate?: () => void;
-};
-
-export function useWikiUpdate({ onUpdate }: UseWikiUpdateOptions = {}) {
- const { data, loading: queryLoading } = useFetchArtifactAlteration('wiki');
- const { runArtifactIndex, loading: mutationLoading } =
- useRunArtifactIndex('wiki');
-
- const newlyUploaded = data?.newly_uploaded ?? 0;
- const removed = data?.removed ?? 0;
- const changed = data?.changed ?? 0;
- const retryPageCount = data?.retry_page_count ?? 0;
- const hasChanges =
- newlyUploaded > 0 || removed > 0 || changed > 0 || retryPageCount > 0;
-
- const handleUpdate = useCallback(async () => {
- const result = await runArtifactIndex();
- if (result?.code === 0) {
- onUpdate?.();
- }
- }, [runArtifactIndex, onUpdate]);
-
- return {
- hasChanges,
- newlyUploaded,
- removed,
- changed,
- retryPageCount,
- handleUpdate,
- loading: queryLoading || mutationLoading,
- };
-}
diff --git a/web/src/pages/dataset/compilation/wiki-left-panel/index.tsx b/web/src/pages/dataset/compilation/wiki-left-panel/index.tsx
index b7e369bb96..1e7927e075 100644
--- a/web/src/pages/dataset/compilation/wiki-left-panel/index.tsx
+++ b/web/src/pages/dataset/compilation/wiki-left-panel/index.tsx
@@ -1,19 +1,8 @@
-import { ConfirmDeleteDialog } from '@/components/confirm-delete-dialog';
-import { Button } from '@/components/ui/button';
import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
-import { GenerateStatus, GenerateType } from '@/constants/knowledge';
-import { ITraceInfo, useGenerateStatus } from '@/hooks/use-dataset-generate';
import { IArtifact } from '@/interfaces/database/dataset';
-import { useIsGoBackend } from '@/utils/backend-variant';
-import { Trash2 } from 'lucide-react';
-import { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { LeftPanelTab } from '../constants';
-import { CompilationUpdateButton } from '../update-button';
-import { UpdateLogSheet } from '../update-log-sheet';
-import { useWikiClear } from './hooks/use-wiki-clear';
-import { useWikiUpdate } from './hooks/use-wiki-update';
import { WikiGraphPanel } from './wiki-graph-panel';
import { WikiNavBar } from './wiki-nav-bar';
@@ -23,10 +12,6 @@ type WikiLeftPanelProps = {
selectedArtifact: IArtifact | null;
onSelectArtifact: (artifact: IArtifact) => void;
onClearArtifact: () => void;
- onClearWiki?: () => void;
- updateSheetOpen: boolean;
- onUpdateSheetOpenChange: (open: boolean) => void;
- traceData?: ITraceInfo;
};
export function WikiLeftPanel({
@@ -35,79 +20,11 @@ export function WikiLeftPanel({
selectedArtifact,
onSelectArtifact,
onClearArtifact,
- onClearWiki,
- updateSheetOpen,
- onUpdateSheetOpenChange,
- traceData,
}: WikiLeftPanelProps) {
const { t } = useTranslation();
- const isGo = useIsGoBackend();
-
- const { open, setOpen, handleConfirm, loading } = useWikiClear({
- onClearWiki,
- });
-
- const {
- hasChanges,
- newlyUploaded,
- removed,
- changed,
- retryPageCount,
- handleUpdate,
- loading: updateLoading,
- } = useWikiUpdate();
-
- const { status } = useGenerateStatus(traceData);
-
- const handleUpdateClick = useCallback(async () => {
- onUpdateSheetOpenChange(true);
- if (status === GenerateStatus.Running) {
- return;
- }
- await handleUpdate();
- }, [status, handleUpdate, onUpdateSheetOpenChange]);
return (
<aside className="size-full flex flex-col p-5">
- {!isGo && (
- <div className="flex items-center justify-between pb-5">
- <CompilationUpdateButton
- traceData={traceData}
- generateType={GenerateType.Artifact}
- hasChanges={hasChanges}
- newlyUploaded={newlyUploaded}
- removed={removed}
- changed={changed}
- retryPageCount={retryPageCount}
- loading={updateLoading}
- tooltip={t('knowledgeCompilation.updateTooltip', {
- newlyUploaded,
- removed,
- changed,
- defaultValue:
- '{{newlyUploaded}} new, {{removed}} removed, {{changed}} changed documents found. Click to compile and merge into current Wiki.',
- })}
- onClick={handleUpdateClick}
- />
- <ConfirmDeleteDialog
- open={open}
- onOpenChange={setOpen}
- title={t('knowledgeCompilation.clearWikiTitle')}
- content={{ title: t('knowledgeCompilation.clearWikiDescription') }}
- onOk={handleConfirm}
- >
- <Button
- variant="ghost"
- size="icon-sm"
- className="ml-auto"
- disabled={loading}
- data-testid="wiki-clear-trigger"
- >
- <Trash2 className="size-[1em]" />
- </Button>
- </ConfirmDeleteDialog>
- </div>
- )}
<Tabs value={tab} onValueChange={onTabChange} className="pb-5">
<TabsList className="grid grid-cols-2 w-80">
<TabsTrigger value={LeftPanelTab.Contents}>
@@ -134,15 +51,6 @@ export function WikiLeftPanel({
/>
)}
</div>
-
- <UpdateLogSheet
- open={updateSheetOpen}
- onOpenChange={onUpdateSheetOpenChange}
- data={traceData}
- title={t('knowledgeCompilation.updateSheetTitle', {
- defaultValue: 'Update Wiki',
- })}
- />
</aside>
);
}
diff --git a/web/src/pages/dataset/dataset-overview/overview-table.tsx b/web/src/pages/dataset/dataset-overview/overview-table.tsx
index a37aaad230..0f84d25285 100644
--- a/web/src/pages/dataset/dataset-overview/overview-table.tsx
+++ b/web/src/pages/dataset/dataset-overview/overview-table.tsx
@@ -23,7 +23,6 @@ import { useTranslate } from '@/hooks/common-hooks';
import { cn } from '@/lib/utils';
import { useDataSourceInfo } from '@/pages/user-setting/data-source/constant';
import { useGetKnowledgeSearchParams } from '@/hooks/route-hook';
-import { useIsGoBackend } from '@/utils/backend-variant';
import { IDataSourceInfoMap } from '@/pages/user-setting/data-source/interface';
import { formatDate, formatSecondsToHumanReadable } from '@/utils/date';
import {
@@ -347,7 +346,6 @@ const FileLogsTable: FC<FileLogsTableProps> = ({
const { id: routeId } = useParams();
const { knowledgeId } = useGetKnowledgeSearchParams();
const datasetId = knowledgeId || routeId;
- const isGoBackend = useIsGoBackend();
const {
data: messages,
fetchPreviousPage,
@@ -375,9 +373,6 @@ const FileLogsTable: FC<FileLogsTableProps> = ({
if (!logInfo) {
return undefined;
}
- if (!isGoBackend) {
- return logInfo;
- }
return {
...logInfo,
// Keep the seeded progress_msg visible until events arrive: blanking
@@ -394,7 +389,6 @@ const FileLogsTable: FC<FileLogsTableProps> = ({
isLoadingPreviousEvents: isFetchingPreviousPage,
};
}, [
- isGoBackend,
logInfo,
messages,
fetchPreviousPage,
diff --git a/web/src/pages/dataset/dataset/change-parser-dialog.tsx b/web/src/pages/dataset/dataset/change-parser-dialog.tsx
index 3262498ad6..ac056d8dff 100644
--- a/web/src/pages/dataset/dataset/change-parser-dialog.tsx
+++ b/web/src/pages/dataset/dataset/change-parser-dialog.tsx
@@ -1,53 +1,29 @@
-import { ChunkMethodDialog } from '@/components/chunk-method-dialog';
import { DocumentPipelineDialog } from '@/components/document-pipeline-dialog';
import { IDocumentInfo } from '@/interfaces/database/document';
import { IChangeParserRequestBody } from '@/interfaces/request/document';
-import { BackendVariant } from '@/utils/backend-variant';
-import { getExtension } from '@/utils/document-util';
type ChangeParserDialogProps = {
record: IDocumentInfo;
- visible: boolean;
onOk: (values: IChangeParserRequestBody) => Promise<void>;
hideModal: () => void;
loading: boolean;
};
-// Dispatch point for the document parser-change dialog: the Go backend edits
-// the pipeline-shaped parser config, while the Python backend uses the legacy
-// chunk-method dialog.
+// The document parser-change dialog edits the pipeline-shaped parser config.
export function ChangeParserDialog({
record,
- visible,
onOk,
hideModal,
loading,
}: ChangeParserDialogProps) {
return (
- <BackendVariant
- go={
- <DocumentPipelineDialog
- parserId={record.chunk_method}
- pipelineId={record.pipeline_id}
- parserConfig={record.parser_config}
- onOk={onOk}
- hideModal={hideModal}
- loading={loading}
- ></DocumentPipelineDialog>
- }
- python={
- <ChunkMethodDialog
- documentId={record.id}
- parserId={record.chunk_method}
- pipelineId={record.pipeline_id}
- parserConfig={record.parser_config}
- documentExtension={getExtension(record.name)}
- onOk={onOk}
- visible={visible}
- hideModal={hideModal}
- loading={loading}
- ></ChunkMethodDialog>
- }
- />
+ <DocumentPipelineDialog
+ parserId={record.chunk_method}
+ pipelineId={record.pipeline_id}
+ parserConfig={record.parser_config}
+ onOk={onOk}
+ hideModal={hideModal}
+ loading={loading}
+ ></DocumentPipelineDialog>
);
}
diff --git a/web/src/pages/dataset/dataset/hooks.test.ts b/web/src/pages/dataset/dataset/hooks.test.ts
index dad2bf5e68..ffa1153aea 100644
--- a/web/src/pages/dataset/dataset/hooks.test.ts
+++ b/web/src/pages/dataset/dataset/hooks.test.ts
@@ -10,16 +10,10 @@ import { IngestionTaskStatus, RunningStatus } from '@/constants/knowledge';
type Doc = {
id: string;
name: string;
- run: string;
- progress_msg: string;
ingestion_status?: string;
[key: string]: unknown;
};
-// The hook branches on the backend variant; drive it from a mutable flag so a
-// single suite can exercise both the Python and the Go path.
-let mockIsGo = false;
-
jest.mock('react-router', () => ({
useParams: jest.fn(() => ({ id: 'kb-1' })),
}));
@@ -28,12 +22,6 @@ jest.mock('@/hooks/route-hook', () => ({
useGetKnowledgeSearchParams: jest.fn(() => ({ knowledgeId: 'kb-1' })),
}));
-jest.mock('@/utils/backend-variant', () => ({
- useIsGoBackend: () => mockIsGo,
- pickByBackend: (variants: { go: unknown; python: unknown }) =>
- mockIsGo ? variants.go : variants.python,
-}));
-
jest.mock('@/hooks/use-document-request', () => ({
useFetchDocumentsByIds: () => ({ documents: [] }),
}));
@@ -53,13 +41,7 @@ const mockList = jest.mocked(listDataPipelineLogDocument);
const mockMessages = jest.mocked(listIngestionMessages);
function makeDoc(overrides: Partial<Doc> = {}): Doc {
- return {
- id: 'doc-1',
- name: 'a.pdf',
- run: RunningStatus.UNSTART,
- progress_msg: '',
- ...overrides,
- };
+ return { id: 'doc-1', name: 'a.pdf', ...overrides };
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -78,49 +60,10 @@ function renderLogs(documents: Doc[]): any {
beforeEach(() => {
jest.clearAllMocks();
- mockIsGo = false;
});
-describe('useShowLog — Python backend is unaffected by the early-log fallback', () => {
- it('never queries pipeline logs and passes document.progress_msg through', () => {
- mockIsGo = false;
- const doc = makeDoc({
- run: RunningStatus.RUNNING,
- progress_msg: 'Parsing chunks',
- });
-
- const { result } = renderLogs([doc]);
- act(() => result.current.showLog(doc));
-
- expect(result.current.logInfo.details).toBe('Parsing chunks');
- expect(result.current.logInfo.status).toBe(RunningStatus.RUNNING);
- expect(mockList).not.toHaveBeenCalled();
- });
-
- it('uses a placeholder for an empty progress message', () => {
- mockIsGo = false;
- const doc = makeDoc({ run: RunningStatus.UNSTART, progress_msg: '' });
-
- const { result } = renderLogs([doc]);
- act(() => result.current.showLog(doc));
-
- expect(result.current.logInfo.details).toBe('-');
- expect(mockList).not.toHaveBeenCalled();
- });
-
- it('keeps the legacy "-" placeholder when there is no source document', () => {
- mockIsGo = false;
-
- const { result } = renderLogs([]);
-
- expect(result.current.logInfo.details).toBe('-');
- expect(mockList).not.toHaveBeenCalled();
- });
-});
-
-describe('useShowLog — Go backend early-log fallback', () => {
+describe('useShowLog early-log fallback', () => {
it('performs one finishing poll after terminal before stopping', async () => {
- mockIsGo = true;
jest.useFakeTimers();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
mockList.mockResolvedValue({
@@ -162,7 +105,6 @@ describe('useShowLog — Go backend early-log fallback', () => {
});
it('exposes a previous-page loader for historical event scrolling', async () => {
- mockIsGo = true;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
mockList.mockResolvedValue({
data: {
@@ -209,7 +151,6 @@ describe('useShowLog — Go backend early-log fallback', () => {
});
it('loads messages by the exact pipeline log identity', async () => {
- mockIsGo = true;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
mockList.mockResolvedValue({
data: {
@@ -264,17 +205,16 @@ describe('useShowLog — Go backend early-log fallback', () => {
});
});
- it('shows the Python pipeline log progress field on Go', async () => {
- mockIsGo = true;
+ it('uses the current run progress field', async () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
mockList.mockResolvedValue({
data: {
data: {
logs: [
{
- id: 'python-run',
+ id: 'run-1',
document_id: 'doc-1',
- progress_msg: 'Python parse completed',
+ progress_msg: 'Parse completed',
},
],
total: 1,
@@ -299,11 +239,11 @@ describe('useShowLog — Go backend early-log fallback', () => {
act(() => result.current.showLog(doc));
await waitFor(() =>
- expect(mockMessages).toHaveBeenCalledWith('kb-1', 'python-run', {
+ expect(mockMessages).toHaveBeenCalledWith('kb-1', 'run-1', {
limit: 200,
}),
);
- expect(result.current.logInfo.details).toBe('Python parse completed');
+ expect(result.current.logInfo.details).toBe('Parse completed');
expect(result.current.logInfo.events).toBeUndefined();
expect(result.current.logInfo.status).toBe(RunningStatus.DONE);
expect(mockList).toHaveBeenCalledWith(
@@ -313,7 +253,6 @@ describe('useShowLog — Go backend early-log fallback', () => {
});
it('prefers the selected log event over its stored progress message', async () => {
- mockIsGo = true;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
mockList.mockResolvedValue({
data: {
@@ -360,7 +299,6 @@ describe('useShowLog — Go backend early-log fallback', () => {
});
it('scopes the query to the document instead of a fuzzy name search', async () => {
- mockIsGo = true;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
mockList.mockResolvedValue({
data: { data: { logs: [], total: 0 } },
@@ -386,11 +324,8 @@ describe('useShowLog — Go backend early-log fallback', () => {
});
it('uses the current log identity even when the document is running', async () => {
- mockIsGo = true;
const doc = makeDoc({
ingestion_status: IngestionTaskStatus.RUNNING,
- run: RunningStatus.RUNNING,
- progress_msg: 'Indexing done',
});
const { result } = renderLogs([doc]);
diff --git a/web/src/pages/dataset/dataset/hooks.ts b/web/src/pages/dataset/dataset/hooks.ts
index e5f28dd0c4..c115696966 100644
--- a/web/src/pages/dataset/dataset/hooks.ts
+++ b/web/src/pages/dataset/dataset/hooks.ts
@@ -2,7 +2,6 @@ import { useSetModalState } from '@/hooks/common-hooks';
import { useFetchDocumentsByIds } from '@/hooks/use-document-request';
import { IDocumentInfo } from '@/interfaces/database/document';
import { useGetKnowledgeSearchParams } from '@/hooks/route-hook';
-import { useIsGoBackend } from '@/utils/backend-variant';
import { formatDate, formatSecondsToHumanReadable } from '@/utils/date';
import { formatBytes } from '@/utils/file-util';
import { useQuery } from '@tanstack/react-query';
@@ -28,7 +27,6 @@ export const useShowLog = (documents: IDocumentInfo[]) => {
const { id: routeId } = useParams();
const { knowledgeId } = useGetKnowledgeSearchParams();
const datasetId = knowledgeId || routeId;
- const isGoBackend = useIsGoBackend();
const isTerminal = (doc?: IDocumentInfo) => {
const status = doc && getDocumentRunningStatus(doc);
@@ -67,7 +65,7 @@ export const useShowLog = (documents: IDocumentInfo[]) => {
// reads to the intended run.
const { data: documentLog } = useQuery<IFileLogList>({
queryKey: DocumentLogKeys.queued(datasetId, sourceDoc?.id),
- enabled: visible && isGoBackend && !!datasetId && !!sourceDoc?.id,
+ enabled: visible && !!datasetId && !!sourceDoc?.id,
refetchInterval: isTerminal(sourceDoc) ? false : PollIntervalMs,
queryFn: async () => {
const { data: res = {} } = await listDataPipelineLogDocument(
@@ -128,8 +126,6 @@ export const useShowLog = (documents: IDocumentInfo[]) => {
processBeginAt: formatDate(source.process_begin_at),
chunkNumber: source.chunk_count,
duration: formatSecondsToHumanReadable(source.process_duration || 0),
- // Go derives status from ingestion_status (queued included);
- // Python reads the legacy run field.
status: getDocumentRunningStatus(source),
details,
events: messages?.items.length ? messages.items : undefined,
diff --git a/web/src/pages/dataset/dataset/index.tsx b/web/src/pages/dataset/dataset/index.tsx
index 05ec190fc8..11ec8525a0 100644
--- a/web/src/pages/dataset/dataset/index.tsx
+++ b/web/src/pages/dataset/dataset/index.tsx
@@ -29,7 +29,6 @@ import { useManageMetadata } from '../components/metedata/hooks/use-manage-modal
import { ManageMetadataModal } from '../components/metedata/manage-modal';
import { useKnowledgeBaseContext } from '../contexts/knowledge-base-context';
import { DatasetTable } from './dataset-table';
-import { ReparseDialog } from './reparse-dialog';
import { useBulkOperateDataset } from './use-bulk-operate-dataset';
import { useCreateEmptyDocument } from './use-create-empty-document';
import { useSelectDatasetFilters } from './use-select-filters';
@@ -91,17 +90,12 @@ export default function Dataset() {
useClearSelectionOnPageChange(pagination, clearRowSelection);
- const {
- chunkNum,
- list,
- visible: reparseDialogVisible,
- hideModal: hideReparseDialogModal,
- handleRunClick: handleOperationIconClick,
- } = useBulkOperateDataset({
- documents,
- rowSelection,
- setRowSelection,
- });
+ const { list, handleRunClick: handleOperationIconClick } =
+ useBulkOperateDataset({
+ documents,
+ rowSelection,
+ setRowSelection,
+ });
const { selectedIds: selectedRowKeys } = useSelectedIds(
rowSelection,
@@ -258,15 +252,6 @@ export default function Dataset() {
otherData={metadataConfig.record}
/>
)}
- {reparseDialogVisible && (
- <ReparseDialog
- enable_metadata={knowledgeBase?.parser_config?.enable_metadata}
- handleOperationIconClick={handleOperationIconClick}
- chunk_num={chunkNum}
- visible={reparseDialogVisible}
- hideModal={hideReparseDialogModal}
- ></ReparseDialog>
- )}
</CardContent>
</Card>
);
diff --git a/web/src/pages/dataset/dataset/parsing-status-cell.test.tsx b/web/src/pages/dataset/dataset/parsing-status-cell.test.tsx
index 3ce13361ed..511ead3ae5 100644
--- a/web/src/pages/dataset/dataset/parsing-status-cell.test.tsx
+++ b/web/src/pages/dataset/dataset/parsing-status-cell.test.tsx
@@ -21,16 +21,7 @@ jest.mock('./use-run-document', () => ({
}),
}));
-// Drive both the useIsGoBackend hook and the pickByBackend payload/status
-// adapters from a single mutable flag.
-let mockIsGoBackend = false;
-jest.mock('@/utils/backend-variant', () => ({
- useIsGoBackend: () => mockIsGoBackend,
- pickByBackend: ({ go, python }: { go: unknown; python: unknown }) =>
- mockIsGoBackend ? go : python,
-}));
-
-import { IngestionTaskStatus, RunningStatus } from './constant';
+import { IngestionTaskStatus } from './constant';
import { ParsingStatusCell } from './parsing-status-cell';
const baseRecord = {
@@ -38,7 +29,6 @@ const baseRecord = {
dataset_id: 'dataset-1',
name: 'doc.pdf',
type: 'document',
- run: RunningStatus.UNSTART,
progress: 0,
chunk_count: 0,
parser_config: {},
@@ -95,169 +85,90 @@ describe('ParsingStatusCell', () => {
mockShowReparseDialog.mockClear();
});
- afterEach(() => {
- mockIsGoBackend = false;
+ it('shows the queued chip for CREATED tasks', () => {
+ const { container } = renderCell({
+ ingestion_status: IngestionTaskStatus.CREATED,
+ });
+ expect(getSection(container)).toHaveAttribute('data-state', 'queued');
+ expect(
+ screen.getByText('knowledgeDetails.runningStatusQueued'),
+ ).toBeInTheDocument();
});
- it('shows a cancel icon while the legacy run state is RUNNING on Python', () => {
- const { container } = renderCell({ run: RunningStatus.RUNNING });
-
+ it('shows progress and an enabled cancel button while RUNNING', () => {
+ const { container } = renderCell({
+ ingestion_status: IngestionTaskStatus.RUNNING,
+ });
+ expect(getSection(container)).toHaveAttribute('data-state', 'running');
expect(container.querySelector('svg.lucide-circle-x')).toBeInTheDocument();
- expect(hasIconFont(container, 'play')).toBe(false);
- // Python never reports STOPPING, so the loading mask must not render.
+ expect(container.querySelector('button[disabled]')).not.toBeInTheDocument();
+ });
+
+ it('masks the progress area with a loading overlay while STOPPING', () => {
+ const { container } = renderCell({
+ ingestion_status: IngestionTaskStatus.STOPPING,
+ });
+ expect(getSection(container)).toHaveAttribute('data-state', 'stopping');
+
+ // The underlying running row stays visible but reads as disabled:
+ // dimmed, flagged as stopping and non-interactive.
+ const row = screen.getByTestId('document-processing-row');
+ expect(row).toHaveAttribute('data-stopping');
+ expect(row).toHaveClass('opacity-50');
+ expect(row).toHaveClass('pointer-events-none');
+
+ // The overlay communicates the in-flight cancel with a plain
+ // spinner (no status text) and blocks the actions beneath.
+ const overlay = screen.getByTestId('document-stopping-overlay');
+ expect(overlay).toBeInTheDocument();
expect(
- screen.queryByTestId('document-stopping-overlay'),
+ screen.queryByText('knowledgeDetails.runningStatusStopping'),
).not.toBeInTheDocument();
- expect(getSection(container)).toHaveAttribute('data-state', 'running');
- });
+ expect(overlay.querySelector('.animate-spin')).toBeInTheDocument();
- it('shows the play action for an idle Python document', () => {
- const { container } = renderCell({ run: RunningStatus.UNSTART });
+ // Both the progress/log button and the cancel button are disabled.
+ const buttons = container.querySelectorAll('button');
+ buttons.forEach((button) => expect(button).toBeDisabled());
+ });
- expect(getSection(container)).toHaveAttribute('data-state', 'unstart');
- expect(hasIconFont(container, 'play')).toBe(true);
+ it('renders the success state for COMPLETED', () => {
+ const { container } = renderCell({
+ ingestion_status: IngestionTaskStatus.COMPLETED,
+ });
+ expect(getSection(container)).toHaveAttribute('data-state', 'success');
expect(
container.querySelector('svg.lucide-circle-x'),
).not.toBeInTheDocument();
});
- describe('Go backend', () => {
- beforeEach(() => {
- mockIsGoBackend = true;
- });
-
- it('shows the queued chip for CREATED tasks', () => {
- const { container } = renderCell({
- run: undefined,
- ingestion_status: IngestionTaskStatus.CREATED,
- });
- expect(getSection(container)).toHaveAttribute('data-state', 'queued');
- expect(
- screen.getByText('knowledgeDetails.runningStatusQueued'),
- ).toBeInTheDocument();
- });
-
- it('shows progress and an enabled cancel button while RUNNING', () => {
- const { container } = renderCell({
- run: undefined,
- ingestion_status: IngestionTaskStatus.RUNNING,
- });
- expect(getSection(container)).toHaveAttribute('data-state', 'running');
- expect(
- container.querySelector('svg.lucide-circle-x'),
- ).toBeInTheDocument();
- expect(
- container.querySelector('button[disabled]'),
- ).not.toBeInTheDocument();
- });
-
- it('masks the progress area with a loading overlay while STOPPING', () => {
- const { container } = renderCell({
- run: undefined,
- ingestion_status: IngestionTaskStatus.STOPPING,
- });
- expect(getSection(container)).toHaveAttribute('data-state', 'stopping');
-
- // The underlying running row stays visible but reads as disabled:
- // dimmed, flagged as stopping and non-interactive.
- const row = screen.getByTestId('document-processing-row');
- expect(row).toHaveAttribute('data-stopping');
- expect(row).toHaveClass('opacity-50');
- expect(row).toHaveClass('pointer-events-none');
-
- // The overlay communicates the in-flight cancel with a plain
- // spinner (no status text) and blocks the actions beneath.
- const overlay = screen.getByTestId('document-stopping-overlay');
- expect(overlay).toBeInTheDocument();
- expect(
- screen.queryByText('knowledgeDetails.runningStatusStopping'),
- ).not.toBeInTheDocument();
- expect(overlay.querySelector('.animate-spin')).toBeInTheDocument();
-
- // Both the progress/log button and the cancel button are disabled.
- const buttons = container.querySelectorAll('button');
- buttons.forEach((button) => expect(button).toBeDisabled());
+ it('renders the cancel state for STOPPED', () => {
+ const { container } = renderCell({
+ ingestion_status: IngestionTaskStatus.STOPPED,
});
+ expect(getSection(container)).toHaveAttribute('data-state', 'cancel');
+ });
- it('renders the success state and reparse action for COMPLETED', () => {
- const { container } = renderCell({
- run: undefined,
- ingestion_status: IngestionTaskStatus.COMPLETED,
- });
- expect(getSection(container)).toHaveAttribute('data-state', 'success');
- expect(
- container.querySelector('svg.lucide-circle-x'),
- ).not.toBeInTheDocument();
- });
-
- it('renders the cancel state for STOPPED', () => {
- const { container } = renderCell({
- run: undefined,
- ingestion_status: IngestionTaskStatus.STOPPED,
- });
- expect(getSection(container)).toHaveAttribute('data-state', 'cancel');
- });
-
- it('renders the play action for UNSTART without a run field', () => {
- const { container } = renderCell({
- run: undefined,
- ingestion_status: IngestionTaskStatus.UNSTART,
- });
- expect(getSection(container)).toHaveAttribute('data-state', 'unstart');
- expect(hasIconFont(container, 'play')).toBe(true);
- });
-
- it('treats a missing ingestion_status as idle', () => {
- const { container } = renderCell({ run: undefined });
- expect(getSection(container)).toHaveAttribute('data-state', 'unstart');
- expect(
- container.querySelector('svg.lucide-circle-x'),
- ).not.toBeInTheDocument();
- });
-
- it('asks for confirmation before dropping existing chunks', () => {
- renderCell({
- run: undefined,
- ingestion_status: IngestionTaskStatus.COMPLETED,
- chunk_count: 3,
- parser_config: { enable_metadata: true },
- });
-
- fireEvent.click(screen.getByTestId('document-parse-toggle'));
-
- expect(mockShowReparseDialog).toHaveBeenCalledTimes(1);
- expect(mockRunDocumentByIds).not.toHaveBeenCalled();
- });
-
- it('re-parses a chunkless document straight away without confirmation', () => {
- renderCell({
- run: undefined,
- ingestion_status: IngestionTaskStatus.COMPLETED,
- chunk_count: 0,
- parser_config: { enable_metadata: true },
- });
-
- fireEvent.click(screen.getByTestId('document-parse-toggle'));
-
- expect(mockRunDocumentByIds).toHaveBeenCalledTimes(1);
- expect(mockShowReparseDialog).not.toHaveBeenCalled();
+ it('renders the play action for UNSTART', () => {
+ const { container } = renderCell({
+ ingestion_status: IngestionTaskStatus.UNSTART,
});
+ expect(getSection(container)).toHaveAttribute('data-state', 'unstart');
+ expect(hasIconFont(container, 'play')).toBe(true);
});
- it('runs a chunkless document once without opening the confirmation', () => {
- renderCell({ ingestion_status: IngestionTaskStatus.COMPLETED });
-
- fireEvent.click(screen.getByTestId('document-parse-toggle'));
-
- expect(mockRunDocumentByIds).toHaveBeenCalledTimes(1);
- expect(mockShowReparseDialog).not.toHaveBeenCalled();
+ it('treats a missing ingestion_status as idle', () => {
+ const { container } = renderCell();
+ expect(getSection(container)).toHaveAttribute('data-state', 'unstart');
+ expect(
+ container.querySelector('svg.lucide-circle-x'),
+ ).not.toBeInTheDocument();
});
- it('opens the confirmation when existing chunks would be dropped', () => {
+ it('asks for confirmation before dropping existing chunks', () => {
renderCell({
- run: RunningStatus.DONE,
ingestion_status: IngestionTaskStatus.COMPLETED,
chunk_count: 3,
+ parser_config: { enable_metadata: true },
});
fireEvent.click(screen.getByTestId('document-parse-toggle'));
@@ -266,15 +177,16 @@ describe('ParsingStatusCell', () => {
expect(mockRunDocumentByIds).not.toHaveBeenCalled();
});
- it('opens the confirmation for a chunkless document when auto-metadata applies', () => {
+ it('re-parses a chunkless document straight away without confirmation', () => {
renderCell({
ingestion_status: IngestionTaskStatus.COMPLETED,
+ chunk_count: 0,
parser_config: { enable_metadata: true },
});
fireEvent.click(screen.getByTestId('document-parse-toggle'));
- expect(mockShowReparseDialog).toHaveBeenCalledTimes(1);
- expect(mockRunDocumentByIds).not.toHaveBeenCalled();
+ expect(mockRunDocumentByIds).toHaveBeenCalledTimes(1);
+ expect(mockShowReparseDialog).not.toHaveBeenCalled();
});
});
diff --git a/web/src/pages/dataset/dataset/parsing-status-cell.tsx b/web/src/pages/dataset/dataset/parsing-status-cell.tsx
index f8095b8a7b..0663055440 100644
--- a/web/src/pages/dataset/dataset/parsing-status-cell.tsx
+++ b/web/src/pages/dataset/dataset/parsing-status-cell.tsx
@@ -15,7 +15,6 @@ import {
} from '@/components/ui/tooltip';
import { IDocumentInfo } from '@/interfaces/database/document';
import { cn } from '@/lib/utils';
-import { useIsGoBackend } from '@/utils/backend-variant';
import { CircleQuestionMark, CircleX, Clock3, Loader2 } from 'lucide-react';
import { useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -123,7 +122,6 @@ export function ParsingStatusCell({
} & UseChangeDocumentParserShowType) {
const { t } = useTranslation();
const { progress, chunk_count, id } = record;
- // Go reports state via ingestion_status (run is gone); Python keeps run.
// Resolve one effective status for the icon, state attribute and labels.
const effectiveRun = getDocumentRunningStatus(record);
const operationIcon = IconMap[effectiveRun];
@@ -135,7 +133,6 @@ export function ParsingStatusCell({
showModal: showReparseDialogModal,
hideModal: hideReparseDialogModal,
} = useHandleRunDocumentByIds(id, showChangeParserModal);
- const isGo = useIsGoBackend();
const isRunning = isDocumentProcessing(record);
const isQueued = effectiveRun === RunningStatus.QUEUED;
const isStopping = isDocumentStopping(record);
@@ -148,15 +145,10 @@ export function ParsingStatusCell({
handleRunDocumentByIds(record, isRunning, option);
};
- // The confirmation only offers real choices when there are existing chunks to
- // drop or auto-metadata to re-apply. Otherwise, and always when cancelling a
- // run, the action fires straight away. Go always drops existing chunks
- // server-side, so its dialog shows the delete notice locked on and only the
- // auto-metadata choice is Python-only.
- const needsParseConfirm =
- !isRunning &&
- (!isZeroChunk ||
- (!isGo && Boolean(record?.parser_config?.enable_metadata)));
+ // Existing chunks are always dropped server-side on re-ingest, so the
+ // confirmation is only needed when there are existing chunks; otherwise, and
+ // always when cancelling a run, the action fires straight away.
+ const needsParseConfirm = !isRunning && !isZeroChunk;
const handleParseClick = () => {
if (needsParseConfirm) {
@@ -258,7 +250,7 @@ export function ParsingStatusCell({
</div>
)}
</div>
- ) : isGo && isRunLoading ? (
+ ) : isRunLoading ? (
<Button size="auto" variant="static" disabled>
<Loader2 className="size-[1em] animate-spin" />
</Button>
@@ -280,10 +272,8 @@ export function ParsingStatusCell({
)}
{reparseDialogVisible && (
<ReparseDialog
- enable_metadata={record?.parser_config?.enable_metadata}
- forceDelete={isGo}
+ forceDelete
handleOperationIconClick={handleOperationIconClick}
- chunk_num={chunk_count}
visible={reparseDialogVisible}
hideModal={hideReparseDialogModal}
></ReparseDialog>
diff --git a/web/src/pages/dataset/dataset/reparse-dialog.tsx b/web/src/pages/dataset/dataset/reparse-dialog.tsx
index 803cd43634..665136121b 100644
--- a/web/src/pages/dataset/dataset/reparse-dialog.tsx
+++ b/web/src/pages/dataset/dataset/reparse-dialog.tsx
@@ -1,115 +1,40 @@
import { ConfirmDeleteDialog } from '@/components/confirm-delete-dialog';
-import {
- DynamicForm,
- DynamicFormRef,
- FormFieldConfig,
- FormFieldType,
-} from '@/components/dynamic-form';
-import { Checkbox } from '@/components/ui/checkbox';
+import { DynamicForm, DynamicFormRef } from '@/components/dynamic-form';
import { DialogProps } from '@radix-ui/react-dialog';
-import { memo, useCallback, useEffect, useRef, useState } from 'react';
-import { ControllerRenderProps } from 'react-hook-form';
+import { memo, useCallback, useRef } from 'react';
import { useTranslation } from 'react-i18next';
export const ReparseDialog = memo(
({
handleOperationIconClick,
- chunk_num,
- enable_metadata = false,
- forceDelete = false,
visible = true,
hideModal,
}: DialogProps & {
- chunk_num: number;
handleOperationIconClick: (options?: {
delete: boolean;
apply_kb: boolean;
}) => void;
- enable_metadata?: boolean;
- // Go always drops existing chunks on re-ingest, so it only shows a plain
- // confirmation with no checkboxes.
- forceDelete?: boolean;
visible: boolean;
hideModal: () => void;
}) => {
- const [defaultValues, setDefaultValues] = useState<any>(null);
- const [fields, setFields] = useState<FormFieldConfig[]>([]);
const { t } = useTranslation();
- useEffect(() => {
- setDefaultValues({
- delete: forceDelete || chunk_num > 0,
- apply_kb: false,
- });
- const deleteField = {
- name: 'delete',
- label: '',
- type: FormFieldType.Checkbox,
- render: (fieldProps: ControllerRenderProps) => (
- <div className="flex items-center text-text-secondary p-5 border border-border-button rounded-lg">
- <Checkbox
- {...fieldProps}
- checked={fieldProps.value}
- onCheckedChange={(checked: boolean) => {
- fieldProps.onChange(checked);
- }}
- />
- <span className="ml-2">
- {chunk_num > 0
- ? t(`knowledgeDetails.redo`, {
- chunkNum: chunk_num,
- })
- : t('knowledgeDetails.redoAll')}
- </span>
- </div>
- ),
- };
- const applyKBField = {
- name: 'apply_kb',
- label: '',
- type: FormFieldType.Checkbox,
- defaultValue: false,
- render: (fieldProps: ControllerRenderProps) => (
- <div className="flex items-center text-text-secondary p-5 border border-border-button rounded-lg">
- <Checkbox
- {...fieldProps}
- checked={fieldProps.value}
- onCheckedChange={(checked: boolean) => {
- fieldProps.onChange(checked);
- }}
- />
- <span className="ml-2">
- {t('knowledgeDetails.applyAutoMetadataSettings')}
- </span>
- </div>
- ),
- };
- // Go only needs a plain confirm: chunks are always dropped, so no
- // checkboxes are rendered.
- if (forceDelete) {
- setFields([]);
- } else if (chunk_num > 0 && enable_metadata) {
- setFields([deleteField, applyKBField]);
- } else if (chunk_num > 0 && !enable_metadata) {
- setFields([deleteField]);
- } else if (chunk_num <= 0 && enable_metadata) {
- setFields([applyKBField]);
- } else {
- setFields([]);
- }
- }, [chunk_num, t, enable_metadata, forceDelete]);
+ // Existing chunks are always dropped on re-ingest, so the dialog only
+ // needs a plain confirmation with no checkboxes. Seed delete: true so the
+ // click payload keeps the drop behavior.
+ const defaultValues = {
+ delete: true,
+ apply_kb: false,
+ };
const formCallbackRef = useRef<DynamicFormRef>(null);
const handleCancel = useCallback(() => {
- // handleOperationIconClick(false);
hideModal?.();
- // formInstance?.reset();
formCallbackRef?.current?.reset();
}, [formCallbackRef, hideModal]);
const handleSave = useCallback(async () => {
- // const instance = formInstance;
const instance = formCallbackRef?.current;
if (!instance) {
console.error('Form instance is null');
@@ -120,7 +45,6 @@ export const ReparseDialog = memo(
if (check) {
instance.submit();
const formValues = instance.getValues();
- console.log(formValues);
handleOperationIconClick({
delete: formValues.delete,
apply_kb: formValues.apply_kb,
@@ -136,11 +60,7 @@ export const ReparseDialog = memo(
open={visible}
okButtonText={t('common.confirm')}
content={{
- title: t(
- forceDelete
- ? `knowledgeDetails.clearChunksReparseTip`
- : `knowledgeDetails.parseFileTip`,
- ),
+ title: t(`knowledgeDetails.clearChunksReparseTip`),
node: (
<div>
<DynamicForm.Root
@@ -148,24 +68,13 @@ export const ReparseDialog = memo(
console.log('submit', data);
}}
ref={formCallbackRef}
- fields={fields}
+ fields={[]}
defaultValues={defaultValues}
- >
- {/* <DynamicForm.CancelButton
- handleCancel={() => handleOperationIconClick(false)}
- cancelText={t('common.cancel')}
- />
- <DynamicForm.SavingButton
- buttonText={t('common.confirm')}
- submitFunc={handleSave}
- /> */}
- </DynamicForm.Root>
+ ></DynamicForm.Root>
</div>
),
}}
- >
- {/* {children} */}
- </ConfirmDeleteDialog>
+ ></ConfirmDeleteDialog>
);
},
);
diff --git a/web/src/pages/dataset/dataset/use-bulk-operate-dataset.tsx b/web/src/pages/dataset/dataset/use-bulk-operate-dataset.tsx
index 709d70ca02..c18ad78cbc 100644
--- a/web/src/pages/dataset/dataset/use-bulk-operate-dataset.tsx
+++ b/web/src/pages/dataset/dataset/use-bulk-operate-dataset.tsx
@@ -1,5 +1,4 @@
import { Modal } from '@/components/ui/modal/modal';
-import { useSetModalState } from '@/hooks/common-hooks';
import {
UseRowSelectionType,
useSelectedIds,
@@ -10,7 +9,6 @@ import {
useSetDocumentStatus,
} from '@/hooks/use-document-request';
import { IDocumentInfo } from '@/interfaces/database/document';
-import { useIsGoBackend } from '@/utils/backend-variant';
import {
LucideCircleX,
LucideCylinder,
@@ -23,7 +21,6 @@ import { useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router';
import { toast } from 'sonner';
-import { useKnowledgeBaseContext } from '../contexts/knowledge-base-context';
import { DocumentType } from './constant';
import { buildParserGapModalContent } from './parser-gap-content';
import { useParserGapValidation } from './use-parser-gap-validation';
@@ -46,21 +43,7 @@ export function useBulkOperateDataset({
const { runDocumentByIds } = useRunDocument();
const { setDocumentStatus } = useSetDocumentStatus();
const { removeDocument } = useRemoveDocument();
- const { visible, showModal, hideModal } = useSetModalState();
const { findDocumentParseGaps } = useParserGapValidation();
- const { knowledgeBase } = useKnowledgeBaseContext();
- const isGo = useIsGoBackend();
-
- const chunkNum = useMemo(() => {
- if (!documents.length) {
- return 0;
- }
- return documents
- .filter((item) => selectedRowKeys.includes(item.id) && item.id)
- ?.reduce((acc, cur) => {
- return acc + cur.chunk_count;
- }, 0);
- }, [documents, selectedRowKeys]);
const runDocument = useCallback(
async (run: number, option?: { delete: boolean; apply_kb: boolean }) => {
@@ -134,16 +117,8 @@ export function useBulkOperateDataset({
run,
option,
});
- hideModal();
},
- [
- documents,
- runDocumentByIds,
- selectedRowKeys,
- hideModal,
- t,
- findDocumentParseGaps,
- ],
+ [documents, runDocumentByIds, selectedRowKeys, t, findDocumentParseGaps],
);
const handleRunClick = useCallback(
@@ -153,21 +128,6 @@ export function useBulkOperateDataset({
[runDocument],
);
- // The confirmation only offers real choices when the selection has existing
- // chunks to drop or auto-metadata to re-apply; otherwise run straight away.
- // Go re-ingests in place server-side, so the dialog is Python-only.
- const needsRunConfirm =
- !isGo &&
- (chunkNum > 0 || Boolean(knowledgeBase?.parser_config?.enable_metadata));
-
- const handleRunMenuClick = useCallback(() => {
- if (needsRunConfirm) {
- showModal();
- return;
- }
- handleRunClick();
- }, [needsRunConfirm, showModal, handleRunClick]);
-
const handleCancelClick = useCallback(() => {
runDocument(2);
}, [runDocument]);
@@ -210,7 +170,7 @@ export function useBulkOperateDataset({
id: 'run',
label: t('knowledgeDetails.run'),
icon: <LucidePlayCircle />,
- onClick: handleRunMenuClick,
+ onClick: handleRunClick,
},
{
id: 'cancel',
@@ -249,5 +209,5 @@ export function useBulkOperateDataset({
},
];
- return { chunkNum, list, visible, hideModal, showModal, handleRunClick };
+ return { list, handleRunClick };
}
diff --git a/web/src/pages/dataset/dataset/use-change-document-parser.ts b/web/src/pages/dataset/dataset/use-change-document-parser.ts
index 58e6c50df8..8607f905e3 100644
--- a/web/src/pages/dataset/dataset/use-change-document-parser.ts
+++ b/web/src/pages/dataset/dataset/use-change-document-parser.ts
@@ -1,17 +1,11 @@
import { useSetModalState } from '@/hooks/common-hooks';
-import {
- useSetDocumentParser,
- useSetDocumentPipelineParser,
-} from '@/hooks/use-document-request';
+import { useSetDocumentPipelineParser } from '@/hooks/use-document-request';
import { IDocumentInfo } from '@/interfaces/database/document';
import { IChangeParserRequestBody } from '@/interfaces/request/document';
-import { pickByBackend } from '@/utils/backend-variant';
import { useCallback, useState } from 'react';
export const useChangeDocumentParser = () => {
- const { setDocumentParser, loading } = useSetDocumentParser();
- const { setDocumentPipelineParser, loading: pipelineParserLoading } =
- useSetDocumentPipelineParser();
+ const { setDocumentPipelineParser, loading } = useSetDocumentPipelineParser();
const [record, setRecord] = useState<IDocumentInfo>({} as IDocumentInfo);
const {
@@ -23,23 +17,16 @@ export const useChangeDocumentParser = () => {
const onChangeParserOk = useCallback(
async (parserConfigInfo: IChangeParserRequestBody) => {
if (record?.id && record?.dataset_id) {
- // The Go document endpoint takes `parser_id` and a pipeline-shaped
- // parser_config; the Python one keeps the legacy payload shape.
- const common = {
+ // The document endpoint takes `parser_id` and a pipeline-shaped
+ // parser_config.
+ const ret = await setDocumentPipelineParser({
parserId: parserConfigInfo.parser_id,
pipelineId: parserConfigInfo.pipeline_id || '',
documentId: record?.id,
datasetId: record?.dataset_id,
parserConfig: parserConfigInfo.parser_config,
- };
- const ret = await pickByBackend({
- go: () =>
- setDocumentPipelineParser({
- ...common,
- parseType: parserConfigInfo.parseType,
- }),
- python: () => setDocumentParser(common),
- })();
+ parseType: parserConfigInfo.parseType,
+ });
if (ret === 0) {
hideChangeParserModal();
}
@@ -48,7 +35,6 @@ export const useChangeDocumentParser = () => {
[
record?.id,
record?.dataset_id,
- setDocumentParser,
setDocumentPipelineParser,
hideChangeParserModal,
],
@@ -63,7 +49,7 @@ export const useChangeDocumentParser = () => {
);
return {
- changeParserLoading: loading || pipelineParserLoading,
+ changeParserLoading: loading,
onChangeParserOk,
changeParserVisible,
hideChangeParserModal,
diff --git a/web/src/pages/dataset/dataset/use-parser-gap-validation.ts b/web/src/pages/dataset/dataset/use-parser-gap-validation.ts
index 57263f56fa..6cb0c30cb4 100644
--- a/web/src/pages/dataset/dataset/use-parser-gap-validation.ts
+++ b/web/src/pages/dataset/dataset/use-parser-gap-validation.ts
@@ -1,5 +1,4 @@
import type { IDocumentInfo } from '@/interfaces/database/document';
-import { useIsGoBackend } from '@/utils/backend-variant';
import { useCallback } from 'react';
import { useKnowledgeBaseContext } from '../contexts/knowledge-base-context';
import {
@@ -13,11 +12,8 @@ import {
* Validates that each file can be parsed under the Parser operator config it
* actually runs with: the file type must be declared in the operator setups,
* and audio/video additionally need their model configured.
- * Only the Go backend has parser operator settings — on the Python backend
- * every file passes.
*/
export function useParserGapValidation() {
- const isGoBackend = useIsGoBackend();
const { knowledgeBase, loading } = useKnowledgeBaseContext();
// Skip while the dataset is loading: its parser_config is not readable
@@ -26,7 +22,7 @@ export function useParserGapValidation() {
// determined either.
const findParseGaps = useCallback(
(names: string[]): FileParserGap[] => {
- if (!isGoBackend || loading) {
+ if (loading) {
return [];
}
const setups = getSavedParserSetups(knowledgeBase);
@@ -35,7 +31,7 @@ export function useParserGapValidation() {
}
return findFilesParserGaps(names, setups);
},
- [isGoBackend, loading, knowledgeBase],
+ [loading, knowledgeBase],
);
// Parse-time validation: a document may override the dataset parser, and
@@ -45,7 +41,7 @@ export function useParserGapValidation() {
(
documents: Pick<IDocumentInfo, 'name' | 'parser_config'>[],
): FileParserGap[] => {
- if (!isGoBackend || loading) {
+ if (loading) {
return [];
}
return findDocumentsParserGaps(
@@ -53,7 +49,7 @@ export function useParserGapValidation() {
getSavedParserSetups(knowledgeBase),
);
},
- [isGoBackend, loading, knowledgeBase],
+ [loading, knowledgeBase],
);
return { findParseGaps, findDocumentParseGaps };
diff --git a/web/src/pages/dataset/dataset/utils.test.ts b/web/src/pages/dataset/dataset/utils.test.ts
index 2ff42a15b9..651ebd4443 100644
--- a/web/src/pages/dataset/dataset/utils.test.ts
+++ b/web/src/pages/dataset/dataset/utils.test.ts
@@ -19,16 +19,8 @@ import {
isDocumentStopping,
} from './utils';
-// Dispatch on the mutable flag so each scenario can exercise either the
-// Go or the Python branch without mounting React.
-let mockIsGoBackend = false;
-jest.mock('@/utils/backend-variant', () => ({
- pickByBackend: ({ go, python }: { go: unknown; python: unknown }) =>
- mockIsGoBackend ? go : python,
-}));
-
describe('isDocumentStopping', () => {
- it('is true only for the Go STOPPING status', () => {
+ it('is true only for the STOPPING status', () => {
expect(
isDocumentStopping({ ingestion_status: IngestionTaskStatus.STOPPING }),
).toBe(true);
@@ -40,16 +32,9 @@ describe('isDocumentStopping', () => {
});
describe('getDocumentProgressMessage', () => {
- afterEach(() => {
- mockIsGoBackend = false;
- });
-
- it('reads the latest real ingestion event on Go', () => {
- mockIsGoBackend = true;
-
+ it('reads the latest real ingestion event', () => {
expect(
getDocumentProgressMessage({
- progress_msg: 'stale legacy text',
latest_ingestion_event: {
id: 42,
ts: '2026-01-01T00:00:00Z',
@@ -62,108 +47,29 @@ describe('getDocumentProgressMessage', () => {
).toBe('Indexing 4/10');
});
- it('keeps the Python progress field unchanged', () => {
- mockIsGoBackend = false;
-
- expect(
- getDocumentProgressMessage({
- progress_msg: 'Parsing chunks',
- latest_ingestion_event: {
- id: 42,
- ts: '2026-01-01T00:00:00Z',
- event_type: 1,
- component: '',
- phase: 0,
- message: 'Go-only event',
- },
- }),
- ).toBe('Parsing chunks');
- });
-
it('returns a placeholder when the selected source has no message', () => {
- mockIsGoBackend = true;
-
- expect(getDocumentProgressMessage({ progress_msg: '' })).toBe('-');
+ expect(getDocumentProgressMessage({})).toBe('-');
});
});
describe('isDocumentProcessing', () => {
- afterEach(() => {
- mockIsGoBackend = false;
- });
-
- describe('Go backend', () => {
- beforeEach(() => {
- mockIsGoBackend = true;
- });
-
- it.each([
- IngestionTaskStatus.CREATED,
- IngestionTaskStatus.SCHEDULED,
- IngestionTaskStatus.RUNNING,
- IngestionTaskStatus.STOPPING,
- ])('treats active ingestion_status %s as processing', (status) => {
- expect(isDocumentProcessing({ ingestion_status: status })).toBe(true);
- });
-
- it.each([
- IngestionTaskStatus.UNSTART,
- IngestionTaskStatus.COMPLETED,
- IngestionTaskStatus.FAILED,
- IngestionTaskStatus.STOPPED,
- undefined,
- ])(
- 'treats idle/terminal ingestion_status %s as not processing',
- (status) => {
- expect(isDocumentProcessing({ ingestion_status: status })).toBe(false);
- },
- );
-
- it('ignores a stale legacy run field on Go responses', () => {
- expect(
- isDocumentProcessing({
- run: RunningStatus.RUNNING,
- ingestion_status: IngestionTaskStatus.COMPLETED,
- }),
- ).toBe(false);
- });
+ it.each([
+ IngestionTaskStatus.CREATED,
+ IngestionTaskStatus.SCHEDULED,
+ IngestionTaskStatus.RUNNING,
+ IngestionTaskStatus.STOPPING,
+ ])('treats active ingestion_status %s as processing', (status) => {
+ expect(isDocumentProcessing({ ingestion_status: status })).toBe(true);
});
- describe('Python backend', () => {
- beforeEach(() => {
- mockIsGoBackend = false;
- });
-
- it('treats run=RUNNING as processing', () => {
- expect(isDocumentProcessing({ run: RunningStatus.RUNNING })).toBe(true);
- });
-
- it.each([
- RunningStatus.UNSTART,
- RunningStatus.CANCEL,
- RunningStatus.DONE,
- RunningStatus.FAIL,
- undefined,
- ])('treats terminal/absent run %s as not processing', (run) => {
- expect(isDocumentProcessing({ run })).toBe(false);
- });
-
- // Python never serializes ingestion_status; even if a stray field
- // reached the client, it must not influence the run-based result.
- it('ignores ingestion_status because Python never sends it', () => {
- expect(
- isDocumentProcessing({
- run: RunningStatus.DONE,
- ingestion_status: IngestionTaskStatus.RUNNING,
- }),
- ).toBe(false);
- expect(
- isDocumentProcessing({
- run: RunningStatus.RUNNING,
- ingestion_status: IngestionTaskStatus.STOPPED,
- }),
- ).toBe(true);
- });
+ it.each([
+ IngestionTaskStatus.UNSTART,
+ IngestionTaskStatus.COMPLETED,
+ IngestionTaskStatus.FAILED,
+ IngestionTaskStatus.STOPPED,
+ undefined,
+ ])('treats idle/terminal ingestion_status %s as not processing', (status) => {
+ expect(isDocumentProcessing({ ingestion_status: status })).toBe(false);
});
});
@@ -184,33 +90,20 @@ describe('ingestionStatusToRunningStatus', () => {
});
describe('getDocumentRunningStatus', () => {
- afterEach(() => {
- mockIsGoBackend = false;
- });
-
- it('derives every status from ingestion_status on Go', () => {
- mockIsGoBackend = true;
+ it('derives every status from ingestion_status', () => {
expect(
getDocumentRunningStatus({
- run: undefined,
ingestion_status: IngestionTaskStatus.STOPPED,
}),
).toBe(RunningStatus.CANCEL);
expect(
getDocumentRunningStatus({
- run: RunningStatus.RUNNING,
ingestion_status: IngestionTaskStatus.COMPLETED,
}),
).toBe(RunningStatus.DONE);
});
- it('reads the legacy run field on Python', () => {
- expect(getDocumentRunningStatus({ run: RunningStatus.DONE })).toBe(
- RunningStatus.DONE,
- );
- });
-
- it('falls back to UNSTART when Python omits run', () => {
+ it('falls back to UNSTART when status is missing', () => {
expect(getDocumentRunningStatus({})).toBe(RunningStatus.UNSTART);
});
});
diff --git a/web/src/pages/dataset/dataset/utils.ts b/web/src/pages/dataset/dataset/utils.ts
index ad002cd73d..935169d583 100644
--- a/web/src/pages/dataset/dataset/utils.ts
+++ b/web/src/pages/dataset/dataset/utils.ts
@@ -1,7 +1,6 @@
import { Operator } from '@/constants/agent';
import { FileType, FileTypeSuffixMap } from '@/constants/file';
import type { IDocumentInfo } from '@/interfaces/database/document';
-import { pickByBackend } from '@/utils/backend-variant';
import { getExtension } from '@/utils/document-util';
import {
getOperatorType,
@@ -22,11 +21,6 @@ const activeIngestionStatuses = new Set<IngestionTaskStatus>([
IngestionTaskStatus.STOPPING,
]);
-export const isParserRunning = (text?: RunningStatus) => {
- const isRunning = text === RunningStatus.RUNNING;
- return isRunning;
-};
-
/**
* Maps a Go `ingestion_status` value onto the legacy `RunningStatus`
* vocabulary consumed by the document list UI (icons, dots, labels).
@@ -71,39 +65,24 @@ export const ingestionStatusToRunningStatus = (
/**
* Returns the effective display/action status of a document.
*
- * Go derives every status from the real-time `ingestion_status` field
- * (the `run` field is no longer returned). Python keeps reading the
- * legacy `run` field, which is always present on Python responses.
+ * Every status is derived from the real-time `ingestion_status` field
+ * (the legacy `run` field is no longer returned).
*
- * @param document - Document (or subset) carrying the raw status fields.
+ * @param document - Document (or subset) carrying the raw status field.
* @returns The `RunningStatus` to drive icons, dots and labels.
*
* @example
- * // Go backend
* getDocumentRunningStatus({ ingestion_status: IngestionTaskStatus.SCHEDULED });
* // => RunningStatus.QUEUED
- *
- * @example
- * // Python backend
- * getDocumentRunningStatus({ run: RunningStatus.RUNNING });
- * // => RunningStatus.RUNNING
*/
export const getDocumentRunningStatus = (
- document: Pick<IDocumentInfo, 'run' | 'ingestion_status'>,
-): RunningStatus =>
- pickByBackend({
- go: ingestionStatusToRunningStatus(document.ingestion_status),
- python: document.run ?? RunningStatus.UNSTART,
- });
+ document: Pick<IDocumentInfo, 'ingestion_status'>,
+): RunningStatus => ingestionStatusToRunningStatus(document.ingestion_status);
-/** Returns the backend-specific message shown for a document's current run. */
+/** Returns the message shown for a document's current run. */
export const getDocumentProgressMessage = (
- document: Pick<IDocumentInfo, 'progress_msg' | 'latest_ingestion_event'>,
-) =>
- pickByBackend({
- go: document.latest_ingestion_event?.message,
- python: document.progress_msg,
- }) || '-';
+ document: Pick<IDocumentInfo, 'latest_ingestion_event'>,
+) => document.latest_ingestion_event?.message || '-';
/**
* Whether a cancel request is currently in flight for the document.
@@ -130,41 +109,21 @@ const isGoDocumentProcessing = (
!!document.ingestion_status &&
activeIngestionStatuses.has(document.ingestion_status);
-// Python: ingestion_status is never present on Python responses (the
-// Python backend only serializes the legacy run field), so run is the
-// only signal — exactly the pre-Go polling contract
-// (docs.some(doc => doc.run === RUNNING)).
-const isPythonDocumentProcessing = (document: Pick<IDocumentInfo, 'run'>) =>
- isParserRunning(document.run);
-
/**
* Whether a document is currently being parsed (queued, running or
* canceling). Drives the 5s list polling, disabled row actions and the
* bulk-delete protection.
*
- * The check is backend-specific: on Go it relies solely on
- * `ingestion_status`, on Python it follows the legacy `run`-based logic.
- *
- * @param document - Document (or subset) carrying the raw status fields.
+ * @param document - Document (or subset) carrying the raw status field.
* @returns `true` while any parse-related task is in progress.
*
* @example
- * // Go backend
* isDocumentProcessing({ ingestion_status: IngestionTaskStatus.RUNNING });
* // => true
- *
- * @example
- * // Python backend
- * isDocumentProcessing({ run: RunningStatus.DONE });
- * // => false
*/
export const isDocumentProcessing = (
- document: Pick<IDocumentInfo, 'run' | 'ingestion_status'>,
-) =>
- pickByBackend({
- go: isGoDocumentProcessing(document),
- python: isPythonDocumentProcessing(document),
- });
+ document: Pick<IDocumentInfo, 'ingestion_status'>,
+) => isGoDocumentProcessing(document);
// --- Parser prerequisite checks -------------------------------------------
// A file cannot be parsed under the dataset's current Parser operator when
diff --git a/web/src/pages/dataset/ingestion-message-hooks.ts b/web/src/pages/dataset/ingestion-message-hooks.ts
index 5865cc71a2..dbea5d32a0 100644
--- a/web/src/pages/dataset/ingestion-message-hooks.ts
+++ b/web/src/pages/dataset/ingestion-message-hooks.ts
@@ -3,7 +3,6 @@ import {
IngestionMessageParams,
} from '@/interfaces/database/ingestion';
import { listIngestionMessages } from '@/services/knowledge-service';
-import { useIsGoBackend } from '@/utils/backend-variant';
import { useInfiniteQuery, useQueryClient } from '@tanstack/react-query';
import type { InfiniteData } from '@tanstack/react-query';
import { useEffect, useRef, useState } from 'react';
@@ -27,7 +26,6 @@ export const useIngestionMessages = (
params: IngestionMessageParams = DefaultParams,
) => {
const queryClient = useQueryClient();
- const isGoBackend = useIsGoBackend();
const [finishing, setFinishing] = useState(false);
const finishingRef = useRef(false);
@@ -39,7 +37,7 @@ export const useIngestionMessages = (
IngestionMessageParams | undefined
>({
queryKey: IngestionMessageKeys.messages(datasetId, logId),
- enabled: enabled && isGoBackend && !!datasetId && !!logId,
+ enabled: enabled && !!datasetId && !!logId,
initialPageParam: undefined,
queryFn: async ({ pageParam }) => {
const { data: res = {} } = await listIngestionMessages(
@@ -80,14 +78,7 @@ export const useIngestionMessages = (
newestIdRef.current = newestId;
useEffect(() => {
- if (
- !enabled ||
- !isGoBackend ||
- !datasetId ||
- !logId ||
- terminal ||
- finishing
- ) {
+ if (!enabled || !datasetId || !logId || terminal || finishing) {
return;
}
const interval = setInterval(async () => {
@@ -148,7 +139,6 @@ export const useIngestionMessages = (
return () => clearInterval(interval);
}, [
enabled,
- isGoBackend,
datasetId,
logId,
terminal,
@@ -165,14 +155,7 @@ export const useIngestionMessages = (
}, [datasetId, logId]);
useEffect(() => {
- if (
- !terminal ||
- finishingRef.current ||
- !enabled ||
- !isGoBackend ||
- !datasetId ||
- !logId
- ) {
+ if (!terminal || finishingRef.current || !enabled || !datasetId || !logId) {
return;
}
finishingRef.current = true;
@@ -212,7 +195,7 @@ export const useIngestionMessages = (
}
}, PollIntervalMs);
return () => clearTimeout(timer);
- }, [datasetId, enabled, isGoBackend, logId, params, queryClient, terminal]);
+ }, [datasetId, enabled, logId, params, queryClient, terminal]);
return {
...query,
diff --git a/web/src/pages/dataset/setting/common-item.tsx b/web/src/pages/dataset/setting/common-item.tsx
new file mode 100644
index 0000000000..d4758b8f6d
--- /dev/null
+++ b/web/src/pages/dataset/setting/common-item.tsx
@@ -0,0 +1,101 @@
+import { ModelTreeSelect, ModelTypeMap } from '@/components/model-tree-select';
+import {
+ FormControl,
+ FormField,
+ FormItem,
+ FormLabel,
+ FormMessage,
+} from '@/components/ui/form';
+import { useTranslate } from '@/hooks/common-hooks';
+import { useFetchDatasetPipelineConfiguration } from '@/hooks/use-knowledge-request';
+import { cn } from '@/lib/utils';
+import { FieldValues, useFormContext } from 'react-hook-form';
+import { EmbeddingSelect } from './embedding-select';
+
+interface IProps {
+ line?: 1 | 2;
+ isEdit?: boolean;
+ label?: string;
+ name?: string;
+}
+
+export function EmbeddingModelItem({
+ line = 1,
+ isEdit,
+ ownerTenantId,
+}: IProps & { ownerTenantId?: string }) {
+ const { t } = useTranslate('knowledgeConfiguration');
+ const form = useFormContext();
+ const { data: knowledgeDetails } = useFetchDatasetPipelineConfiguration({
+ isEdit,
+ });
+ const disabled = knowledgeDetails.chunk_count > 0;
+ return (
+ <FormField
+ control={form.control}
+ name={'embedding_model'}
+ render={({ field }) => (
+ <FormItem className={cn('items-center space-y-0')}>
+ <div
+ className={cn('flex', {
+ 'items-center': line === 1,
+ 'flex-col gap-1': line === 2,
+ })}
+ >
+ <FormLabel
+ required
+ tooltip={t('embeddingModelTip')}
+ className={cn('text-sm whitespace-wrap', {
+ 'w-1/4': line === 1,
+ })}
+ >
+ {t('embeddingModel')}
+ </FormLabel>
+ <div className={cn('text-text-primary', { 'w-3/4': line === 1 })}>
+ <FormControl>
+ <EmbeddingSelect
+ isEdit={!!isEdit}
+ field={field}
+ disabled={disabled}
+ testId="ds-settings-basic-embedding-model-select"
+ ownerTenantId={ownerTenantId}
+ ></EmbeddingSelect>
+ </FormControl>
+ </div>
+ </div>
+ <div className="flex pt-1">
+ <div className={line === 1 ? 'w-1/4' : ''}></div>
+ <FormMessage />
+ </div>
+ </FormItem>
+ )}
+ />
+ );
+}
+
+export const LLMSelect = ({
+ isEdit,
+ field,
+ disabled = false,
+ ownerTenantId,
+}: {
+ isEdit: boolean;
+ field: FieldValues;
+ name?: string;
+ disabled?: boolean;
+ ownerTenantId?: string;
+}) => {
+ const { t } = useTranslate('knowledgeConfiguration');
+ return (
+ <ModelTreeSelect
+ modelTypes={ModelTypeMap.llm_id}
+ onChange={(value) => {
+ field.onChange(value);
+ }}
+ disabled={disabled && !isEdit}
+ value={field.value}
+ placeholder={t('embeddingModelPlaceholder')}
+ ownerTenantId={ownerTenantId}
+ />
+ );
+};
diff --git a/web/src/pages/dataset/setting/go/hooks.test.tsx b/web/src/pages/dataset/setting/go/hooks.test.tsx
index c1fad20a98..c174217752 100644
--- a/web/src/pages/dataset/setting/go/hooks.test.tsx
+++ b/web/src/pages/dataset/setting/go/hooks.test.tsx
@@ -2,10 +2,6 @@ import { useUpdateKnowledge } from '@/hooks/use-knowledge-request';
import { renderHook } from '@testing-library/react';
import { useSaveDatasetSetting } from './hooks';
-let mockIsGoBackend = true;
-jest.mock('@/utils/backend-runtime', () => ({
- getBackendLanguage: () => (mockIsGoBackend ? 'go' : 'python'),
-}));
jest.mock('@/hooks/use-knowledge-request', () => ({
useFetchDatasetPipelineConfiguration: jest.fn(),
useUpdateKnowledge: jest.fn(),
@@ -21,7 +17,6 @@ const mockUseUpdateKnowledge = jest.mocked(useUpdateKnowledge);
describe('useSaveDatasetSetting parser_config metadata scoping', () => {
beforeEach(() => {
- mockIsGoBackend = true;
mockUseUpdateKnowledge.mockReset();
});
diff --git a/web/src/pages/dataset/setting/go/index.tsx b/web/src/pages/dataset/setting/go/index.tsx
index 4cee59cc79..f6349874c0 100644
--- a/web/src/pages/dataset/setting/go/index.tsx
+++ b/web/src/pages/dataset/setting/go/index.tsx
@@ -25,7 +25,6 @@ import { useCallback, useEffect, useState } from 'react';
import { FieldErrors, useForm, useFormState, useWatch } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
import { z } from 'zod';
-import ChunkMethodLearnMore from '../python/chunk-method-learn-more';
import LinkDataSource, {
IDataSourceNodeProps,
} from './components/link-data-source';
@@ -195,7 +194,7 @@ export default function DatasetSetting() {
</header>
</CardHeader>
- <CardContent className="p-0 flex-1 h-0 flex divide-x-0.5">
+ <CardContent className="p-0 flex-1 h-0 flex">
<Form {...form}>
<form
onSubmit={form.handleSubmit(handleSubmit, handleInvalidSubmit)}
@@ -277,12 +276,6 @@ export default function DatasetSetting() {
</div>
</form>
</Form>
-
- <div className="flex-1 p-5 overflow-auto">
- {parseType === ParseType.BuiltIn && builtinPipelineId && (
- <ChunkMethodLearnMore parserId={builtinPipelineId} />
- )}
- </div>
</CardContent>
</Card>
</div>
diff --git a/web/src/pages/dataset/setting/index.tsx b/web/src/pages/dataset/setting/index.tsx
index b2564171fd..a4702afdf1 100644
--- a/web/src/pages/dataset/setting/index.tsx
+++ b/web/src/pages/dataset/setting/index.tsx
@@ -1,19 +1 @@
-import { BackendVariant } from '@/utils/backend-variant';
-import { lazy, Suspense } from 'react';
-
-const GoDatasetSetting = lazy(() => import('./go'));
-const PythonDatasetSetting = lazy(() => import('./python'));
-
-// Single configuration route for both backends. Each variant page stays in
-// its own chunk so a deployment only ever downloads the implementation its
-// backend serves.
-export default function DatasetSettingPage() {
- return (
- <Suspense fallback={null}>
- <BackendVariant
- go={<GoDatasetSetting />}
- python={<PythonDatasetSetting />}
- />
- </Suspense>
- );
-}
+export { default } from './go';
diff --git a/web/src/pages/dataset/setting/python/category-panel.tsx b/web/src/pages/dataset/setting/python/category-panel.tsx
deleted file mode 100644
index 2635c8d269..0000000000
--- a/web/src/pages/dataset/setting/python/category-panel.tsx
+++ /dev/null
@@ -1,120 +0,0 @@
-import SvgIcon from '@/components/svg-icon';
-import Divider from '@/components/ui/divider';
-import { useTranslate } from '@/hooks/common-hooks';
-import { useSelectParserList } from '@/hooks/use-user-setting-request';
-import DOMPurify from 'dompurify';
-import camelCase from 'lodash/camelCase';
-import { useCallback, useEffect, useMemo, useState } from 'react';
-import { TagTabs } from './tag-tabs';
-import { DescriptionKeyMap, ImageMap } from './utils';
-
-const ChunkMethodScreenshot = ({ src }: { src: string }) => {
- const { t } = useTranslate('knowledgeConfiguration');
- const [failed, setFailed] = useState(false);
-
- useEffect(() => {
- setFailed(false);
- }, [src]);
-
- const handleError = useCallback(() => setFailed(true), []);
-
- if (failed) {
- return (
- <div className="flex h-40 w-full items-center justify-center rounded-md border border-border-button bg-bg-card">
- <span className="text-sm text-text-secondary">
- {t('imageLoadFailed')}
- </span>
- </div>
- );
- }
-
- return (
- <img
- src={src}
- alt=""
- width={'100%'}
- className="w-full max-w-full"
- onError={handleError}
- />
- );
-};
-
-const CategoryPanel = ({ chunkMethod }: { chunkMethod: string }) => {
- const parserList = useSelectParserList();
- const { t } = useTranslate('knowledgeConfiguration');
-
- const item = useMemo(() => {
- const item = parserList.find((x) => x.value === chunkMethod);
- if (item) {
- const descriptionKey = DescriptionKeyMap[item.value] ?? item.value;
- return {
- title: item.label,
- // Methods without a description entry get an empty string, so the
- // empty placeholder below is still shown for them.
- description: t(camelCase(descriptionKey), { defaultValue: '' }),
- };
- }
- return { title: '', description: '' };
- }, [parserList, chunkMethod, t]);
-
- const imageList = useMemo(() => {
- if (chunkMethod in ImageMap) {
- return ImageMap[chunkMethod as keyof typeof ImageMap];
- }
- return [];
- }, [chunkMethod]);
-
- const hasDescription = item.description.trim().length > 0;
-
- return (
- <div>
- {hasDescription ? (
- <>
- <h5 className="font-semibold text-base mt-0 mb-1">
- {`"${item.title}" ${t('methodTitle')}`}
- </h5>
- <p
- className="[&_ul]:list-disc [&_ol]:list-decimal [&_:is(ul,ol)]:pl-8"
- dangerouslySetInnerHTML={{
- __html: DOMPurify.sanitize(item.description),
- }}
- ></p>
- {imageList.length > 0 && (
- <>
- <h5 className="font-semibold text-base mt-4 mb-1">{`"${item.title}" ${t('methodExamples')}`}</h5>
- <span className="text-text-secondary">
- {t('methodExamplesDescription')}
- </span>
- <div className="grid grid-cols-2 gap-2.5 mt-4">
- {imageList.map((x) =>
- /^https?:\/\//.test(x) ? (
- <ChunkMethodScreenshot key={x} src={x} />
- ) : (
- <SvgIcon
- key={x}
- name={x}
- width={'100%'}
- className="w-full"
- ></SvgIcon>
- ),
- )}
- </div>
- <h5 className="font-semibold text-base mt-4 mb-1">
- {item.title} {t('dialogueExamplesTitle')}
- </h5>
- <Divider></Divider>
- </>
- )}
- </>
- ) : (
- <div className="flex flex-col items-center justify-center py-8">
- <p className="text-text-secondary mb-4">{t('methodEmpty')}</p>
- <SvgIcon name={'chunk-method/chunk-empty'} width={'100%'}></SvgIcon>
- </div>
- )}
- {chunkMethod === 'tag' && <TagTabs></TagTabs>}
- </div>
- );
-};
-
-export default CategoryPanel;
diff --git a/web/src/pages/dataset/setting/python/chunk-method-form.tsx b/web/src/pages/dataset/setting/python/chunk-method-form.tsx
deleted file mode 100644
index 3f48eb39ce..0000000000
--- a/web/src/pages/dataset/setting/python/chunk-method-form.tsx
+++ /dev/null
@@ -1,64 +0,0 @@
-import { useFormContext, useWatch } from 'react-hook-form';
-
-import { DocumentParserType } from '@/constants/knowledge';
-import { useMemo } from 'react';
-import { AudioConfiguration } from './configuration/audio';
-import { BookConfiguration } from './configuration/book';
-import { EmailConfiguration } from './configuration/email';
-import { KnowledgeGraphConfiguration } from './configuration/knowledge-graph';
-import { LawsConfiguration } from './configuration/laws';
-import { ManualConfiguration } from './configuration/manual';
-import { NaiveConfiguration } from './configuration/naive';
-import { OneConfiguration } from './configuration/one';
-import { PaperConfiguration } from './configuration/paper';
-import { PictureConfiguration } from './configuration/picture';
-import { PresentationConfiguration } from './configuration/presentation';
-import { QAConfiguration } from './configuration/qa';
-import { ResumeConfiguration } from './configuration/resume';
-import { TableConfiguration } from './configuration/table';
-import { TagConfiguration } from './configuration/tag';
-
-const ConfigurationComponentMap = {
- [DocumentParserType.Naive]: NaiveConfiguration,
- [DocumentParserType.Qa]: QAConfiguration,
- [DocumentParserType.Resume]: ResumeConfiguration,
- [DocumentParserType.Manual]: ManualConfiguration,
- [DocumentParserType.Table]: TableConfiguration,
- [DocumentParserType.Paper]: PaperConfiguration,
- [DocumentParserType.Book]: BookConfiguration,
- [DocumentParserType.Laws]: LawsConfiguration,
- [DocumentParserType.Presentation]: PresentationConfiguration,
- [DocumentParserType.Picture]: PictureConfiguration,
- [DocumentParserType.One]: OneConfiguration,
- [DocumentParserType.Audio]: AudioConfiguration,
- [DocumentParserType.Email]: EmailConfiguration,
- [DocumentParserType.Tag]: TagConfiguration,
- [DocumentParserType.KnowledgeGraph]: KnowledgeGraphConfiguration,
-};
-
-function EmptyComponent() {
- return <div></div>;
-}
-
-export function ChunkMethodForm() {
- const form = useFormContext();
-
- const finalParserId: DocumentParserType = useWatch({
- control: form.control,
- name: 'chunk_method',
- });
-
- const ConfigurationComponent = useMemo(() => {
- return finalParserId
- ? ConfigurationComponentMap[finalParserId]
- : EmptyComponent;
- }, [finalParserId]);
-
- return (
- <section className="h-full flex flex-col">
- <div className="overflow-auto flex-1 min-h-0">
- <ConfigurationComponent></ConfigurationComponent>
- </div>
- </section>
- );
-}
diff --git a/web/src/pages/dataset/setting/python/chunk-method-learn-more.tsx b/web/src/pages/dataset/setting/python/chunk-method-learn-more.tsx
deleted file mode 100644
index abc3a47cd1..0000000000
--- a/web/src/pages/dataset/setting/python/chunk-method-learn-more.tsx
+++ /dev/null
@@ -1,47 +0,0 @@
-import { Button } from '@/components/ui/button';
-import { Card, CardContent } from '@/components/ui/card';
-import { cn } from '@/lib/utils';
-import { t } from 'i18next';
-import { LucideX } from 'lucide-react';
-import { useState } from 'react';
-import CategoryPanel from './category-panel';
-
-const ChunkMethodLearnMore = ({ parserId }: { parserId: string }) => {
- const [visible, setVisible] = useState(false);
-
- return (
- <div className={cn('hidden flex-1', 'flex flex-col')}>
- <div>
- <Button
- variant="outline"
- onClick={() => {
- setVisible(!visible);
- }}
- >
- {t('knowledgeDetails.learnMore')}
- </Button>
- </div>
-
- <Card
- as="article"
- className="relative flex-1 overflow-auto mt-4"
- style={{ display: visible ? 'block' : 'none' }}
- >
- <Button
- className="absolute right-2 top-2"
- variant="ghost"
- size="icon-xs"
- onClick={() => setVisible(false)}
- >
- <LucideX />
- </Button>
-
- <CardContent className="p-5">
- <CategoryPanel chunkMethod={parserId}></CategoryPanel>
- </CardContent>
- </Card>
- </div>
- );
-};
-
-export default ChunkMethodLearnMore;
diff --git a/web/src/pages/dataset/setting/python/components/added-source-card.tsx b/web/src/pages/dataset/setting/python/components/added-source-card.tsx
deleted file mode 100644
index b4b8759ff8..0000000000
--- a/web/src/pages/dataset/setting/python/components/added-source-card.tsx
+++ /dev/null
@@ -1,97 +0,0 @@
-import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
-import { cn } from '@/lib/utils';
-import {
- IDataSorceInfo,
- IDataSourceBase,
-} from '@/pages/user-setting/data-source/interface';
-import { Check } from 'lucide-react';
-import { useMemo } from 'react';
-
-export type IAddedSourceCardProps = IDataSorceInfo & {
- filterString: string;
- list: IDataSourceBase[];
- selectedList: IDataSourceBase[];
- setSelectedList: (list: IDataSourceBase[]) => void;
-};
-export const AddedSourceCard = (props: IAddedSourceCardProps) => {
- const {
- list: originList,
- name,
- icon,
- filterString,
- selectedList,
- setSelectedList,
- } = props;
-
- const list = useMemo(() => {
- return originList.map((item) => {
- const checked = selectedList?.some((i) => i.id === item.id) || false;
- return {
- ...item,
- checked: checked,
- };
- });
- }, [originList, selectedList]);
-
- const filterList = useMemo(
- () => list.filter((item) => item.name.indexOf(filterString) > -1),
- [filterString, list],
- );
-
- // const { navigateToDataSourceDetail } = useNavigatePage();
- // const toDetail = (id: string) => {
- // navigateToDataSourceDetail(id);
- // };
-
- const onCheck = (item: IDataSourceBase & { checked: boolean }) => {
- if (item.checked) {
- setSelectedList(selectedList.filter((i) => i.id !== item.id));
- } else {
- setSelectedList([...(selectedList || []), item]);
- }
- };
- return (
- <>
- {filterList.length > 0 && (
- <Card className="bg-transparent border border-border-button px-5 pt-[10px] pb-5 rounded-md">
- <CardHeader className="flex flex-row items-center justify-between space-y-0 p-0 pb-3">
- {/* <Users className="mr-2 h-5 w-5 text-[#1677ff]" /> */}
- <CardTitle className="text-base flex gap-1 font-normal">
- {icon}
- {name}
- </CardTitle>
- </CardHeader>
- <CardContent className="p-2 flex flex-col gap-2">
- {filterList.map((item) => (
- <div
- key={item.id}
- className={cn(
- 'flex flex-row items-center justify-between rounded-md bg-bg-card px-2 py-1 cursor-pointer',
- // { hidden: item.name.indexOf(filterString) <= -1 },
- )}
- onClick={() => {
- console.log('item--->', item);
- // toDetail(item.id);
- onCheck(item);
- }}
- >
- <div className="text-sm text-text-secondary ">{item.name}</div>
- <div className="text-sm text-text-secondary flex gap-2">
- {item.checked && (
- <Check
- className="cursor-pointer"
- size={14}
- // onClick={() => {
- // toDetail(item.id);
- // }}
- />
- )}
- </div>
- </div>
- ))}
- </CardContent>
- </Card>
- )}
- </>
- );
-};
diff --git a/web/src/pages/dataset/setting/python/components/link-data-pipeline.tsx b/web/src/pages/dataset/setting/python/components/link-data-pipeline.tsx
deleted file mode 100644
index 92c80dab65..0000000000
--- a/web/src/pages/dataset/setting/python/components/link-data-pipeline.tsx
+++ /dev/null
@@ -1,191 +0,0 @@
-import { IDataPipelineSelectNode } from '@/components/data-pipeline-select';
-import { IconFont } from '@/components/icon-font';
-import { RAGFlowAvatar } from '@/components/ragflow-avatar';
-import { Button } from '@/components/ui/button';
-import { Modal } from '@/components/ui/modal/modal';
-import { Link } from 'lucide-react';
-import { useMemo, useState } from 'react';
-import { useTranslation } from 'react-i18next';
-import LinkDataPipelineModal from './link-data-pipline-modal';
-export interface IDataPipelineNodeProps extends IDataPipelineSelectNode {
- isDefault?: boolean;
- linked?: boolean;
-}
-
-export interface ILinkDataPipelineProps {
- data?: IDataPipelineNodeProps;
- handleLinkOrEditSubmit?: (data: IDataPipelineNodeProps | undefined) => void;
-}
-
-interface DataPipelineItemProps extends IDataPipelineNodeProps {
- openLinkModalFunc?: (open: boolean, data?: IDataPipelineNodeProps) => void;
-}
-
-const DataPipelineItem = (props: DataPipelineItemProps) => {
- const { t } = useTranslation();
- const { name, avatar, isDefault, linked, openLinkModalFunc } = props;
- const openUnlinkModal = () => {
- Modal.show({
- visible: true,
- className: '!w-[560px]',
- title: t('dataflowParser.unlinkPipelineModalTitle'),
- children: (
- <div
- className="text-sm text-text-secondary"
- dangerouslySetInnerHTML={{
- __html: t('dataflowParser.unlinkPipelineModalContent'),
- }}
- ></div>
- ),
- onVisibleChange: () => {
- Modal.hide();
- },
- footer: (
- <div className="flex justify-end gap-2">
- <Button variant={'outline'} onClick={() => Modal.hide()}>
- {t('dataflowParser.changeStepModalCancelText')}
- </Button>
- <Button
- variant={'secondary'}
- className="!bg-state-error text-bg-base"
- onClick={() => {
- Modal.hide();
- }}
- >
- {t('dataflowParser.unlinkPipelineModalConfirmText')}
- </Button>
- </div>
- ),
- });
- };
-
- return (
- <div className="flex items-center justify-between gap-1 px-2 rounded-md border">
- <div className="flex items-center gap-1">
- <RAGFlowAvatar avatar={avatar} name={name} className="size-4" />
- <div>{name}</div>
- {/* {isDefault && (
- <div className="text-xs bg-text-secondary text-bg-base px-2 py-1 rounded-md">
- {t('knowledgeConfiguration.default')}
- </div>
- )} */}
- </div>
- {/* <div className="flex gap-1 items-center">
- <Button
- variant={'transparent'}
- className="border-none"
- type="button"
- onClick={() =>
- openLinkModalFunc?.(true, { ...omit(props, ['openLinkModalFunc']) })
- }
- >
- <Settings2 />
- </Button>
- {!isDefault && (
- <>
- {linked && (
- <Button
- type="button"
- variant={'transparent'}
- className="border-none"
- onClick={() => {
- openUnlinkModal();
- }}
- >
- <Unlink />
- </Button>
- )}
- </>
- )}
- </div> */}
- </div>
- );
-};
-
-const LinkDataPipeline = (props: ILinkDataPipelineProps) => {
- const { data, handleLinkOrEditSubmit: submit } = props;
- const { t } = useTranslation();
- const [openLinkModal, setOpenLinkModal] = useState(false);
- const [currentDataPipeline, setCurrentDataPipeline] =
- useState<IDataPipelineNodeProps>();
- const pipelineNode: IDataPipelineNodeProps[] = useMemo(
- () => [
- {
- id: data?.id,
- name: data?.name,
- avatar: data?.avatar,
- isDefault: data?.isDefault,
- linked: true,
- },
- ],
- [data],
- );
- const openLinkModalFunc = (open: boolean, data?: IDataPipelineNodeProps) => {
- console.log('open', open, data);
- setOpenLinkModal(open);
- if (data) {
- setCurrentDataPipeline(data);
- } else {
- setCurrentDataPipeline(undefined);
- }
- };
- const handleLinkOrEditSubmit = (
- data: IDataPipelineSelectNode | undefined,
- ) => {
- console.log('handleLinkOrEditSubmit', data);
- submit?.(data);
- setOpenLinkModal(false);
- };
- return (
- <div className="flex flex-col gap-2">
- <section className="flex flex-col">
- <div className="flex items-center gap-1 text-text-primary text-sm">
- <IconFont name="Pipeline" />
- {t('knowledgeConfiguration.dataPipeline')}
- </div>
- <div className="flex justify-between items-center">
- <div className="text-center text-xs text-text-secondary">
- {t('knowledgeConfiguration.linkPipelineSetTip')}
- </div>
- <Button
- type="button"
- variant={'transparent'}
- onClick={() => {
- openLinkModalFunc?.(true);
- }}
- >
- <Link />
- <span className="text-xs text-text-primary">
- {t('knowledgeConfiguration.linkDataPipeline')}
- </span>
- </Button>
- </div>
- </section>
- <section className="flex flex-col gap-2">
- {pipelineNode.map(
- (item) =>
- item.id && (
- <DataPipelineItem
- key={item.id}
- openLinkModalFunc={openLinkModalFunc}
- id={item.id}
- name={item.name}
- avatar={item.avatar}
- isDefault={item.isDefault}
- linked={item.linked}
- />
- ),
- )}
- </section>
- <LinkDataPipelineModal
- data={currentDataPipeline}
- open={openLinkModal}
- setOpen={(open: boolean) => {
- openLinkModalFunc(open);
- }}
- onSubmit={handleLinkOrEditSubmit}
- />
- </div>
- );
-};
-export default LinkDataPipeline;
diff --git a/web/src/pages/dataset/setting/python/components/link-data-pipline-modal.tsx b/web/src/pages/dataset/setting/python/components/link-data-pipline-modal.tsx
deleted file mode 100644
index a84fb0561e..0000000000
--- a/web/src/pages/dataset/setting/python/components/link-data-pipline-modal.tsx
+++ /dev/null
@@ -1,163 +0,0 @@
-import {
- DataFlowSelect,
- IDataPipelineSelectNode,
-} from '@/components/data-pipeline-select';
-import { Button } from '@/components/ui/button';
-import { Form } from '@/components/ui/form';
-import { Modal } from '@/components/ui/modal/modal';
-import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks';
-import { zodResolver } from '@hookform/resolvers/zod';
-import { t } from 'i18next';
-import { useState } from 'react';
-import { useForm } from 'react-hook-form';
-import { z } from 'zod';
-import { pipelineFormSchema } from '../form-schema';
-import { IDataPipelineNodeProps } from './link-data-pipeline';
-
-const LinkDataPipelineModal = ({
- data,
- open,
- setOpen,
- onSubmit,
-}: {
- data: IDataPipelineNodeProps | undefined;
- open: boolean;
- setOpen: (open: boolean) => void;
- onSubmit?: (pipeline: IDataPipelineSelectNode | undefined) => void;
-}) => {
- const isEdit = !!data;
- const [list, setList] = useState<IDataPipelineSelectNode[]>();
- const form = useForm<z.infer<typeof pipelineFormSchema>>({
- resolver: zodResolver(pipelineFormSchema),
- defaultValues: {
- pipeline_id: '',
- set_default: false,
- file_filter: '',
- },
- });
- // const [open, setOpen] = useState(false);
- const { navigateToAgents } = useNavigatePage();
- const handleFormSubmit = (values: any) => {
- console.log(values, data);
- // const param = {
- // ...data,
- // ...values,
- // };
- const pipeline = list?.find((item) => item.id === values.pipeline_id);
- onSubmit?.(pipeline);
- };
- return (
- <Modal
- className="!w-[560px]"
- title={
- !isEdit
- ? t('knowledgeConfiguration.linkDataPipeline')
- : t('knowledgeConfiguration.editLinkDataPipeline')
- }
- open={open}
- onOpenChange={setOpen}
- showfooter={false}
- >
- <Form {...form}>
- <form onSubmit={form.handleSubmit(handleFormSubmit)}>
- <div className="flex flex-col gap-4 ">
- {!isEdit && (
- <DataFlowSelect
- toDataPipeline={navigateToAgents}
- formFieldName="pipeline_id"
- setDataList={setList}
- />
- )}
- {/* <FormField
- control={form.control}
- name={'file_filter'}
- render={({ field }) => (
- <FormItem className=" items-center space-y-0 ">
- <div className="flex flex-col gap-1">
- <div className="flex gap-2 justify-between ">
- <FormLabel
- tooltip={t('knowledgeConfiguration.fileFilterTip')}
- className="text-sm text-text-primary whitespace-wrap "
- >
- {t('knowledgeConfiguration.fileFilter')}
- </FormLabel>
- </div>
-
- <div className="text-muted-foreground">
- <FormControl>
- <Input
- placeholder={t(
- 'knowledgeConfiguration.filterPlaceholder',
- )}
- {...field}
- />
- </FormControl>
- </div>
- </div>
- <div className="flex pt-1">
- <div className="w-full"></div>
- <FormMessage />
- </div>
- </FormItem>
- )}
- />
- {isEdit && (
- <FormField
- control={form.control}
- name={'set_default'}
- render={({ field }) => (
- <FormItem className=" items-center space-y-0 ">
- <div className="flex flex-col gap-1">
- <div className="flex gap-2 justify-between ">
- <FormLabel
- tooltip={t('knowledgeConfiguration.setDefaultTip')}
- className="text-sm text-text-primary whitespace-wrap "
- >
- {t('knowledgeConfiguration.setDefault')}
- </FormLabel>
- </div>
-
- <div className="text-muted-foreground">
- <FormControl>
- <Switch
- value={field.value}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- </div>
- </div>
- <div className="flex pt-1">
- <div className="w-full"></div>
- <FormMessage />
- </div>
- </FormItem>
- )}
- />
- )} */}
- <div className="flex justify-end gap-1">
- <Button
- type="button"
- variant={'outline'}
- className="btn-primary"
- onClick={() => {
- setOpen(false);
- }}
- >
- {t('modal.cancelText')}
- </Button>
- <Button
- type="button"
- variant={'default'}
- className="btn-primary"
- onClick={form.handleSubmit(handleFormSubmit)}
- >
- {t('modal.okText')}
- </Button>
- </div>
- </div>
- </form>
- </Form>
- </Modal>
- );
-};
-export default LinkDataPipelineModal;
diff --git a/web/src/pages/dataset/setting/python/components/link-data-source-modal.tsx b/web/src/pages/dataset/setting/python/components/link-data-source-modal.tsx
deleted file mode 100644
index 978cf15408..0000000000
--- a/web/src/pages/dataset/setting/python/components/link-data-source-modal.tsx
+++ /dev/null
@@ -1,86 +0,0 @@
-import { Button } from '@/components/ui/button';
-import { SearchInput } from '@/components/ui/input';
-import { Modal } from '@/components/ui/modal/modal';
-import { IConnector } from '@/interfaces/database/dataset';
-import { useListDataSource } from '@/pages/user-setting/data-source/hooks';
-import { IDataSourceBase } from '@/pages/user-setting/data-source/interface';
-import { t } from 'i18next';
-import { useEffect, useState } from 'react';
-import { AddedSourceCard } from './added-source-card';
-
-const LinkDataSourceModal = ({
- selectedList,
- open,
- setOpen,
- onSubmit,
-}: {
- selectedList: IConnector[];
- open: boolean;
- setOpen: (open: boolean) => void;
- onSubmit?: (list: IDataSourceBase[] | undefined) => void;
-}) => {
- const [list, setList] = useState<IDataSourceBase[]>();
- const [fileterString, setFileterString] = useState('');
-
- useEffect(() => {
- setList(selectedList);
- }, [selectedList]);
-
- const { categorizedList } = useListDataSource();
- const handleFormSubmit = (values: any) => {
- console.log(values, selectedList);
- onSubmit?.(list);
- };
- return (
- <Modal
- className="!w-[560px]"
- title={t('knowledgeConfiguration.linkDataSource')}
- open={open}
- onCancel={() => {
- setList(selectedList);
- }}
- onOpenChange={setOpen}
- showfooter={false}
- >
- <div className="flex flex-col gap-4 ">
- {/* {JSON.stringify(selectedList)} */}
- <SearchInput
- value={fileterString}
- onChange={(e) => setFileterString(e.target.value)}
- />
- <div className="flex flex-col gap-3">
- {categorizedList.map((item, index) => (
- <AddedSourceCard
- key={index}
- selectedList={list as IDataSourceBase[]}
- setSelectedList={(list) => setList(list)}
- filterString={fileterString}
- {...item}
- />
- ))}
- </div>
- <div className="flex justify-end gap-1">
- <Button
- type="button"
- variant={'outline'}
- className="btn-primary"
- onClick={() => {
- setOpen(false);
- }}
- >
- {t('modal.cancelText')}
- </Button>
- <Button
- type="button"
- variant={'default'}
- className="btn-primary"
- onClick={handleFormSubmit}
- >
- {t('modal.okText')}
- </Button>
- </div>
- </div>
- </Modal>
- );
-};
-export default LinkDataSourceModal;
diff --git a/web/src/pages/dataset/setting/python/components/link-data-source.tsx b/web/src/pages/dataset/setting/python/components/link-data-source.tsx
deleted file mode 100644
index a859568e5e..0000000000
--- a/web/src/pages/dataset/setting/python/components/link-data-source.tsx
+++ /dev/null
@@ -1,233 +0,0 @@
-import { IconFontFill } from '@/components/icon-font';
-import { Button } from '@/components/ui/button';
-import { Switch } from '@/components/ui/switch';
-import {
- Tooltip,
- TooltipContent,
- TooltipTrigger,
-} from '@/components/ui/tooltip';
-import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks';
-import { IConnector } from '@/interfaces/database/dataset';
-import { delSourceModal } from '@/pages/user-setting/data-source/component/delete-source-modal';
-import { useDataSourceInfo } from '@/pages/user-setting/data-source/constant';
-import { useDataSourceRebuild } from '@/pages/user-setting/data-source/hooks';
-import { IDataSourceBase } from '@/pages/user-setting/data-source/interface';
-import { Link, Settings, Unlink } from 'lucide-react';
-import { useMemo, useState } from 'react';
-import { useTranslation } from 'react-i18next';
-import LinkDataSourceModal from './link-data-source-modal';
-
-export type IDataSourceNodeProps = IConnector & {
- icon: React.ReactNode;
-};
-
-export interface ILinkDataSourceProps {
- data?: IConnector[];
- handleLinkOrEditSubmit?: (data: IDataSourceBase[] | undefined) => void;
- unbindFunc?: (item: DataSourceItemProps) => void;
- handleAutoParse?: (option: {
- source_id: string;
- isAutoParse: boolean;
- }) => void;
-}
-
-interface DataSourceItemProps extends IDataSourceNodeProps {
- openLinkModalFunc?: (open: boolean, data?: IDataSourceNodeProps) => void;
- unbindFunc?: (item: DataSourceItemProps) => void;
- handleAutoParse?: (option: {
- source_id: string;
- isAutoParse: boolean;
- }) => void;
-}
-
-const DataSourceItem = (props: DataSourceItemProps) => {
- const { dataSourceInfo } = useDataSourceInfo();
- const { t } = useTranslation();
- const { id, name, icon, source, auto_parse, unbindFunc, handleAutoParse } =
- props;
-
- const { navigateToDataSourceDetail } = useNavigatePage();
- const { handleRebuild } = useDataSourceRebuild();
- const toDetail = (id: string) => {
- navigateToDataSourceDetail(id);
- };
-
- return (
- <div className="flex items-center justify-between gap-1 px-2 h-10 rounded-md border group hover:bg-bg-card">
- <div className="flex items-center gap-1">
- <div className="w-6 h-6 flex-shrink-0">{icon}</div>
- <div className="text-base text-text-primary">
- {dataSourceInfo[source].name}
- </div>
- <div>{name}</div>
- </div>
- <div className="flex items-center ">
- <div className="items-center gap-1 hidden mr-5 group-hover:flex">
- <div className="text-xs text-text-secondary">
- {t('knowledgeConfiguration.autoParse')}
- </div>
- <Switch
- checked={auto_parse === '1'}
- onCheckedChange={(isAutoParse) => {
- handleAutoParse?.({ source_id: id, isAutoParse });
- }}
- className="w-8 h-4"
- />
- </div>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- variant={'transparent'}
- className="border-none hidden group-hover:block"
- type="button"
- onClick={() => {
- handleRebuild({ source_id: id });
- }}
- >
- <IconFontFill name="reparse" className="text-text-primary" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- {t('knowledgeConfiguration.rebuildTip')}
- </TooltipContent>
- </Tooltip>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- variant={'transparent'}
- className="border-none hidden group-hover:block"
- type="button"
- onClick={() => {
- toDetail(id);
- }}
- >
- <Settings />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- {t('knowledgeConfiguration.settings')}
- </TooltipContent>
- </Tooltip>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- type="button"
- variant={'transparent'}
- className="border-none hidden group-hover:block"
- onClick={() => {
- delSourceModal({
- data: props,
- type: 'unlink',
- dataSourceInfo: dataSourceInfo,
- onOk: (data) => unbindFunc?.(data as DataSourceItemProps),
- });
- }}
- >
- <Unlink />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- {t('dataflowParser.unlinkSourceModalConfirmText')}
- </TooltipContent>
- </Tooltip>
- </div>
- </div>
- );
-};
-
-const LinkDataSource = (props: ILinkDataSourceProps) => {
- const {
- data,
- handleLinkOrEditSubmit: submit,
- unbindFunc,
- handleAutoParse,
- } = props;
- const { t } = useTranslation();
- const { dataSourceInfo } = useDataSourceInfo();
- const [openLinkModal, setOpenLinkModal] = useState(false);
-
- const pipelineNode: IDataSourceNodeProps[] = useMemo(() => {
- if (data && data.length > 0) {
- return data.map((item) => {
- return {
- ...item,
- id: item?.id,
- name: item?.name,
- icon:
- dataSourceInfo[item?.source as keyof typeof dataSourceInfo]?.icon ||
- '',
- } as IDataSourceNodeProps;
- });
- }
- return [];
- }, [data]);
-
- const openLinkModalFunc = (open: boolean, data?: IDataSourceNodeProps) => {
- console.log('open', open, data);
- setOpenLinkModal(open);
- // if (data) {
- // setCurrentDataSource(data);
- // } else {
- // setCurrentDataSource(undefined);
- // }
- };
-
- const handleLinkOrEditSubmit = (data: IDataSourceBase[] | undefined) => {
- console.log('handleLinkOrEditSubmit', data);
- submit?.(data);
- setOpenLinkModal(false);
- };
-
- return (
- <div className="flex flex-col gap-2">
- <section className="flex flex-col">
- <div className="text-base font-medium text-text-primary">
- {t('knowledgeConfiguration.dataSource')}
- </div>
- {/* <div className="flex items-center gap-1 text-text-primary text-sm">
- {t('knowledgeConfiguration.dataSource')}
- </div> */}
- <div className="flex justify-between items-center">
- <div className="text-center text-xs text-text-secondary">
- {t('knowledgeConfiguration.linkSourceSetTip')}
- </div>
- <Button
- type="button"
- variant={'transparent'}
- onClick={() => {
- openLinkModalFunc?.(true);
- }}
- >
- <Link />
- <span className="text-xs text-text-primary">
- {t('knowledgeConfiguration.linkDataSource')}
- </span>
- </Button>
- </div>
- </section>
- <section className="flex flex-col gap-2">
- {pipelineNode.map(
- (item) =>
- item.id && (
- <DataSourceItem
- key={item.id}
- openLinkModalFunc={openLinkModalFunc}
- unbindFunc={unbindFunc}
- handleAutoParse={handleAutoParse}
- {...item}
- />
- ),
- )}
- </section>
- <LinkDataSourceModal
- selectedList={data as IConnector[]}
- open={openLinkModal}
- setOpen={(open: boolean) => {
- openLinkModalFunc(open);
- }}
- onSubmit={handleLinkOrEditSubmit}
- />
- </div>
- );
-};
-export default LinkDataSource;
diff --git a/web/src/pages/dataset/setting/python/components/tag-item.tsx b/web/src/pages/dataset/setting/python/components/tag-item.tsx
deleted file mode 100644
index 6324c1f2c4..0000000000
--- a/web/src/pages/dataset/setting/python/components/tag-item.tsx
+++ /dev/null
@@ -1,124 +0,0 @@
-import { RAGFlowAvatar } from '@/components/ragflow-avatar';
-import { SliderInputFormField } from '@/components/slider-input-form-field';
-import {
- FormControl,
- FormField,
- FormItem,
- FormLabel,
- FormMessage,
-} from '@/components/ui/form';
-import { MultiSelect } from '@/components/ui/multi-select';
-import { FormLayout } from '@/constants/form';
-import { useFetchKnowledgeList } from '@/hooks/use-knowledge-request';
-import { useDebounce } from 'ahooks';
-import DOMPurify from 'dompurify';
-import { useState } from 'react';
-import { useFormContext, useWatch } from 'react-hook-form';
-import { useTranslation } from 'react-i18next';
-
-export const TagSetItem = () => {
- const { t } = useTranslation();
- const form = useFormContext();
-
- const [searchString, setSearchString] = useState('');
- const debouncedSearchString = useDebounce(searchString, { wait: 500 });
-
- const {
- list: knowledgeList,
- handleScroll,
- hasNextPage,
- loading,
- } = useFetchKnowledgeList(true, debouncedSearchString);
-
- const knowledgeOptions = knowledgeList
- .filter((x) => x.chunk_method === 'tag')
- .map((x) => ({
- label: x.name,
- value: x.id,
- icon: () => (
- <RAGFlowAvatar
- name={x.name}
- avatar={x.avatar}
- className="size-4"
- ></RAGFlowAvatar>
- ),
- }));
-
- return (
- <FormField
- control={form.control}
- name="parser_config.tag_kb_ids"
- render={({ field }) => (
- <FormItem className=" items-center space-y-0 ">
- <div className="flex items-center">
- <FormLabel
- className="text-sm text-text-secondary whitespace-nowrap w-1/4"
- tooltip={
- <div
- dangerouslySetInnerHTML={{
- __html: DOMPurify.sanitize(
- t('knowledgeConfiguration.tagSetTip'),
- ),
- }}
- ></div>
- }
- >
- {t('knowledgeConfiguration.tagSet')}
- </FormLabel>
- <div className="w-3/4">
- <FormControl>
- <MultiSelect
- options={knowledgeOptions}
- onValueChange={field.onChange}
- searchValue={searchString}
- onSearchChange={setSearchString}
- isSearching={loading}
- shouldFilter={false}
- onListScroll={hasNextPage ? handleScroll : undefined}
- // placeholder={t('chat.knowledgeBasesMessage')}
- variant="inverted"
- maxCount={10}
- {...field}
- />
- </FormControl>
- </div>
- </div>
- <div className="flex pt-1">
- <div className="w-1/4"></div>
- <FormMessage />
- </div>
- </FormItem>
- )}
- />
- );
-};
-
-export const TopNTagsItem = () => {
- const { t } = useTranslation();
-
- return (
- <SliderInputFormField
- name={'parser_config.topn_tags'}
- label={t('knowledgeConfiguration.topnTags')}
- max={10}
- min={1}
- defaultValue={3}
- layout={FormLayout.Horizontal}
- ></SliderInputFormField>
- );
-};
-
-export function TagItems() {
- const form = useFormContext();
- const ids: string[] = useWatch({
- control: form.control,
- name: 'parser_config.tag_kb_ids',
- });
-
- return (
- <>
- <TagSetItem></TagSetItem>
- {Array.isArray(ids) && ids.length > 0 && <TopNTagsItem></TopNTagsItem>}
- </>
- );
-}
diff --git a/web/src/pages/dataset/setting/python/configuration-form-container.tsx b/web/src/pages/dataset/setting/python/configuration-form-container.tsx
deleted file mode 100644
index f262e3ea82..0000000000
--- a/web/src/pages/dataset/setting/python/configuration-form-container.tsx
+++ /dev/null
@@ -1,17 +0,0 @@
-import { FormContainerProps } from '@/components/form-container';
-import { cn } from '@/lib/utils';
-import { PropsWithChildren } from 'react';
-
-export function ConfigurationFormContainer({
- children,
- className,
-}: FormContainerProps) {
- return <section className={cn('space-y-4', className)}>{children}</section>;
-}
-
-export function MainContainer({
- children,
- className,
-}: PropsWithChildren & { className?: string }) {
- return <section className={cn('space-y-5', className)}>{children}</section>;
-}
diff --git a/web/src/pages/dataset/setting/python/configuration/audio.tsx b/web/src/pages/dataset/setting/python/configuration/audio.tsx
deleted file mode 100644
index 03ebfc01e6..0000000000
--- a/web/src/pages/dataset/setting/python/configuration/audio.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-import {
- AutoKeywordsFormField,
- AutoQuestionsFormField,
-} from '@/components/auto-keywords-form-field';
-import { ConfigurationFormContainer } from '../configuration-form-container';
-import { AutoMetadata, GlobalIndexModelItem } from './common-item';
-import { FormLayout } from '@/constants/form';
-
-export function AudioConfiguration() {
- return (
- <ConfigurationFormContainer>
- <>
- <GlobalIndexModelItem />
- <AutoMetadata />
- <AutoKeywordsFormField
- layout={FormLayout.Horizontal}
- ></AutoKeywordsFormField>
- <AutoQuestionsFormField
- layout={FormLayout.Horizontal}
- ></AutoQuestionsFormField>
- </>
-
- {/* <TagItems></TagItems> */}
- </ConfigurationFormContainer>
- );
-}
diff --git a/web/src/pages/dataset/setting/python/configuration/book.tsx b/web/src/pages/dataset/setting/python/configuration/book.tsx
deleted file mode 100644
index 1f36008f34..0000000000
--- a/web/src/pages/dataset/setting/python/configuration/book.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import {
- AutoKeywordsFormField,
- AutoQuestionsFormField,
-} from '@/components/auto-keywords-form-field';
-import { LayoutRecognizeFormField } from '@/components/layout-recognize-form-field';
-import {
- ConfigurationFormContainer,
- MainContainer,
-} from '../configuration-form-container';
-import { useOwnerTenantId } from '../../../contexts/knowledge-base-context';
-import { AutoMetadata, GlobalIndexModelItem } from './common-item';
-import { FormLayout } from '@/constants/form';
-
-export function BookConfiguration() {
- const ownerTenantId = useOwnerTenantId();
- return (
- <MainContainer>
- <ConfigurationFormContainer>
- <LayoutRecognizeFormField
- ownerTenantId={ownerTenantId}
- ></LayoutRecognizeFormField>
- <GlobalIndexModelItem />
- </ConfigurationFormContainer>
-
- <ConfigurationFormContainer>
- <AutoMetadata />
- <AutoKeywordsFormField
- layout={FormLayout.Horizontal}
- ></AutoKeywordsFormField>
- <AutoQuestionsFormField
- layout={FormLayout.Horizontal}
- ></AutoQuestionsFormField>
- </ConfigurationFormContainer>
- {/* <ConfigurationFormContainer>
- <TagItems></TagItems>
- </ConfigurationFormContainer> */}
- </MainContainer>
- );
-}
diff --git a/web/src/pages/dataset/setting/python/configuration/common-item.tsx b/web/src/pages/dataset/setting/python/configuration/common-item.tsx
deleted file mode 100644
index 9425431609..0000000000
--- a/web/src/pages/dataset/setting/python/configuration/common-item.tsx
+++ /dev/null
@@ -1,474 +0,0 @@
-import {
- FormFieldConfig,
- FormFieldType,
- RenderField,
-} from '@/components/dynamic-form';
-import { ModelTreeSelect, ModelTypeMap } from '@/components/model-tree-select';
-import { SelectWithSearch } from '@/components/originui/select-with-search';
-import { SliderInputFormField } from '@/components/slider-input-form-field';
-import { Button } from '@/components/ui/button';
-import {
- FormControl,
- FormField,
- FormItem,
- FormLabel,
- FormMessage,
-} from '@/components/ui/form';
-import { Switch } from '@/components/ui/switch';
-import { useTranslate } from '@/hooks/common-hooks';
-import { cn } from '@/lib/utils';
-import { history } from '@/utils/simple-history-util';
-import { t } from 'i18next';
-import { Settings } from 'lucide-react';
-import { useCallback, useContext, useEffect } from 'react';
-import {
- ControllerRenderProps,
- FieldValues,
- useFormContext,
-} from 'react-hook-form';
-import { useLocation } from 'react-router';
-import { DataSetContext } from '..';
-import { MetadataType } from '../../../components/metedata/constant';
-import {
- useManageMetadata,
- util,
-} from '../../../components/metedata/hooks/use-manage-modal';
-
-import { RAGFlowAvatar } from '@/components/ragflow-avatar';
-import {
- IBuiltInMetadataItem,
- IMetaDataReturnJSONSettings,
-} from '../../../components/metedata/interface';
-import { ManageMetadataModal } from '../../../components/metedata/manage-modal';
-import {
- useOwnerTenantId,
- useKnowledgeBaseContext,
-} from '../../../contexts/knowledge-base-context';
-import { EmbeddingSelect } from '../../embedding-select';
-import { useHasParsedDocument, useSelectChunkMethodList } from '../hooks';
-interface IProps {
- line?: 1 | 2;
- isEdit?: boolean;
- label?: string;
- name?: string;
-}
-export function ChunkMethodItem(props: IProps) {
- const { line, name = 'parser_id' } = props;
- const { t } = useTranslate('knowledgeConfiguration');
- const form = useFormContext();
- const parserList = useSelectChunkMethodList();
-
- return (
- <FormField
- control={form.control}
- name={name}
- render={({ field }) => (
- <FormItem className="items-center gap-1">
- <div
- className={line === 1 ? 'flex items-center' : 'flex flex-col gap-1'}
- >
- <FormLabel
- required
- tooltip={t('chunkMethodTip')}
- className={cn('text-sm', {
- 'w-1/4 whitespace-pre-wrap': line === 1,
- })}
- >
- {t('builtIn')}
- </FormLabel>
- <div className={line === 1 ? 'w-3/4' : 'w-full'}>
- <FormControl>
- <SelectWithSearch
- {...field}
- options={parserList}
- placeholder={t('chunkMethodPlaceholder')}
- />
- </FormControl>
- </div>
- </div>
- <div className="flex pt-1">
- <div className={line === 1 ? 'w-1/4' : ''}></div>
- <FormMessage />
- </div>
- </FormItem>
- )}
- />
- );
-}
-
-export function EmbeddingModelItem({
- line = 1,
- isEdit,
- ownerTenantId,
-}: IProps & { ownerTenantId?: string }) {
- const { t } = useTranslate('knowledgeConfiguration');
- const form = useFormContext();
- const disabled = useHasParsedDocument(isEdit);
- return (
- <>
- <FormField
- control={form.control}
- name={'embedding_model'}
- render={({ field }) => (
- <FormItem className={cn('items-center space-y-0')}>
- <div
- className={cn('flex', {
- 'items-center': line === 1,
- 'flex-col gap-1': line === 2,
- })}
- >
- <FormLabel
- required
- tooltip={t('embeddingModelTip')}
- className={cn('text-sm whitespace-wrap', {
- 'w-1/4': line === 1,
- })}
- >
- {t('embeddingModel')}
- </FormLabel>
- <div className={cn('text-text-primary', { 'w-3/4': line === 1 })}>
- <FormControl>
- <EmbeddingSelect
- isEdit={!!isEdit}
- field={field}
- disabled={disabled}
- testId="ds-settings-basic-embedding-model-select"
- ownerTenantId={ownerTenantId}
- ></EmbeddingSelect>
- </FormControl>
- </div>
- </div>
- <div className="flex pt-1">
- <div className={line === 1 ? 'w-1/4' : ''}></div>
- <FormMessage />
- </div>
- </FormItem>
- )}
- />
- </>
- );
-}
-
-export function EnableAutoGenerateItem() {
- const { t } = useTranslate('knowledgeConfiguration');
- const form = useFormContext();
-
- return (
- <FormField
- control={form.control}
- name={'enableAutoGenerate'}
- render={({ field }) => (
- <FormItem className="items-center space-y-0">
- <div className="flex items-center">
- <FormLabel
- tooltip={t('enableAutoGenerateTip')}
- className="text-sm whitespace-wrap w-1/4"
- >
- {t('enableAutoGenerate')}
- </FormLabel>
- <div className="text-muted-foreground w-3/4">
- <FormControl>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- </div>
- </div>
- <div className="flex pt-1">
- <div className="w-1/4"></div>
- <FormMessage />
- </div>
- </FormItem>
- )}
- />
- );
-}
-
-export function ImageContextWindow() {
- const { t } = useTranslate('knowledgeConfiguration');
- const form = useFormContext();
-
- return (
- <FormField
- control={form.control}
- name="parser_config.image_table_context_window"
- render={({ field }) => (
- <FormItem>
- <FormControl>
- <SliderInputFormField
- {...field}
- label={t('imageTableContextWindow')}
- tooltip={t('imageTableContextWindowTip')}
- defaultValue={0}
- min={0}
- max={256}
- sliderTestId="ds-settings-parser-image-table-context-window-slider"
- numberInputTestId="ds-settings-parser-image-table-context-window-input"
- />
- </FormControl>
- <div className="flex pt-1">
- <div className="w-1/4"></div>
- <FormMessage />
- </div>
- </FormItem>
- )}
- />
- );
-}
-
-export function OverlappedPercent() {
- return (
- <SliderInputFormField
- percentage={true}
- name="parser_config.overlapped_percent"
- label={t('knowledgeConfiguration.overlappedPercent')}
- tooltip={t('knowledgeConfiguration.overlappedPercentTip')}
- max={0.3}
- step={0.01}
- sliderTestId="ds-settings-parser-overlapped-percent-slider"
- numberInputTestId="ds-settings-parser-overlapped-percent-input"
- ></SliderInputFormField>
- );
-}
-
-export function AutoMetadata({
- type = MetadataType.Setting,
- otherData,
-}: {
- type?: MetadataType;
- otherData?: Record<string, any>;
-}) {
- // get metadata field
- const location = useLocation();
- const form = useFormContext();
- const datasetContext = useContext(DataSetContext);
- const { knowledgeBase } = useKnowledgeBaseContext();
- const {
- manageMetadataVisible,
- showManageMetadataModal,
- hideManageMetadataModal,
- tableData,
- config: metadataConfig,
- } = useManageMetadata();
-
- const handleClickOpenMetadata = useCallback(() => {
- const metadata = form.getValues('parser_config.metadata');
- const builtInMetadata = form.getValues('parser_config.built_in_metadata');
- const tableMetaData = util.metaDataSettingJSONToMetaDataTableData(metadata);
- showManageMetadataModal({
- metadata: tableMetaData,
- isCanAdd: true,
- type: type,
- record: otherData,
- builtInMetadata,
- secondTitle: knowledgeBase ? (
- <div className="w-full flex items-center gap-1 text-sm text-text-secondary">
- <RAGFlowAvatar
- avatar={knowledgeBase.avatar}
- name={knowledgeBase.name}
- className="size-8"
- />
- <div className="text-text-primary text-base space-y-1 truncate overflow-hidden">
- {knowledgeBase.name}
- </div>
- </div>
- ) : (
- <></>
- ),
- });
- }, [form, otherData, showManageMetadataModal, knowledgeBase, type]);
-
- useEffect(() => {
- const locationState = location.state as
- | { openMetadata?: boolean }
- | undefined;
- if (locationState?.openMetadata && !datasetContext?.loading) {
- const timer = setTimeout(() => {
- handleClickOpenMetadata();
- clearTimeout(timer);
- }, 0);
- locationState.openMetadata = false;
- history.replace({ ...location }, locationState);
- }
- }, [location, handleClickOpenMetadata, datasetContext]);
-
- const autoMetadataField: FormFieldConfig = {
- name: 'parser_config.enable_metadata',
- label: t('knowledgeConfiguration.autoMetadata'),
- type: FormFieldType.Custom,
- horizontal: true,
- defaultValue: true,
- tooltip: t('knowledgeConfiguration.autoMetadataTip'),
- render: (fieldProps: ControllerRenderProps) => (
- <div className="flex items-center justify-between">
- <Button
- type="button"
- variant="ghost"
- onClick={handleClickOpenMetadata}
- data-testid="ds-settings-metadata-open-modal-btn"
- >
- <div className="flex items-center gap-2">
- <Settings />
- {t('knowledgeConfiguration.settings')}
- </div>
- </Button>
- <Switch
- checked={fieldProps.value}
- onCheckedChange={fieldProps.onChange}
- data-testid="ds-settings-metadata-switch"
- />
- </div>
- ),
- };
-
- const handleSaveMetadata = (data?: {
- metadata?: IMetaDataReturnJSONSettings;
- builtInMetadata?: IBuiltInMetadataItem[];
- }) => {
- form.setValue('parser_config.metadata', data?.metadata || []);
- form.setValue(
- 'parser_config.built_in_metadata',
- data?.builtInMetadata || [],
- );
- form.setValue('parser_config.enable_metadata', true);
- };
- return (
- <>
- <RenderField field={autoMetadataField} />
- {manageMetadataVisible && (
- <ManageMetadataModal
- title={
- metadataConfig.title || (
- <div className="flex flex-col gap-2">
- <div className="text-base font-normal">
- {t('knowledgeDetails.metadata.metadataGenerationSettings')}
- </div>
- <div className="text-sm text-text-secondary">
- {t('knowledgeDetails.metadata.changesAffectNewParses')}
- </div>
- </div>
- )
- }
- visible={manageMetadataVisible}
- hideModal={hideManageMetadataModal}
- // selectedRowKeys={selectedRowKeys}
- tableData={tableData}
- isCanAdd={metadataConfig.isCanAdd}
- isDeleteSingleValue={metadataConfig.isDeleteSingleValue}
- type={metadataConfig.type}
- otherData={metadataConfig.record}
- isShowDescription={true}
- isShowValueSwitch={true}
- isVerticalShowValue={false}
- builtInMetadata={metadataConfig.builtInMetadata}
- secondTitle={metadataConfig.secondTitle}
- success={(data?: {
- metadata?: IMetaDataReturnJSONSettings;
- builtInMetadata?: IBuiltInMetadataItem[];
- }) => {
- handleSaveMetadata(data);
- }}
- testId="ds-settings-metadata-modal"
- okButtonTestId="ds-settings-metadata-modal-save-btn"
- addButtonTestId="ds-settings-metadata-add-btn"
- nestedModalTestId="ds-settings-metadata-add-modal"
- nestedModalOkButtonTestId="ds-settings-metadata-add-modal-confirm-btn"
- />
- )}
- </>
- );
-}
-
-export const LLMSelect = ({
- isEdit,
- field,
- disabled = false,
- ownerTenantId,
-}: {
- isEdit: boolean;
- field: FieldValues;
- name?: string;
- disabled?: boolean;
- ownerTenantId?: string;
-}) => {
- const { t } = useTranslate('knowledgeConfiguration');
- return (
- <ModelTreeSelect
- modelTypes={ModelTypeMap.llm_id}
- onChange={(value) => {
- field.onChange(value);
- }}
- disabled={disabled && !isEdit}
- value={field.value}
- placeholder={t('embeddingModelPlaceholder')}
- ownerTenantId={ownerTenantId}
- />
- );
-};
-
-export function LLMModelItem({
- line = 1,
- isEdit,
- label,
- name,
- ownerTenantId,
-}: IProps & { ownerTenantId?: string }) {
- const { t } = useTranslate('knowledgeConfiguration');
- const form = useFormContext();
- // const disabled = useHasParsedDocument(isEdit);
- return (
- <>
- <FormField
- control={form.control}
- name={name ?? 'llm_id'}
- render={({ field }) => (
- <FormItem className={cn('items-center space-y-0')}>
- <div
- className={cn('flex', {
- 'items-center': line === 1,
- 'flex-col gap-1': line === 2,
- })}
- >
- <FormLabel
- tooltip={t('globalIndexModelTip')}
- className={cn('text-sm whitespace-wrap ', {
- 'w-1/4': line === 1,
- })}
- >
- {label ?? t('llmModel')}
- </FormLabel>
- <div className={cn('text-text-primary', { 'w-3/4': line === 1 })}>
- <FormControl>
- <LLMSelect
- isEdit={!!isEdit}
- field={field}
- disabled={false}
- ownerTenantId={ownerTenantId}
- ></LLMSelect>
- </FormControl>
- </div>
- </div>
- <div className="flex pt-1">
- <div className={line === 1 ? 'w-1/4' : ''}></div>
- <FormMessage />
- </div>
- </FormItem>
- )}
- />
- </>
- );
-}
-
-export function GlobalIndexModelItem() {
- const { t } = useTranslate('knowledgeConfiguration');
- const ownerTenantId = useOwnerTenantId();
- return (
- <LLMModelItem
- isEdit={true}
- name="parser_config.llm_id"
- label={t('globalIndexModel')}
- ownerTenantId={ownerTenantId}
- />
- );
-}
diff --git a/web/src/pages/dataset/setting/python/configuration/email.tsx b/web/src/pages/dataset/setting/python/configuration/email.tsx
deleted file mode 100644
index c7484ecbf2..0000000000
--- a/web/src/pages/dataset/setting/python/configuration/email.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-import {
- AutoKeywordsFormField,
- AutoQuestionsFormField,
-} from '@/components/auto-keywords-form-field';
-import { ConfigurationFormContainer } from '../configuration-form-container';
-import { AutoMetadata, GlobalIndexModelItem } from './common-item';
-import { FormLayout } from '@/constants/form';
-
-export function EmailConfiguration() {
- return (
- <ConfigurationFormContainer>
- <>
- <GlobalIndexModelItem />
- <AutoMetadata />
- <AutoKeywordsFormField
- layout={FormLayout.Horizontal}
- ></AutoKeywordsFormField>
- <AutoQuestionsFormField
- layout={FormLayout.Horizontal}
- ></AutoQuestionsFormField>
- </>
- {/* <TagItems></TagItems> */}
- </ConfigurationFormContainer>
- );
-}
diff --git a/web/src/pages/dataset/setting/python/configuration/knowledge-graph.tsx b/web/src/pages/dataset/setting/python/configuration/knowledge-graph.tsx
deleted file mode 100644
index d86130c0d0..0000000000
--- a/web/src/pages/dataset/setting/python/configuration/knowledge-graph.tsx
+++ /dev/null
@@ -1,17 +0,0 @@
-import { DelimiterFormField } from '@/components/delimiter-form-field';
-import { EntityTypesFormField } from '@/components/entity-types-form-field';
-import { MaxTokenNumberFormField } from '@/components/max-token-number-from-field';
-import { GlobalIndexModelItem } from './common-item';
-
-export function KnowledgeGraphConfiguration() {
- return (
- <>
- <>
- <GlobalIndexModelItem />
- <EntityTypesFormField></EntityTypesFormField>
- <MaxTokenNumberFormField max={8192 * 2}></MaxTokenNumberFormField>
- <DelimiterFormField></DelimiterFormField>
- </>
- </>
- );
-}
diff --git a/web/src/pages/dataset/setting/python/configuration/laws.tsx b/web/src/pages/dataset/setting/python/configuration/laws.tsx
deleted file mode 100644
index 25f5fa46b0..0000000000
--- a/web/src/pages/dataset/setting/python/configuration/laws.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import {
- AutoKeywordsFormField,
- AutoQuestionsFormField,
-} from '@/components/auto-keywords-form-field';
-import { LayoutRecognizeFormField } from '@/components/layout-recognize-form-field';
-import {
- ConfigurationFormContainer,
- MainContainer,
-} from '../configuration-form-container';
-import { useOwnerTenantId } from '../../../contexts/knowledge-base-context';
-import { AutoMetadata, GlobalIndexModelItem } from './common-item';
-import { FormLayout } from '@/constants/form';
-
-export function LawsConfiguration() {
- const ownerTenantId = useOwnerTenantId();
- return (
- <MainContainer>
- <ConfigurationFormContainer>
- <LayoutRecognizeFormField
- ownerTenantId={ownerTenantId}
- ></LayoutRecognizeFormField>
- <GlobalIndexModelItem />
- </ConfigurationFormContainer>
-
- <ConfigurationFormContainer>
- <AutoMetadata />
- <AutoKeywordsFormField
- layout={FormLayout.Horizontal}
- ></AutoKeywordsFormField>
- <AutoQuestionsFormField
- layout={FormLayout.Horizontal}
- ></AutoQuestionsFormField>
- </ConfigurationFormContainer>
-
- {/* <ConfigurationFormContainer>
- <TagItems></TagItems>
- </ConfigurationFormContainer> */}
- </MainContainer>
- );
-}
diff --git a/web/src/pages/dataset/setting/python/configuration/manual.tsx b/web/src/pages/dataset/setting/python/configuration/manual.tsx
deleted file mode 100644
index a0f604b95b..0000000000
--- a/web/src/pages/dataset/setting/python/configuration/manual.tsx
+++ /dev/null
@@ -1,38 +0,0 @@
-import {
- AutoKeywordsFormField,
- AutoQuestionsFormField,
-} from '@/components/auto-keywords-form-field';
-import { LayoutRecognizeFormField } from '@/components/layout-recognize-form-field';
-import {
- ConfigurationFormContainer,
- MainContainer,
-} from '../configuration-form-container';
-import { useOwnerTenantId } from '../../../contexts/knowledge-base-context';
-import { AutoMetadata, GlobalIndexModelItem } from './common-item';
-import { FormLayout } from '@/constants/form';
-
-export function ManualConfiguration() {
- const ownerTenantId = useOwnerTenantId();
- return (
- <MainContainer>
- <ConfigurationFormContainer>
- <LayoutRecognizeFormField
- ownerTenantId={ownerTenantId}
- ></LayoutRecognizeFormField>
- <GlobalIndexModelItem />
- </ConfigurationFormContainer>
-
- <ConfigurationFormContainer>
- <AutoMetadata />
- <AutoKeywordsFormField
- layout={FormLayout.Horizontal}
- ></AutoKeywordsFormField>
- <AutoQuestionsFormField
- layout={FormLayout.Horizontal}
- ></AutoQuestionsFormField>
- </ConfigurationFormContainer>
-
- {/* <TagItems></TagItems> */}
- </MainContainer>
- );
-}
diff --git a/web/src/pages/dataset/setting/python/configuration/naive.tsx b/web/src/pages/dataset/setting/python/configuration/naive.tsx
deleted file mode 100644
index ff79e9bcc7..0000000000
--- a/web/src/pages/dataset/setting/python/configuration/naive.tsx
+++ /dev/null
@@ -1,58 +0,0 @@
-import {
- AutoKeywordsFormField,
- AutoQuestionsFormField,
-} from '@/components/auto-keywords-form-field';
-import { ChildrenDelimiterForm } from '@/components/children-delimiter-form';
-import { DelimiterFormField } from '@/components/delimiter-form-field';
-import { ExcelToHtmlFormField } from '@/components/excel-to-html-form-field';
-import { LayoutRecognizeFormField } from '@/components/layout-recognize-form-field';
-import { MaxTokenNumberFormField } from '@/components/max-token-number-from-field';
-import {
- ConfigurationFormContainer,
- MainContainer,
-} from '../configuration-form-container';
-import { useOwnerTenantId } from '../../../contexts/knowledge-base-context';
-import {
- AutoMetadata,
- GlobalIndexModelItem,
- ImageContextWindow,
- OverlappedPercent,
-} from './common-item';
-import { FormLayout } from '@/constants/form';
-import { Separator } from '@/components/ui/separator';
-
-export function NaiveConfiguration() {
- const ownerTenantId = useOwnerTenantId();
- return (
- <MainContainer>
- <ConfigurationFormContainer>
- <LayoutRecognizeFormField
- testId="ds-settings-parser-pdf-parser-select"
- ownerTenantId={ownerTenantId}
- ></LayoutRecognizeFormField>
- <MaxTokenNumberFormField
- initialValue={512}
- sliderTestId="ds-settings-parser-recommended-chunk-size-slider"
- numberInputTestId="ds-settings-parser-recommended-chunk-size-input"
- ></MaxTokenNumberFormField>
- <OverlappedPercent />
- <DelimiterFormField></DelimiterFormField>
- <ChildrenDelimiterForm />
- <ImageContextWindow />
- <ExcelToHtmlFormField></ExcelToHtmlFormField>
- </ConfigurationFormContainer>
- <ConfigurationFormContainer>
- <Separator />
- <GlobalIndexModelItem />
- <AutoMetadata />
- <AutoKeywordsFormField
- layout={FormLayout.Horizontal}
- ></AutoKeywordsFormField>
- <AutoQuestionsFormField
- layout={FormLayout.Horizontal}
- ></AutoQuestionsFormField>
- {/* <TagItems></TagItems> */}
- </ConfigurationFormContainer>
- </MainContainer>
- );
-}
diff --git a/web/src/pages/dataset/setting/python/configuration/one.tsx b/web/src/pages/dataset/setting/python/configuration/one.tsx
deleted file mode 100644
index d234dca931..0000000000
--- a/web/src/pages/dataset/setting/python/configuration/one.tsx
+++ /dev/null
@@ -1,32 +0,0 @@
-import {
- AutoKeywordsFormField,
- AutoQuestionsFormField,
-} from '@/components/auto-keywords-form-field';
-import { LayoutRecognizeFormField } from '@/components/layout-recognize-form-field';
-import { ConfigurationFormContainer } from '../configuration-form-container';
-import { useOwnerTenantId } from '../../../contexts/knowledge-base-context';
-import { AutoMetadata, GlobalIndexModelItem } from './common-item';
-import { FormLayout } from '@/constants/form';
-
-export function OneConfiguration() {
- const ownerTenantId = useOwnerTenantId();
- return (
- <ConfigurationFormContainer>
- <LayoutRecognizeFormField
- ownerTenantId={ownerTenantId}
- ></LayoutRecognizeFormField>
- <GlobalIndexModelItem />
- <>
- <AutoMetadata />
- <AutoKeywordsFormField
- layout={FormLayout.Horizontal}
- ></AutoKeywordsFormField>
- <AutoQuestionsFormField
- layout={FormLayout.Horizontal}
- ></AutoQuestionsFormField>
- </>
-
- {/* <TagItems></TagItems> */}
- </ConfigurationFormContainer>
- );
-}
diff --git a/web/src/pages/dataset/setting/python/configuration/paper.tsx b/web/src/pages/dataset/setting/python/configuration/paper.tsx
deleted file mode 100644
index cdbe2c4563..0000000000
--- a/web/src/pages/dataset/setting/python/configuration/paper.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import {
- AutoKeywordsFormField,
- AutoQuestionsFormField,
-} from '@/components/auto-keywords-form-field';
-import { LayoutRecognizeFormField } from '@/components/layout-recognize-form-field';
-import {
- ConfigurationFormContainer,
- MainContainer,
-} from '../configuration-form-container';
-import { useOwnerTenantId } from '../../../contexts/knowledge-base-context';
-import { AutoMetadata, GlobalIndexModelItem } from './common-item';
-import { FormLayout } from '@/constants/form';
-
-export function PaperConfiguration() {
- const ownerTenantId = useOwnerTenantId();
- return (
- <MainContainer>
- <ConfigurationFormContainer>
- <LayoutRecognizeFormField
- ownerTenantId={ownerTenantId}
- ></LayoutRecognizeFormField>
- <GlobalIndexModelItem />
- </ConfigurationFormContainer>
-
- <ConfigurationFormContainer>
- <AutoMetadata />
- <AutoKeywordsFormField
- layout={FormLayout.Horizontal}
- ></AutoKeywordsFormField>
- <AutoQuestionsFormField
- layout={FormLayout.Horizontal}
- ></AutoQuestionsFormField>
- </ConfigurationFormContainer>
- {/* <ConfigurationFormContainer>
- <TagItems></TagItems>
- </ConfigurationFormContainer> */}
- </MainContainer>
- );
-}
diff --git a/web/src/pages/dataset/setting/python/configuration/picture.tsx b/web/src/pages/dataset/setting/python/configuration/picture.tsx
deleted file mode 100644
index 0f2aa62e84..0000000000
--- a/web/src/pages/dataset/setting/python/configuration/picture.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-import {
- AutoKeywordsFormField,
- AutoQuestionsFormField,
-} from '@/components/auto-keywords-form-field';
-import { ConfigurationFormContainer } from '../configuration-form-container';
-import { AutoMetadata, GlobalIndexModelItem } from './common-item';
-import { FormLayout } from '@/constants/form';
-
-export function PictureConfiguration() {
- return (
- <ConfigurationFormContainer>
- <>
- <GlobalIndexModelItem />
- <AutoMetadata />
- <AutoKeywordsFormField
- layout={FormLayout.Horizontal}
- ></AutoKeywordsFormField>
- <AutoQuestionsFormField
- layout={FormLayout.Horizontal}
- ></AutoQuestionsFormField>
- </>
- {/* <TagItems></TagItems> */}
- </ConfigurationFormContainer>
- );
-}
diff --git a/web/src/pages/dataset/setting/python/configuration/presentation.tsx b/web/src/pages/dataset/setting/python/configuration/presentation.tsx
deleted file mode 100644
index 6596bd24f9..0000000000
--- a/web/src/pages/dataset/setting/python/configuration/presentation.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import {
- AutoKeywordsFormField,
- AutoQuestionsFormField,
-} from '@/components/auto-keywords-form-field';
-import { LayoutRecognizeFormField } from '@/components/layout-recognize-form-field';
-import {
- ConfigurationFormContainer,
- MainContainer,
-} from '../configuration-form-container';
-import { useOwnerTenantId } from '../../../contexts/knowledge-base-context';
-import { AutoMetadata, GlobalIndexModelItem } from './common-item';
-import { FormLayout } from '@/constants/form';
-
-export function PresentationConfiguration() {
- const ownerTenantId = useOwnerTenantId();
- return (
- <MainContainer>
- <ConfigurationFormContainer>
- <LayoutRecognizeFormField
- ownerTenantId={ownerTenantId}
- ></LayoutRecognizeFormField>
- <GlobalIndexModelItem />
- </ConfigurationFormContainer>
-
- <ConfigurationFormContainer>
- <AutoMetadata />
- <AutoKeywordsFormField
- layout={FormLayout.Horizontal}
- ></AutoKeywordsFormField>
- <AutoQuestionsFormField
- layout={FormLayout.Horizontal}
- ></AutoQuestionsFormField>
- </ConfigurationFormContainer>
-
- {/* <ConfigurationFormContainer>
- <TagItems></TagItems>
- </ConfigurationFormContainer> */}
- </MainContainer>
- );
-}
diff --git a/web/src/pages/dataset/setting/python/configuration/qa.tsx b/web/src/pages/dataset/setting/python/configuration/qa.tsx
deleted file mode 100644
index 6d545cc561..0000000000
--- a/web/src/pages/dataset/setting/python/configuration/qa.tsx
+++ /dev/null
@@ -1,8 +0,0 @@
-export function QAConfiguration() {
- return (
- <></>
- // <ConfigurationFormContainer>
- // <TagItems></TagItems>
- // </ConfigurationFormContainer>
- );
-}
diff --git a/web/src/pages/dataset/setting/python/configuration/resume.tsx b/web/src/pages/dataset/setting/python/configuration/resume.tsx
deleted file mode 100644
index b9e57313c5..0000000000
--- a/web/src/pages/dataset/setting/python/configuration/resume.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-import { ConfigurationFormContainer } from '../configuration-form-container';
-import { GlobalIndexModelItem } from './common-item';
-
-export function ResumeConfiguration() {
- return (
- <ConfigurationFormContainer>
- <GlobalIndexModelItem />
- </ConfigurationFormContainer>
- );
-}
diff --git a/web/src/pages/dataset/setting/python/configuration/table.tsx b/web/src/pages/dataset/setting/python/configuration/table.tsx
deleted file mode 100644
index 20382adc87..0000000000
--- a/web/src/pages/dataset/setting/python/configuration/table.tsx
+++ /dev/null
@@ -1,157 +0,0 @@
-import { FormControl, FormItem, FormLabel } from '@/components/ui/form';
-import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from '@/components/ui/select';
-import { useTranslate } from '@/hooks/common-hooks';
-import { useFormContext, useWatch } from 'react-hook-form';
-import { ConfigurationFormContainer } from '../configuration-form-container';
-import { GlobalIndexModelItem } from './common-item';
-
-const ROLE_OPTIONS = [
- { value: 'both', labelKey: 'tableColumnRoleBoth' },
- { value: 'indexing', labelKey: 'tableColumnRoleIndexing' },
- { value: 'metadata', labelKey: 'tableColumnRoleMetadata' },
-] as const;
-
-function selectTableColumnRoleValue(raw: string | undefined): string {
- if (!raw) return 'both';
- return raw === 'vectorize' ? 'indexing' : raw;
-}
-
-export function TableConfiguration() {
- const form = useFormContext();
- const { t } = useTranslate('knowledgeConfiguration');
-
- const tableColumnMode = useWatch({
- control: form.control,
- name: 'parser_config.table_column_mode',
- defaultValue: 'auto',
- });
- const tableColumnNames = useWatch({
- control: form.control,
- name: 'parser_config.table_column_names',
- defaultValue: [],
- });
- const tableColumnRoles = useWatch({
- control: form.control,
- name: 'parser_config.table_column_roles',
- defaultValue: {},
- });
-
- const mode = tableColumnMode === 'manual' ? 'manual' : 'auto';
- const columns: string[] = Array.isArray(tableColumnNames)
- ? tableColumnNames
- : [];
-
- const handleModeChange = (value: string) => {
- form.setValue(
- 'parser_config.table_column_mode',
- value as 'auto' | 'manual',
- );
- };
-
- const handleRoleChange = (columnName: string, role: string) => {
- const current =
- (form.getValues('parser_config.table_column_roles') as Record<
- string,
- string
- >) || {};
- form.setValue('parser_config.table_column_roles', {
- ...current,
- [columnName]: role,
- });
- };
-
- return (
- <ConfigurationFormContainer>
- <GlobalIndexModelItem />
- <FormItem className="space-y-2">
- <FormLabel className="text-sm font-medium">
- {t('tableColumnMode')}
- </FormLabel>
- <FormControl>
- <RadioGroup
- value={mode}
- onValueChange={handleModeChange}
- className="flex gap-4"
- >
- <div className="flex items-center space-x-2">
- <RadioGroupItem value="auto" id="table-mode-auto" />
- <label
- htmlFor="table-mode-auto"
- className="text-sm font-normal cursor-pointer"
- >
- {t('tableColumnModeAuto')}
- </label>
- </div>
- <div className="flex items-center space-x-2">
- <RadioGroupItem value="manual" id="table-mode-manual" />
- <label
- htmlFor="table-mode-manual"
- className="text-sm font-normal cursor-pointer"
- >
- {t('tableColumnModeManual')}
- </label>
- </div>
- </RadioGroup>
- </FormControl>
- </FormItem>
-
- {mode === 'auto' && (
- <p className="text-sm text-muted-foreground">
- {t('tableColumnModeAutoDescription')}
- </p>
- )}
-
- {mode === 'manual' && columns.length === 0 && (
- <p className="text-sm text-muted-foreground">
- {t('tableColumnRolesEmpty')}
- </p>
- )}
-
- {mode === 'manual' && columns.length > 0 && (
- <>
- <p className="text-sm text-muted-foreground mb-3">
- {t('tableColumnRolesTip')}
- </p>
- <div className="space-y-3">
- {columns.map((col) => (
- <FormItem key={col} className="flex flex-row items-center gap-4">
- <FormLabel className="min-w-[120px] shrink-0 text-sm font-normal">
- {col}
- </FormLabel>
- <FormControl>
- <Select
- value={selectTableColumnRoleValue(
- tableColumnRoles && tableColumnRoles[col],
- )}
- onValueChange={(value) => handleRoleChange(col, value)}
- >
- <SelectTrigger className="w-[160px]">
- <SelectValue />
- </SelectTrigger>
- <SelectContent>
- {ROLE_OPTIONS.map((opt) => (
- <SelectItem key={opt.value} value={opt.value}>
- {t(opt.labelKey)}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- </FormControl>
- </FormItem>
- ))}
- </div>
- <p className="text-xs text-muted-foreground mt-3">
- {t('tableColumnRolesReparseTip')}
- </p>
- </>
- )}
- </ConfigurationFormContainer>
- );
-}
diff --git a/web/src/pages/dataset/setting/python/configuration/tag.tsx b/web/src/pages/dataset/setting/python/configuration/tag.tsx
deleted file mode 100644
index b068ec26f6..0000000000
--- a/web/src/pages/dataset/setting/python/configuration/tag.tsx
+++ /dev/null
@@ -1,5 +0,0 @@
-import { ConfigurationFormContainer } from '../configuration-form-container';
-
-export function TagConfiguration() {
- return <ConfigurationFormContainer></ConfigurationFormContainer>;
-}
diff --git a/web/src/pages/dataset/setting/python/form-schema.ts b/web/src/pages/dataset/setting/python/form-schema.ts
deleted file mode 100644
index 6f92ba9dfc..0000000000
--- a/web/src/pages/dataset/setting/python/form-schema.ts
+++ /dev/null
@@ -1,110 +0,0 @@
-import { DESCRIPTION_MAX_LENGTH } from '@/constants/common';
-import { ParseType } from '@/constants/knowledge';
-import { t } from 'i18next';
-import { z } from 'zod';
-
-export const formSchema = z
- .object({
- parse_type: z.nativeEnum(ParseType),
- name: z.string().min(1, {
- message: 'Username must be at least 2 characters.',
- }),
- description: z
- .string()
- .max(DESCRIPTION_MAX_LENGTH, {
- message: t('common.descriptionMaxLength', {
- max: DESCRIPTION_MAX_LENGTH,
- }),
- })
- .optional(),
- // avatar: z.instanceof(File),
- avatar: z.any().nullish(),
- permission: z.string().optional(),
- language: z.string().optional(),
- chunk_method: z.string(),
- pipeline_id: z.string().optional(),
- pipeline_name: z.string().optional(),
- pipeline_avatar: z.string().optional(),
- embedding_model: z.string(),
- parser_config: z
- .object({
- layout_recognize: z.string(),
- chunk_token_num: z.number(),
- delimiter: z.string(),
- enable_children: z.boolean(),
- children_delimiter: z.string(),
- auto_keywords: z.number().optional(),
- auto_questions: z.number().optional(),
- html4excel: z.boolean(),
- tag_kb_ids: z.array(z.string()).nullish(),
- topn_tags: z.number().optional(),
- image_table_context_window: z.number().optional(),
- overlapped_percent: z.number().optional(),
- // MinerU-specific options
- mineru_parse_method: z.enum(['auto', 'txt', 'ocr']).optional(),
- mineru_formula_enable: z.boolean().optional(),
- mineru_table_enable: z.boolean().optional(),
- mineru_lang: z.string().optional(),
- metadata: z.any().optional(),
- built_in_metadata: z
- .array(
- z.object({
- key: z.string().optional(),
- type: z.string().optional(),
- }),
- )
- .optional(),
- enable_metadata: z.boolean().optional(),
- llm_id: z.string().optional(),
- // Table parser: "auto" = all columns both, "manual" = use column role selector
- table_column_mode: z.enum(['auto', 'manual']).optional(),
- // Table parser: column name -> role (indexing | metadata | both); legacy "vectorize" -> indexing
- table_column_roles: z
- .record(
- z
- .enum(['indexing', 'metadata', 'both', 'vectorize'])
- .transform((role) => (role === 'vectorize' ? 'indexing' : role)),
- )
- .optional(),
- // Table parser: column names list (set by backend after first parse)
- table_column_names: z.array(z.string()).optional(),
- })
- .optional(),
- pagerank: z.number(),
- connectors: z
- .array(
- z.object({
- id: z.string().optional(),
- name: z.string().optional(),
- source: z.string().optional(),
- ststus: z.string().optional(),
- auto_parse: z.string().optional(),
- }),
- )
- .optional(),
- // icon: z.array(z.instanceof(File)),
- })
- .superRefine((data, ctx) => {
- if (data.parse_type === ParseType.Pipeline && !data.pipeline_id) {
- ctx.addIssue({
- path: ['pipeline_id'],
- message: t('common.pleaseSelect'),
- code: 'custom',
- });
- }
- });
-
-export const pipelineFormSchema = z.object({
- pipeline_id: z.string().optional(),
- set_default: z.boolean().optional(),
- file_filter: z.string().optional(),
-});
-
-// export const linkPiplineFormSchema = pipelineFormSchema.pick({
-// pipeline_id: true,
-// file_filter: true,
-// });
-// export const editPiplineFormSchema = pipelineFormSchema.pick({
-// set_default: true,
-// file_filter: true,
-// });
diff --git a/web/src/pages/dataset/setting/python/general-form.tsx b/web/src/pages/dataset/setting/python/general-form.tsx
deleted file mode 100644
index 05d07ca0aa..0000000000
--- a/web/src/pages/dataset/setting/python/general-form.tsx
+++ /dev/null
@@ -1,141 +0,0 @@
-import { AvatarUpload } from '@/components/avatar-upload';
-import { SelectWithSearch } from '@/components/originui/select-with-search';
-import PageRankFormField from '@/components/page-rank-form-field';
-import { RAGFlowFormItem } from '@/components/ragflow-form';
-import {
- FormControl,
- FormField,
- FormItem,
- FormLabel,
- FormMessage,
-} from '@/components/ui/form';
-import { Input } from '@/components/ui/input';
-import {
- DESCRIPTION_MAX_LENGTH,
- LanguageTranslationMap,
-} from '@/constants/common';
-import { useMemo } from 'react';
-import { useFormContext } from 'react-hook-form';
-import { useTranslation } from 'react-i18next';
-import { useOwnerTenantId } from '../../contexts/knowledge-base-context';
-import { TagItems } from './components/tag-item';
-import { EmbeddingModelItem } from './configuration/common-item';
-import { PermissionFormField } from './permission-form-field';
-
-export function GeneralForm() {
- const form = useFormContext();
- const { t } = useTranslation();
- const ownerTenantId = useOwnerTenantId();
-
- const languageOptions = useMemo(() => {
- return Object.keys(LanguageTranslationMap).map((x) => ({
- label: x,
- value: x,
- }));
- }, []);
-
- return (
- <>
- <FormField
- control={form.control}
- name="name"
- render={({ field }) => (
- <FormItem className="items-center space-y-0">
- <div className="flex">
- <FormLabel className="text-sm whitespace-nowrap w-1/4" required>
- {t('common.name')}
- </FormLabel>
- <FormControl className="w-3/4">
- <Input
- {...field}
- data-testid="ds-settings-basic-name-input"
- ></Input>
- </FormControl>
- </div>
- <div className="flex pt-1">
- <div className="w-1/4"></div>
- <FormMessage />
- </div>
- </FormItem>
- )}
- />
- <div className="items-center">
- <RAGFlowFormItem
- name="language"
- label={t('common.language')}
- horizontal={true}
- >
- <SelectWithSearch
- options={languageOptions}
- triggerClassName="w-full"
- testId="ds-settings-basic-language-select"
- ></SelectWithSearch>
- </RAGFlowFormItem>
- </div>
- <FormField
- control={form.control}
- name="avatar"
- render={({ field }) => (
- <FormItem className="items-center space-y-0">
- <div className="flex">
- <FormLabel className="text-sm whitespace-nowrap w-1/4">
- {t('setting.avatar')}
- </FormLabel>
- <FormControl className="w-3/4">
- <AvatarUpload
- {...field}
- uploadInputTestId="ds-settings-basic-avatar-upload"
- cropModalTestId="ds-settings-basic-avatar-crop-modal"
- cropModalOkButtonTestId="ds-settings-basic-avatar-crop-confirm-btn"
- ></AvatarUpload>
- </FormControl>
- </div>
- <div className="flex pt-1">
- <div className="w-1/4"></div>
- <FormMessage />
- </div>
- </FormItem>
- )}
- />
- <FormField
- control={form.control}
- name="description"
- render={({ field }) => {
- // null initialize empty string
- if (typeof field.value === 'object' && !field.value) {
- form.setValue('description', '');
- }
- return (
- <FormItem className="items-center space-y-0">
- <div className="flex">
- <FormLabel className="text-sm whitespace-nowrap w-1/4">
- {t('flow.description')}
- </FormLabel>
- <FormControl className="w-3/4">
- <Input
- {...field}
- maxLength={DESCRIPTION_MAX_LENGTH}
- placeholder={t('knowledgeConfiguration.datasetDescription')}
- data-testid="ds-settings-basic-description-input"
- ></Input>
- </FormControl>
- </div>
- <div className="flex pt-1">
- <div className="w-1/4"></div>
- <FormMessage />
- </div>
- </FormItem>
- );
- }}
- />
- <PermissionFormField></PermissionFormField>
- <EmbeddingModelItem
- isEdit={true}
- ownerTenantId={ownerTenantId}
- ></EmbeddingModelItem>
- <PageRankFormField></PageRankFormField>
-
- <TagItems></TagItems>
- </>
- );
-}
diff --git a/web/src/pages/dataset/setting/python/hooks.ts b/web/src/pages/dataset/setting/python/hooks.ts
deleted file mode 100644
index 1696a061ea..0000000000
--- a/web/src/pages/dataset/setting/python/hooks.ts
+++ /dev/null
@@ -1,84 +0,0 @@
-import { useSetModalState } from '@/hooks/common-hooks';
-
-import { useFetchKnowledgeBaseConfiguration } from '@/hooks/use-knowledge-request';
-import { useSelectParserList } from '@/hooks/use-user-setting-request';
-import { useIsFetching } from '@tanstack/react-query';
-import { pick } from 'lodash';
-import { useCallback, useEffect, useState } from 'react';
-import { UseFormReturn } from 'react-hook-form';
-import { z } from 'zod';
-import { formSchema } from './form-schema';
-
-// The value that does not need to be displayed in the analysis method Select
-const HiddenFields = ['email', 'picture', 'audio', 'resume'];
-
-export function useSelectChunkMethodList() {
- const parserList = useSelectParserList();
-
- return parserList.filter((x) => !HiddenFields.some((y) => y === x.value));
-}
-
-export function useHasParsedDocument(isEdit?: boolean) {
- const { data: knowledgeDetails } = useFetchKnowledgeBaseConfiguration({
- isEdit,
- });
- return knowledgeDetails.chunk_count > 0;
-}
-
-export const useFetchKnowledgeConfigurationOnMount = (
- form: UseFormReturn<z.infer<typeof formSchema>>,
-) => {
- const { data: knowledgeDetails, loading } =
- useFetchKnowledgeBaseConfiguration();
-
- useEffect(() => {
- const parser_config = {
- ...form.formState?.defaultValues?.parser_config,
- ...knowledgeDetails.parser_config,
- };
- const formValues = {
- ...pick({ ...knowledgeDetails, parser_config: parser_config }, [
- 'description',
- 'name',
- 'permission',
- 'language',
- 'parser_config',
- 'connectors',
- 'pagerank',
- 'avatar',
- ]),
- embedding_model: knowledgeDetails.embedding_model,
- chunk_method: knowledgeDetails.chunk_method,
- } as z.infer<typeof formSchema>;
- form.reset(formValues);
- }, [form, knowledgeDetails]);
-
- return { knowledgeDetails, loading };
-};
-
-export const useSelectKnowledgeDetailsLoading = () =>
- useIsFetching({ queryKey: ['fetchKnowledgeDetail'] }) > 0;
-
-export const useRenameKnowledgeTag = () => {
- const [tag, setTag] = useState<string>('');
- const {
- visible: tagRenameVisible,
- hideModal: hideTagRenameModal,
- showModal: showFileRenameModal,
- } = useSetModalState();
-
- const handleShowTagRenameModal = useCallback(
- (record: string) => {
- setTag(record);
- showFileRenameModal();
- },
- [showFileRenameModal],
- );
-
- return {
- initialName: tag,
- tagRenameVisible,
- hideTagRenameModal,
- showTagRenameModal: handleShowTagRenameModal,
- };
-};
diff --git a/web/src/pages/dataset/setting/python/index.tsx b/web/src/pages/dataset/setting/python/index.tsx
deleted file mode 100644
index 2a992167ee..0000000000
--- a/web/src/pages/dataset/setting/python/index.tsx
+++ /dev/null
@@ -1,304 +0,0 @@
-import { DataFlowSelect } from '@/components/data-pipeline-select';
-import { Button } from '@/components/ui/button';
-import {
- Card,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
-} from '@/components/ui/card';
-import Divider from '@/components/ui/divider';
-import { Form } from '@/components/ui/form';
-import { FormLayout } from '@/constants/form';
-import { DocumentParserType, ParseType } from '@/constants/knowledge';
-import { PermissionRole } from '@/constants/permission';
-import { IConnector, IDataset } from '@/interfaces/database/dataset';
-import { useDataSourceInfo } from '@/pages/user-setting/data-source/constant';
-import { IDataSourceBase } from '@/pages/user-setting/data-source/interface';
-import { zodResolver } from '@hookform/resolvers/zod';
-import { createContext, useEffect, useState } from 'react';
-import { useForm, useWatch } from 'react-hook-form';
-import { useTranslation } from 'react-i18next';
-import { z } from 'zod';
-import { ChunkMethodForm } from './chunk-method-form';
-import ChunkMethodLearnMore from './chunk-method-learn-more';
-import LinkDataSource, {
- IDataSourceNodeProps,
-} from './components/link-data-source';
-import { ParseTypeItem } from '@/components/parse-type-form-field';
-import { MainContainer } from './configuration-form-container';
-import { ChunkMethodItem } from './configuration/common-item';
-import { formSchema } from './form-schema';
-import { GeneralForm } from './general-form';
-import { useFetchKnowledgeConfigurationOnMount } from './hooks';
-import { SavingButton } from './saving-button';
-const enum DocumentType {
- DeepDOC = 'DeepDOC',
- PlainText = 'Plain Text',
-}
-export const DataSetContext = createContext<{
- loading: boolean;
- knowledgeDetails: IDataset;
-}>({ loading: false, knowledgeDetails: {} as IDataset });
-
-export default function DatasetSettings() {
- const { t } = useTranslation();
-
- const form = useForm<z.infer<typeof formSchema>>({
- resolver: zodResolver(formSchema),
- defaultValues: {
- name: '',
- chunk_method: DocumentParserType.Naive,
- permission: PermissionRole.Me,
- language: 'English',
- parser_config: {
- layout_recognize: DocumentType.DeepDOC,
- chunk_token_num: 512,
- delimiter: `\n`,
- enable_children: false,
- children_delimiter: `\n`,
- auto_keywords: 0,
- auto_questions: 0,
- html4excel: false,
- topn_tags: 3,
- image_table_context_window: 0,
- overlapped_percent: 0,
- metadata: {
- type: 'object',
- properties: {},
- additionalProperties: false,
- },
- built_in_metadata: [],
- enable_metadata: false,
- llm_id: '',
- },
- pipeline_id: '',
- parse_type: ParseType.BuiltIn,
- pagerank: 0,
- connectors: [],
- },
- });
- const { dataSourceInfo } = useDataSourceInfo();
- const { knowledgeDetails, loading: datasetSettingLoading } =
- useFetchKnowledgeConfigurationOnMount(form);
- // const [pipelineData, setPipelineData] = useState<IDataPipelineNodeProps>();
- const [sourceData, setSourceData] = useState<IDataSourceNodeProps[]>();
-
- useEffect(() => {
- if (knowledgeDetails) {
- // const data: IDataPipelineNodeProps = {
- // id: knowledgeDetails.pipeline_id,
- // name: knowledgeDetails.pipeline_name,
- // avatar: knowledgeDetails.pipeline_avatar,
- // linked: true,
- // };
- // setPipelineData(data);
-
- const source_data: IDataSourceNodeProps[] = (
- knowledgeDetails?.connectors ?? []
- ).map((connector: IConnector) => {
- return {
- ...connector,
- icon:
- dataSourceInfo[connector.source as keyof typeof dataSourceInfo]
- ?.icon || '',
- };
- });
-
- setSourceData(source_data);
-
- form.setValue(
- 'parse_type',
- knowledgeDetails.pipeline_id ? ParseType.Pipeline : ParseType.BuiltIn,
- );
- form.setValue('pipeline_id', knowledgeDetails.pipeline_id || '');
- }
- }, [knowledgeDetails, form]);
-
- async function onSubmit(data: z.infer<typeof formSchema>) {
- try {
- console.log('Form validation passed, submit data', data);
- } catch (error) {
- console.error('An error occurred during submission:', error);
- }
- }
- // const handleLinkOrEditSubmit = (
- // data: IDataPipelineSelectNode | undefined,
- // ) => {
- // console.log('🚀 ~ DatasetSettings ~ data:', data);
- // if (data) {
- // setPipelineData(data);
- // form.setValue('pipeline_id', data.id || '');
- // // form.setValue('pipeline_name', data.name || '');
- // // form.setValue('pipeline_avatar', data.avatar || '');
- // }
- // };
-
- const handleLinkOrEditSubmit = (data: IConnector[] | undefined) => {
- if (data) {
- const connectors = data.map((connector) => {
- return {
- ...connector,
- auto_parse: connector.auto_parse === '0' ? '0' : '1',
- icon:
- dataSourceInfo[connector.source as keyof typeof dataSourceInfo]
- ?.icon || '',
- };
- });
- setSourceData(connectors as IDataSourceNodeProps[]);
- form.setValue('connectors', connectors || []);
- // form.setValue('pipeline_name', data.name || '');
- // form.setValue('pipeline_avatar', data.avatar || '');
- }
- };
-
- const parseType = useWatch({
- control: form.control,
- name: 'parse_type',
- defaultValue: knowledgeDetails.pipeline_id
- ? ParseType.Pipeline
- : ParseType.BuiltIn,
- });
- const selectedTag = useWatch({
- name: 'chunk_method',
- control: form.control,
- });
-
- useEffect(() => {
- if (parseType === ParseType.BuiltIn) {
- form.setValue('pipeline_id', '');
- } else {
- form.setValue('chunk_method', DocumentParserType.Naive);
- }
- }, [parseType, form]);
-
- const unbindFunc = (data: IDataSourceBase) => {
- if (data) {
- const connectors = sourceData?.filter((connector) => {
- return connector.id !== data.id;
- });
- setSourceData(connectors as IDataSourceNodeProps[]);
- form.setValue('connectors', connectors || []);
- // form.setValue('pipeline_name', data.name || '');
- // form.setValue('pipeline_avatar', data.avatar || '');
- }
- };
- const handleAutoParse = ({
- source_id,
- isAutoParse,
- }: {
- source_id: string;
- isAutoParse: boolean;
- }) => {
- if (source_id) {
- const connectors = sourceData?.map((connector) => {
- if (connector.id === source_id) {
- return {
- ...connector,
- auto_parse: isAutoParse ? '1' : '0',
- };
- }
- return connector;
- });
- setSourceData(connectors as IDataSourceNodeProps[]);
- form.setValue('connectors', connectors || []);
- }
- };
-
- return (
- <div className="pr-5 pb-5">
- <Card className="p-0 h-full flex flex-col bg-transparent shadow-none">
- <CardHeader className="p-5 border-b-0.5 border-border-button">
- <header>
- <CardTitle as="h1">{t('knowledgeDetails.configuration')}</CardTitle>
-
- <CardDescription>
- {t('knowledgeConfiguration.titleDescription')}
- </CardDescription>
-
- {/* <Button>Save as Preset</Button> */}
- </header>
- </CardHeader>
-
- <CardContent className="p-0 flex-1 h-0 flex divide-x-0.5">
- <DataSetContext.Provider
- value={{
- loading: datasetSettingLoading,
- knowledgeDetails: knowledgeDetails,
- }}
- >
- <Form {...form}>
- <form
- onSubmit={form.handleSubmit(onSubmit)}
- className="flex flex-col"
- >
- <div className="flex-1 h-0 w-[768px] px-5 pt-5 overflow-y-auto scrollbar-auto">
- <MainContainer className="text-text-secondary">
- <div className="text-base font-medium text-text-primary">
- {t('knowledgeConfiguration.baseInfo')}
- </div>
- <GeneralForm></GeneralForm>
-
- <Divider />
- <div className="text-base font-medium text-text-primary">
- {t('knowledgeConfiguration.dataPipeline')}
- </div>
- <ParseTypeItem line={1} name="parse_type" />
- {parseType === ParseType.BuiltIn && (
- <ChunkMethodItem
- line={1}
- name="chunk_method"
- ></ChunkMethodItem>
- )}
- {parseType === ParseType.Pipeline && (
- <DataFlowSelect
- isMult={false}
- showToDataPipeline={true}
- formFieldName="pipeline_id"
- layout={FormLayout.Horizontal}
- />
- )}
-
- {parseType === ParseType.BuiltIn && <ChunkMethodForm />}
-
- {/* <LinkDataPipeline
- data={pipelineData}
- handleLinkOrEditSubmit={handleLinkOrEditSubmit}
- /> */}
- <Divider />
- <LinkDataSource
- data={sourceData}
- handleLinkOrEditSubmit={handleLinkOrEditSubmit}
- unbindFunc={unbindFunc}
- handleAutoParse={handleAutoParse}
- />
- </MainContainer>
- </div>
-
- <div className="p-5 text-right items-center flex justify-end gap-3 w-[768px]">
- <Button
- type="reset"
- variant="transparent"
- onClick={() => {
- form.reset();
- }}
- >
- {t('knowledgeConfiguration.cancel')}
- </Button>
-
- <SavingButton />
- </div>
- </form>
- </Form>
- </DataSetContext.Provider>
-
- <div className="flex-1 p-5 overflow-auto">
- {parseType === ParseType.BuiltIn && (
- <ChunkMethodLearnMore parserId={selectedTag} />
- )}
- </div>
- </CardContent>
- </Card>
- </div>
- );
-}
diff --git a/web/src/pages/dataset/setting/python/permission-form-field.tsx b/web/src/pages/dataset/setting/python/permission-form-field.tsx
deleted file mode 100644
index 33336a8241..0000000000
--- a/web/src/pages/dataset/setting/python/permission-form-field.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-import { SelectWithSearch } from '@/components/originui/select-with-search';
-import { RAGFlowFormItem } from '@/components/ragflow-form';
-import { PermissionRole } from '@/constants/permission';
-import { useMemo } from 'react';
-import { useTranslation } from 'react-i18next';
-
-export function PermissionFormField() {
- const { t } = useTranslation();
- const teamOptions = useMemo(() => {
- return Object.values(PermissionRole).map((x) => ({
- label: t('knowledgeConfiguration.' + x),
- value: x,
- }));
- }, [t]);
-
- return (
- <RAGFlowFormItem
- name="permission"
- label={t('knowledgeConfiguration.permissions')}
- tooltip={t('knowledgeConfiguration.permissionsTip')}
- horizontal
- >
- <SelectWithSearch
- options={teamOptions}
- triggerClassName="w-full"
- testId="ds-settings-basic-permissions-select"
- ></SelectWithSearch>
- </RAGFlowFormItem>
- );
-}
diff --git a/web/src/pages/dataset/setting/python/saving-button.tsx b/web/src/pages/dataset/setting/python/saving-button.tsx
deleted file mode 100644
index 37b0bd2350..0000000000
--- a/web/src/pages/dataset/setting/python/saving-button.tsx
+++ /dev/null
@@ -1,106 +0,0 @@
-import { ButtonLoading } from '@/components/ui/button';
-import { ParseType } from '@/constants/knowledge';
-import { useUpdateKnowledge } from '@/hooks/use-knowledge-request';
-import { useMemo } from 'react';
-import { useFormContext } from 'react-hook-form';
-import { useTranslation } from 'react-i18next';
-import { useParams } from 'react-router';
-
-export function GeneralSavingButton() {
- const form = useFormContext();
- const { saveKnowledgeConfiguration, loading: submitLoading } =
- useUpdateKnowledge();
- const { id: kb_id } = useParams();
- const { t } = useTranslation();
-
- const defaultValues = useMemo(
- () => form.formState.defaultValues ?? {},
- [form.formState.defaultValues],
- );
- const chunk_method = defaultValues['chunk_method'];
-
- return (
- <ButtonLoading
- type="button"
- loading={submitLoading}
- data-testid="ds-settings-basic-save-btn"
- onClick={() => {
- (async () => {
- const isValidate = await form.trigger('name');
- const { name, description, permission, avatar } = form.getValues();
-
- if (isValidate) {
- saveKnowledgeConfiguration({
- kb_id,
- chunk_method,
- name,
- description,
- avatar,
- permission,
- });
- }
- })();
- }}
- >
- {t('knowledgeConfiguration.save')}
- </ButtonLoading>
- );
-}
-
-export function SavingButton() {
- const { saveKnowledgeConfiguration, loading: submitLoading } =
- useUpdateKnowledge();
- const form = useFormContext();
- const { id: kb_id } = useParams();
- const { t } = useTranslation();
-
- return (
- <ButtonLoading
- loading={submitLoading}
- data-testid="ds-settings-page-save-btn"
- onClick={() => {
- (async () => {
- try {
- const beValid = await form.trigger();
- if (!beValid) {
- const errors = form.formState.errors;
- console.error('Validation errors:', errors);
- }
- if (beValid) {
- form.handleSubmit(async (originalValues) => {
- const values = originalValues;
- if (originalValues.parse_type === ParseType.BuiltIn) {
- values.pipeline_id = null;
- } else {
- values.chunk_method = null;
- }
-
- await saveKnowledgeConfiguration({
- kb_id,
- ...values,
- parser_config: {
- ...values.parser_config,
- image_table_context_window:
- values.parser_config.image_table_context_window,
- image_context_size:
- values.parser_config.image_table_context_window,
- table_context_size:
- values.parser_config.image_table_context_window,
- // Unset children delimiter if this option is not enabled
- children_delimiter: values.parser_config.enable_children
- ? values.parser_config.children_delimiter
- : '',
- },
- });
- })();
- }
- } catch (e) {
- console.log(e);
- }
- })();
- }}
- >
- {t('knowledgeConfiguration.save')}
- </ButtonLoading>
- );
-}
diff --git a/web/src/pages/dataset/setting/python/tag-table/index.tsx b/web/src/pages/dataset/setting/python/tag-table/index.tsx
deleted file mode 100644
index f28e788048..0000000000
--- a/web/src/pages/dataset/setting/python/tag-table/index.tsx
+++ /dev/null
@@ -1,305 +0,0 @@
-'use client';
-
-import {
- ColumnDef,
- ColumnFiltersState,
- SortingState,
- VisibilityState,
- flexRender,
- getCoreRowModel,
- getFilteredRowModel,
- getPaginationRowModel,
- getSortedRowModel,
- useReactTable,
-} from '@tanstack/react-table';
-import { ArrowUpDown, Pencil, Trash2 } from 'lucide-react';
-import * as React from 'react';
-
-import { ConfirmDeleteDialog } from '@/components/confirm-delete-dialog';
-import { Button } from '@/components/ui/button';
-import { Checkbox } from '@/components/ui/checkbox';
-import { Input } from '@/components/ui/input';
-import {
- Table,
- TableBody,
- TableCell,
- TableHead,
- TableHeader,
- TableRow,
-} from '@/components/ui/table';
-import {
- Tooltip,
- TooltipContent,
- TooltipProvider,
- TooltipTrigger,
-} from '@/components/ui/tooltip';
-import { useDeleteTag, useFetchTagList } from '@/hooks/use-knowledge-request';
-import { useCallback, useEffect, useState } from 'react';
-import { useTranslation } from 'react-i18next';
-import { useRenameKnowledgeTag } from '../hooks';
-import { RenameDialog } from './rename-dialog';
-
-export type ITag = {
- tag: string;
- frequency: number;
-};
-
-export function TagTable() {
- const { t } = useTranslation();
- const { list } = useFetchTagList();
- const [tagList, setTagList] = useState<ITag[]>([]);
-
- const [sorting, setSorting] = React.useState<SortingState>([]);
- const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>(
- [],
- );
- const [columnVisibility, setColumnVisibility] =
- React.useState<VisibilityState>({});
- const [rowSelection, setRowSelection] = useState({});
-
- const { deleteTag } = useDeleteTag();
-
- useEffect(() => {
- setTagList(list.map((x) => ({ tag: x[0], frequency: x[1] })));
- }, [list]);
-
- const handleDeleteTag = useCallback(
- (tags: string[]) => () => {
- deleteTag(tags);
- },
- [deleteTag],
- );
-
- const {
- showTagRenameModal,
- hideTagRenameModal,
- tagRenameVisible,
- initialName,
- } = useRenameKnowledgeTag();
-
- const columns: ColumnDef<ITag>[] = [
- {
- id: 'select',
- header: ({ table }) => (
- <Checkbox
- checked={
- table.getIsAllPageRowsSelected() ||
- (table.getIsSomePageRowsSelected() && 'indeterminate')
- }
- onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)}
- aria-label="Select all"
- />
- ),
- cell: ({ row }) => (
- <Checkbox
- checked={row.getIsSelected()}
- onCheckedChange={(value) => row.toggleSelected(!!value)}
- aria-label="Select row"
- />
- ),
- enableSorting: false,
- enableHiding: false,
- },
- {
- accessorKey: 'tag',
- header: ({ column }) => {
- return (
- <Button
- variant="ghost"
- onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
- >
- {t('knowledgeConfiguration.tagName')}
- <ArrowUpDown />
- </Button>
- );
- },
- cell: ({ row }) => {
- const value: string = row.getValue('tag');
- return <div>{value}</div>;
- },
- },
- {
- accessorKey: 'frequency',
- header: ({ column }) => {
- return (
- <Button
- variant="ghost"
- onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
- >
- {t('knowledgeConfiguration.frequency')}
- <ArrowUpDown />
- </Button>
- );
- },
- cell: ({ row }) => (
- <div className="capitalize ">{row.getValue('frequency')}</div>
- ),
- },
- {
- id: 'actions',
- enableHiding: false,
- header: t('common.action'),
- cell: ({ row }) => {
- return (
- <div className="flex gap-1">
- <Tooltip>
- <ConfirmDeleteDialog onOk={handleDeleteTag([row.original.tag])}>
- <TooltipTrigger asChild>
- <Button variant="ghost" size="icon">
- <Trash2 />
- </Button>
- </TooltipTrigger>
- </ConfirmDeleteDialog>
- <TooltipContent>
- <p>{t('common.delete')}</p>
- </TooltipContent>
- </Tooltip>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- variant="ghost"
- size="icon"
- onClick={() => showTagRenameModal(row.original.tag)}
- >
- <Pencil />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>{t('common.rename')}</p>
- </TooltipContent>
- </Tooltip>
- </div>
- );
- },
- },
- ];
-
- const table = useReactTable({
- data: tagList,
- columns,
- onSortingChange: setSorting,
- onColumnFiltersChange: setColumnFilters,
- getCoreRowModel: getCoreRowModel(),
- getPaginationRowModel: getPaginationRowModel(),
- getSortedRowModel: getSortedRowModel(),
- getFilteredRowModel: getFilteredRowModel(),
- onColumnVisibilityChange: setColumnVisibility,
- onRowSelectionChange: setRowSelection,
- state: {
- sorting,
- columnFilters,
- columnVisibility,
- rowSelection,
- },
- });
-
- const selectedRowLength = table.getFilteredSelectedRowModel().rows.length;
-
- return (
- <TooltipProvider>
- <div className="w-full">
- <div className="flex items-center justify-between py-4 ">
- <Input
- placeholder={t('knowledgeConfiguration.searchTags')}
- value={(table.getColumn('tag')?.getFilterValue() as string) ?? ''}
- onChange={(event) =>
- table.getColumn('tag')?.setFilterValue(event.target.value)
- }
- className="w-1/2"
- />
- {selectedRowLength > 0 && (
- <ConfirmDeleteDialog
- onOk={handleDeleteTag(
- table
- .getFilteredSelectedRowModel()
- .rows.map((x) => x.original.tag),
- )}
- >
- <Button variant="outline" size="icon">
- <Trash2 />
- </Button>
- </ConfirmDeleteDialog>
- )}
- </div>
- <Table rootClassName="rounded-none border max-h-80 overflow-y-auto">
- <TableHeader>
- {table.getHeaderGroups().map((headerGroup) => (
- <TableRow key={headerGroup.id}>
- {headerGroup.headers.map((header) => {
- return (
- <TableHead key={header.id}>
- {header.isPlaceholder
- ? null
- : flexRender(
- header.column.columnDef.header,
- header.getContext(),
- )}
- </TableHead>
- );
- })}
- </TableRow>
- ))}
- </TableHeader>
- <TableBody>
- {table.getRowModel().rows?.length ? (
- table.getRowModel().rows.map((row) => (
- <TableRow
- key={row.id}
- data-state={row.getIsSelected() && 'selected'}
- >
- {row.getVisibleCells().map((cell) => (
- <TableCell key={cell.id}>
- {flexRender(
- cell.column.columnDef.cell,
- cell.getContext(),
- )}
- </TableCell>
- ))}
- </TableRow>
- ))
- ) : (
- <TableRow>
- <TableCell
- colSpan={columns.length}
- className="h-24 text-center"
- >
- No results.
- </TableCell>
- </TableRow>
- )}
- </TableBody>
- </Table>
- </div>
- <div className="flex items-center justify-end space-x-2 py-4">
- <div className="flex-1 text-sm text-muted-foreground">
- {selectedRowLength} of {table.getFilteredRowModel().rows.length}{' '}
- row(s) selected.
- </div>
- <div className="space-x-2">
- <Button
- variant="outline"
- size="sm"
- onClick={() => table.previousPage()}
- disabled={!table.getCanPreviousPage()}
- >
- {t('common.previousPage')}
- </Button>
- <Button
- variant="outline"
- size="sm"
- onClick={() => table.nextPage()}
- disabled={!table.getCanNextPage()}
- >
- {t('common.nextPage')}
- </Button>
- </div>
- </div>
- {tagRenameVisible && (
- <RenameDialog
- hideModal={hideTagRenameModal}
- initialName={initialName}
- ></RenameDialog>
- )}
- </TooltipProvider>
- );
-}
diff --git a/web/src/pages/dataset/setting/python/tag-table/rename-dialog/index.tsx b/web/src/pages/dataset/setting/python/tag-table/rename-dialog/index.tsx
deleted file mode 100644
index 7c601e7f45..0000000000
--- a/web/src/pages/dataset/setting/python/tag-table/rename-dialog/index.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import { ButtonLoading } from '@/components/ui/button';
-import {
- Dialog,
- DialogContent,
- DialogFooter,
- DialogHeader,
- DialogTitle,
-} from '@/components/ui/dialog';
-import { TagRenameId } from '@/constants/knowledge';
-import { useTagIsRenaming } from '@/hooks/use-knowledge-request';
-import { IModalProps } from '@/interfaces/common';
-import { useTranslation } from 'react-i18next';
-import { RenameForm } from './rename-form';
-
-export function RenameDialog({
- hideModal,
- initialName,
-}: IModalProps<any> & { initialName: string }) {
- const { t } = useTranslation();
- const loading = useTagIsRenaming();
-
- return (
- <Dialog open onOpenChange={hideModal}>
- <DialogContent className="sm:max-w-[425px]">
- <DialogHeader>
- <DialogTitle>{t('common.rename')}</DialogTitle>
- </DialogHeader>
- <RenameForm
- initialName={initialName}
- hideModal={hideModal}
- ></RenameForm>
- <DialogFooter>
- <ButtonLoading type="submit" form={TagRenameId} loading={loading}>
- {t('common.save')}
- </ButtonLoading>
- </DialogFooter>
- </DialogContent>
- </Dialog>
- );
-}
diff --git a/web/src/pages/dataset/setting/python/tag-table/rename-dialog/rename-form.tsx b/web/src/pages/dataset/setting/python/tag-table/rename-dialog/rename-form.tsx
deleted file mode 100644
index c533496809..0000000000
--- a/web/src/pages/dataset/setting/python/tag-table/rename-dialog/rename-form.tsx
+++ /dev/null
@@ -1,83 +0,0 @@
-'use client';
-
-import { zodResolver } from '@hookform/resolvers/zod';
-import { useForm } from 'react-hook-form';
-import { z } from 'zod';
-
-import {
- Form,
- FormControl,
- FormField,
- FormItem,
- FormLabel,
- FormMessage,
-} from '@/components/ui/form';
-import { Input } from '@/components/ui/input';
-import { TagRenameId } from '@/constants/knowledge';
-import { useRenameTag } from '@/hooks/use-knowledge-request';
-import { IModalProps } from '@/interfaces/common';
-import { useEffect } from 'react';
-import { useTranslation } from 'react-i18next';
-
-export function RenameForm({
- initialName,
- hideModal,
-}: IModalProps<any> & { initialName: string }) {
- const { t } = useTranslation();
- const FormSchema = z.object({
- name: z
- .string()
- .min(1, {
- message: t('common.namePlaceholder'),
- })
- .trim(),
- });
-
- const form = useForm<z.infer<typeof FormSchema>>({
- resolver: zodResolver(FormSchema),
- defaultValues: {
- name: '',
- },
- });
-
- const { renameTag } = useRenameTag();
-
- async function onSubmit(data: z.infer<typeof FormSchema>) {
- const ret = await renameTag({ fromTag: initialName, toTag: data.name });
- if (ret) {
- hideModal?.();
- }
- }
-
- useEffect(() => {
- form.setValue('name', initialName);
- }, [form, initialName]);
-
- return (
- <Form {...form}>
- <form
- onSubmit={form.handleSubmit(onSubmit)}
- className="space-y-6"
- id={TagRenameId}
- >
- <FormField
- control={form.control}
- name="name"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t('common.name')}</FormLabel>
- <FormControl>
- <Input
- placeholder={t('common.namePlaceholder')}
- {...field}
- autoComplete="off"
- />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
- </form>
- </Form>
- );
-}
diff --git a/web/src/pages/dataset/setting/python/tag-tabs.tsx b/web/src/pages/dataset/setting/python/tag-tabs.tsx
deleted file mode 100644
index 43d0c1d937..0000000000
--- a/web/src/pages/dataset/setting/python/tag-tabs.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import { Segmented, SegmentedLabeledOption } from '@/components/ui/segmented';
-import { upperFirst } from 'lodash';
-import { useState } from 'react';
-import { useTranslation } from 'react-i18next';
-import { TagTable } from './tag-table';
-import { TagWordCloud } from './tag-word-cloud';
-
-enum TagType {
- Cloud = 'cloud',
- Table = 'table',
-}
-
-const TagContentMap = {
- [TagType.Cloud]: <TagWordCloud></TagWordCloud>,
- [TagType.Table]: <TagTable></TagTable>,
-};
-
-export function TagTabs() {
- const [value, setValue] = useState<TagType>(TagType.Cloud);
- const { t } = useTranslation();
-
- const options: SegmentedLabeledOption[] = [TagType.Cloud, TagType.Table].map(
- (x) => ({
- label: t(`knowledgeConfiguration.tag${upperFirst(x)}`),
- value: x,
- }),
- );
-
- return (
- <section className="mt-4">
- <Segmented
- className="w-fit"
- value={value}
- options={options}
- onChange={(val) => setValue(val as TagType)}
- />
- {TagContentMap[value]}
- </section>
- );
-}
diff --git a/web/src/pages/dataset/setting/python/tag-word-cloud.tsx b/web/src/pages/dataset/setting/python/tag-word-cloud.tsx
deleted file mode 100644
index 322ceff7ac..0000000000
--- a/web/src/pages/dataset/setting/python/tag-word-cloud.tsx
+++ /dev/null
@@ -1,62 +0,0 @@
-import { useFetchTagList } from '@/hooks/use-knowledge-request';
-import { Chart } from '@antv/g2';
-import { sumBy } from 'lodash';
-import { useCallback, useEffect, useMemo, useRef } from 'react';
-
-export function TagWordCloud() {
- const domRef = useRef<HTMLDivElement>(null);
- const chartRef = useRef<Chart>();
- const { list } = useFetchTagList();
-
- const { list: tagList } = useMemo(() => {
- const nextList = list.sort((a, b) => b[1] - a[1]).slice(0, 256);
-
- return {
- list: nextList.map((x) => ({ text: x[0], value: x[1], name: x[0] })),
- sumValue: sumBy(nextList, (x: [string, number]) => x[1]),
- length: nextList.length,
- };
- }, [list]);
-
- const renderWordCloud = useCallback(() => {
- if (domRef.current) {
- chartRef.current = new Chart({ container: domRef.current });
-
- chartRef.current.options({
- type: 'wordCloud',
- autoFit: true,
- layout: {
- fontSize: [10, 50],
- // fontSize: (d: any) => {
- // if (d.value) {
- // return (d.value / sumValue) * 100 * (length / 10);
- // }
- // return 0;
- // },
- },
- data: {
- type: 'inline',
- value: tagList,
- },
- encode: { color: 'text' },
- legend: false,
- tooltip: {
- title: 'name', // title
- items: ['value'], // data item
- },
- });
-
- chartRef.current.render();
- }
- }, [tagList]);
-
- useEffect(() => {
- renderWordCloud();
-
- return () => {
- chartRef.current?.destroy();
- };
- }, [renderWordCloud]);
-
- return <div ref={domRef} className="w-full h-[38vh]"></div>;
-}
diff --git a/web/src/pages/dataset/setting/python/utils.ts b/web/src/pages/dataset/setting/python/utils.ts
deleted file mode 100644
index 7fd866eda9..0000000000
--- a/web/src/pages/dataset/setting/python/utils.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-// A few images in the repo (infiniflow-ai/ragflow-images, builtin/chunk-method)
-// are jpg rather than png; override them by 1-based index.
-const getImageName = (
- prefix: string,
- length: number,
- extensionOverrides: Record<number, string> = {},
-) =>
- new Array(length)
- .fill(0)
- .map(
- (x, idx) =>
- `https://raw.gitcode.com/infiniflow-ai/ragflow-images/raw/main/builtin/chunk-method/${prefix}-0${idx + 1}.${extensionOverrides[idx + 1] ?? 'png'}`,
- );
-
-// The Go pipeline catalog uses 'general' as the id of the parser that the
-// Python backend calls 'naive'; both share the same description.
-export const DescriptionKeyMap: Record<string, string> = {
- general: 'naive',
-};
-
-export const ImageMap = {
- audio: getImageName('audio', 1),
- email: getImageName('email', 1),
- book: getImageName('book', 4, { 1: 'jpg' }),
- laws: getImageName('law', 2),
- manual: getImageName('manual', 4),
- picture: getImageName('media', 2),
- naive: getImageName('naive', 2, { 2: 'jpg' }),
- general: getImageName('naive', 2, { 2: 'jpg' }),
- paper: getImageName('paper', 2),
- presentation: getImageName('presentation', 2),
- qa: getImageName('qa', 2),
- resume: getImageName('resume', 2),
- table: getImageName('table', 2, { 1: 'jpg' }),
- one: getImageName('one', 2),
- // knowledge-graph images are not yet present in the remote repo.
- tag: getImageName('tag', 2),
-};
diff --git a/web/src/pages/datasets/dataset-creating-dialog.tsx b/web/src/pages/datasets/dataset-creating-dialog.tsx
index b5f47f9659..f6ec610458 100644
--- a/web/src/pages/datasets/dataset-creating-dialog.tsx
+++ b/web/src/pages/datasets/dataset-creating-dialog.tsx
@@ -29,21 +29,13 @@ import { useEffect } from 'react';
import { useForm, useWatch } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
import { z } from 'zod';
-import {
- ChunkMethodItem,
- EmbeddingModelItem,
-} from '../dataset/setting/python/configuration/common-item';
-import { BackendVariant, pickByBackend } from '@/utils/backend-variant';
+import { EmbeddingModelItem } from '../dataset/setting/common-item';
const FormId = 'dataset-creating-form';
export function InputForm({ onOk }: IModalProps<any>) {
const { t } = useTranslation();
const defaultModelDictionary = useFetchDefaultModelDictionary(true);
- const ChunkMethodName = pickByBackend<'parser_id' | 'chunk_method'>({
- go: 'parser_id',
- python: 'chunk_method',
- });
const FormSchema = z
.object({
@@ -60,20 +52,16 @@ export function InputForm({ onOk }: IModalProps<any>) {
message: t('knowledgeConfiguration.embeddingModelPlaceholder'),
})
.trim(),
- // Go registers parser_id, Python registers chunk_method; only the
- // active key is set at runtime (see ChunkMethodName).
parser_id: z.string().optional(),
- chunk_method: z.string().optional(),
pipeline_id: z.string().optional(),
})
.superRefine((data, ctx) => {
- const chunkMethod = data[ChunkMethodName];
- // When parseType === BuiltIn, chunk_method is required
- if (data.parseType === ParseType.BuiltIn && !chunkMethod?.trim()) {
+ // When parseType === BuiltIn, parser_id is required
+ if (data.parseType === ParseType.BuiltIn && !data.parser_id?.trim()) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: t('knowledgeList.parserRequired'),
- path: [ChunkMethodName],
+ path: ['parser_id'],
});
}
// When parseType === Pipeline, pipeline_id required
@@ -91,7 +79,7 @@ export function InputForm({ onOk }: IModalProps<any>) {
defaultValues: {
name: '',
parseType: ParseType.BuiltIn,
- [ChunkMethodName]: '',
+ parser_id: '',
embedding_model: defaultModelDictionary?.embd_id,
},
});
@@ -105,7 +93,7 @@ export function InputForm({ onOk }: IModalProps<any>) {
const nextData =
parseType === ParseType.BuiltIn
? omit(data, ['pipeline_id'])
- : omit(data, [ChunkMethodName]);
+ : omit(data, ['parser_id']);
onOk?.(nextData);
}
@@ -155,10 +143,7 @@ export function InputForm({ onOk }: IModalProps<any>) {
pipelineLabelKey="knowledgeList.ingestionPipeline"
/>
{parseType === ParseType.BuiltIn && (
- <BackendVariant
- go={<BuiltinPipelineItem name={ChunkMethodName} />}
- python={<ChunkMethodItem name={ChunkMethodName}></ChunkMethodItem>}
- />
+ <BuiltinPipelineItem name="parser_id" />
)}
{parseType === ParseType.Pipeline && (
<DataFlowSelect
diff --git a/web/src/pages/files/action-cell.tsx b/web/src/pages/files/action-cell.tsx
index 22e7260f48..b28d8e5a2d 100644
--- a/web/src/pages/files/action-cell.tsx
+++ b/web/src/pages/files/action-cell.tsx
@@ -9,7 +9,6 @@ import { UseRowSelectionType } from '@/hooks/logic-hooks/use-row-selection';
import { useDownloadFile } from '@/hooks/use-file-request';
import { IFile } from '@/interfaces/database/file-manager';
import { cn } from '@/lib/utils';
-import { useIsGoBackend } from '@/utils/backend-variant';
import {
getExtension,
isSupportedPreviewDocumentType,
@@ -52,10 +51,8 @@ export function ActionCell({
const type = record.type;
const { downloadFile } = useDownloadFile();
- const isSkillsEnabled = useIsGoBackend();
const isFolder = isFolderType(record.type);
- const isSkillsFolder =
- isSkillsEnabled && isFolder && record.name.toLowerCase() === 'skills';
+ const isSkillsFolder = isFolder && record.name.toLowerCase() === 'skills';
const extension = getExtension(record.name);
const isKnowledgeBase = isKnowledgeBaseType(record.source_type);
diff --git a/web/src/pages/files/files-table.tsx b/web/src/pages/files/files-table.tsx
index f397a88428..2d1c2b97ba 100644
--- a/web/src/pages/files/files-table.tsx
+++ b/web/src/pages/files/files-table.tsx
@@ -52,7 +52,6 @@ import { LinkToDatasetDialog } from './link-to-dataset-dialog';
import { UseMoveDocumentShowType } from './use-move-file';
import { useNavigateToOtherFolder } from './use-navigate-to-folder';
import { isFolderType, isKnowledgeBaseType } from './util';
-import { useIsGoBackend } from '../../utils/backend-variant';
type FilesTableProps = Pick<
ReturnType<typeof useFetchFileList>,
@@ -102,22 +101,15 @@ export function FilesTable({
fileRenameLoading,
} = useRenameCurrentFile();
- // Skills are only served by the Go backend
- const isSkillsEnabled = useIsGoBackend();
-
- // Sort files with the Go skills folder first, then by time
+ // Sort files with the skills folder first, then by time
const sortedFiles = useMemo(() => {
if (!files) return [];
return [...files].sort((a, b) => {
const aIsSkills =
- isSkillsEnabled &&
- isFolderType(a.type) &&
- a.name.toLowerCase() === 'skills';
+ isFolderType(a.type) && a.name.toLowerCase() === 'skills';
const bIsSkills =
- isSkillsEnabled &&
- isFolderType(b.type) &&
- b.name.toLowerCase() === 'skills';
+ isFolderType(b.type) && b.name.toLowerCase() === 'skills';
// Skills folder always comes first
if (aIsSkills && !bIsSkills) return -1;
@@ -126,7 +118,7 @@ export function FilesTable({
// Then sort by create_time desc (newest first)
return (b.create_time || 0) - (a.create_time || 0);
});
- }, [files, isSkillsEnabled]);
+ }, [files]);
const columns: ColumnDef<IFile>[] = [
{
@@ -176,8 +168,7 @@ export function FilesTable({
const type = row.original.type;
const id = row.original.id;
const isFolder = isFolderType(type);
- const isSkillsFolder =
- isSkillsEnabled && isFolder && name.toLowerCase() === 'skills';
+ const isSkillsFolder = isFolder && name.toLowerCase() === 'skills';
const handleNameClick = () => {
if (isSkillsFolder) {
@@ -306,9 +297,7 @@ export function FilesTable({
const name = row.original.name;
const type = row.original.type;
const isSkillsFolder =
- isSkillsEnabled &&
- isFolderType(type) &&
- name.toLowerCase() === 'skills';
+ isFolderType(type) && name.toLowerCase() === 'skills';
// The Go skills folder is not selectable because it's a special entry.
return !isKnowledgeBaseType(row.original.source_type) && !isSkillsFolder;
},
diff --git a/web/src/pages/memories/constants/index.tsx b/web/src/pages/memories/constants/index.tsx
index dbf50baf4b..c8fec91169 100644
--- a/web/src/pages/memories/constants/index.tsx
+++ b/web/src/pages/memories/constants/index.tsx
@@ -1,6 +1,6 @@
import { FormFieldConfig, FormFieldType } from '@/components/dynamic-form';
import { EmbeddingSelect } from '@/pages/dataset/setting/embedding-select';
-import { LLMSelect } from '@/pages/dataset/setting/python/configuration/common-item';
+import { LLMSelect } from '@/pages/dataset/setting/common-item';
import { TFunction } from 'i18next';
export enum MemoryType {
Raw = 'raw',
diff --git a/web/src/pages/memory/memory-setting/index.tsx b/web/src/pages/memory/memory-setting/index.tsx
index f28d310646..be3624b7b2 100644
--- a/web/src/pages/memory/memory-setting/index.tsx
+++ b/web/src/pages/memory/memory-setting/index.tsx
@@ -2,7 +2,6 @@ import { DynamicForm } from '@/components/dynamic-form';
import { Button } from '@/components/ui/button';
import Divider from '@/components/ui/divider';
import { Form } from '@/components/ui/form';
-import { MainContainer } from '@/pages/dataset/setting/python/configuration-form-container';
import { TopTitle } from '@/pages/dataset/dataset-title';
import { IMemory } from '@/pages/memories/interface';
import { zodResolver } from '@hookform/resolvers/zod';
@@ -81,7 +80,7 @@ export default function MemoryMessage() {
<Form {...form}>
<form onSubmit={form.handleSubmit(() => {})} className="space-y-6 ">
<div className="w-[768px] h-[calc(100vh-300px)] pr-1 overflow-y-auto scrollbar-auto pb-4">
- <MainContainer className="text-text-secondary !space-y-10">
+ <section className="space-y-5 text-text-secondary !space-y-10">
<div className="text-base font-medium text-text-primary">
{t('knowledgeConfiguration.baseInfo')}
</div>
@@ -89,7 +88,7 @@ export default function MemoryMessage() {
<Divider />
<MemoryModelForm />
<AdvancedSettingsForm />
- </MainContainer>
+ </section>
</div>
<div className="text-right items-center flex justify-end gap-3 w-[768px]">
<Button
diff --git a/web/src/pages/user-setting/data-source/constant/index.test.tsx b/web/src/pages/user-setting/data-source/constant/index.test.tsx
index 7665e8ad9f..cd5eaf7cbf 100644
--- a/web/src/pages/user-setting/data-source/constant/index.test.tsx
+++ b/web/src/pages/user-setting/data-source/constant/index.test.tsx
@@ -133,7 +133,7 @@ describe.each([
expect(batchSize?.validation?.min).toBe(1);
expect(DataSourceFormDefaultValues[key].config).toMatchObject({
- batch_size: 2,
+ batch_size: 32,
});
});
});
@@ -291,10 +291,8 @@ describe.each([
const batchSize = fields.find((f) => f.name === 'config.batch_size');
expect(batchSize?.validation?.min).toBe(1);
- // Python backend (the default in the test environment) keeps the
- // conservative per-batch default.
expect(DataSourceFormDefaultValues[key].config).toMatchObject({
- batch_size: 2,
+ batch_size: 32,
});
});
});
diff --git a/web/src/pages/user-setting/data-source/constant/index.tsx b/web/src/pages/user-setting/data-source/constant/index.tsx
index 30685f0ab8..763c17a561 100644
--- a/web/src/pages/user-setting/data-source/constant/index.tsx
+++ b/web/src/pages/user-setting/data-source/constant/index.tsx
@@ -15,7 +15,6 @@
*/
import { FormFieldType } from '@/components/dynamic-form';
-import { pickByBackend } from '@/utils/backend-variant';
import { IconFontFill } from '@/components/icon-font';
import SvgIcon from '@/components/svg-icon';
import { TFunction } from 'i18next';
@@ -2646,7 +2645,7 @@ export const DataSourceFormDefaultValues = {
metadata_columns: '',
id_column: '',
timestamp_column: '',
- batch_size: pickByBackend({ go: 32, python: 2 }),
+ batch_size: 32,
credentials: {
username: '',
password: '',
@@ -2665,7 +2664,7 @@ export const DataSourceFormDefaultValues = {
metadata_columns: '',
id_column: '',
timestamp_column: '',
- batch_size: pickByBackend({ go: 32, python: 2 }),
+ batch_size: 32,
credentials: {
username: '',
password: '',
diff --git a/web/src/pages/user-setting/mcp/mcp-connection.ts b/web/src/pages/user-setting/mcp/mcp-connection.ts
index f49d7bc34f..ec46c92dd4 100644
--- a/web/src/pages/user-setting/mcp/mcp-connection.ts
+++ b/web/src/pages/user-setting/mcp/mcp-connection.ts
@@ -7,8 +7,8 @@ type Connection = {
variables?: Record<string, unknown>;
};
-// Python accepts $name/${name} and $$ escapes; Go accepts arbitrary ${name}
-// keys. Classify both interpretations without rewriting unrelated templates.
+// Resolve arbitrary ${name} and bare $name placeholders against the variables
+// to classify the header without rewriting unrelated templates.
function isAuthorizationHeader(
key: string,
variables: Record<string, unknown>,
@@ -17,13 +17,12 @@ function isAuthorizationHeader(
Object.prototype.hasOwnProperty.call(variables, name)
? String(variables[name])
: match;
- const python = key.replace(
- /\$\$|\$\{([a-z_][a-z0-9_]*)\}|\$([a-z_][a-z0-9_]*)/gi,
- (match, braced, plain) =>
- match === '$$' ? '$' : lookup(match, braced ?? plain),
- );
- const go = key.replace(/\$\{([^}]*)\}/g, lookup);
- return [key, python, go].some((name) =>
+ // Braced forms first, then bare $name (require a word-leading name so
+ // "$$literal" is not treated as a placeholder).
+ const resolved = key
+ .replace(/\$\{([^}]*)\}/g, lookup)
+ .replace(/\$([A-Za-z][\w ]*)/g, lookup);
+ return [key, resolved].some((name) =>
['authorization', 'authorization_token'].includes(name.toLowerCase()),
);
}
diff --git a/web/src/services/admin-service-adapter.ts b/web/src/services/admin-service-adapter.ts
index e553e625b0..cef80c7448 100644
--- a/web/src/services/admin-service-adapter.ts
+++ b/web/src/services/admin-service-adapter.ts
@@ -1,5 +1,3 @@
-import { pickByBackend } from '@/utils/backend-variant';
-
export type GoServiceStatus = {
type: string;
name: string;
@@ -11,33 +9,22 @@ export type GoServiceStatus = {
};
export const adaptServiceList = (
- services: AdminService.ListServicesItem[] | GoServiceStatus[],
+ services: GoServiceStatus[],
): AdminService.ListServicesItem[] =>
- pickByBackend({
- go: () =>
- (services as GoServiceStatus[]).map((service) => ({
- id: service.name,
- name: service.name,
- service_type: service.type,
- status: service.status,
- host: service.host || '-',
- port: service.port || '-',
- extra: { elapsed: service.elapsed, message: service.message },
- })),
- python: () => services as AdminService.ListServicesItem[],
- })();
+ services.map((service) => ({
+ id: service.name,
+ name: service.name,
+ service_type: service.type,
+ status: service.status,
+ host: service.host || '-',
+ port: service.port || '-',
+ extra: { elapsed: service.elapsed, message: service.message },
+ }));
export const adaptServiceDetail = (
- detail: AdminService.ServiceDetail | GoServiceStatus,
-): AdminService.ServiceDetail =>
- pickByBackend({
- go: () => {
- const service = detail as GoServiceStatus;
- return {
- service_name: service.name,
- status: service.status,
- message: service,
- };
- },
- python: () => detail as AdminService.ServiceDetail,
- })();
+ detail: GoServiceStatus,
+): AdminService.ServiceDetail => ({
+ service_name: detail.name,
+ status: detail.status,
+ message: detail,
+});
diff --git a/web/src/services/document-filter-adapter.test.ts b/web/src/services/document-filter-adapter.test.ts
index ea71a28802..e281a00dd5 100644
--- a/web/src/services/document-filter-adapter.test.ts
+++ b/web/src/services/document-filter-adapter.test.ts
@@ -1,23 +1,10 @@
-let mockIsGo = false;
-
-jest.mock('@/utils/backend-variant', () => ({
- pickByBackend: ({ go, python }: { go: unknown; python: unknown }) =>
- mockIsGo ? go : python,
-}));
-
import {
adaptDocumentFilter,
adaptDocumentRunStatusFilter,
} from './document-filter-adapter';
describe('document status filter adapter', () => {
- beforeEach(() => {
- mockIsGo = false;
- });
-
- it('groups Go task statuses into the visible document status options', () => {
- mockIsGo = true;
-
+ it('groups task statuses into the visible document status options', () => {
expect(
adaptDocumentFilter({
suffix: { pdf: 8 },
@@ -51,9 +38,7 @@ describe('document status filter adapter', () => {
]);
});
- it('only shows Go status options present in the dataset', () => {
- mockIsGo = true;
-
+ it('only shows status options present in the dataset', () => {
expect(
adaptDocumentFilter({
suffix: { pdf: 2 },
@@ -66,14 +51,11 @@ describe('document status filter adapter', () => {
});
});
- it('keeps the Python filter response and selected status values', () => {
- const filter = {
- suffix: { docx: 2 },
- metadata: {},
- run_status: { '1': 1, '3': 1 },
- };
-
- expect(adaptDocumentFilter(filter)).toEqual(filter);
- expect(adaptDocumentRunStatusFilter(['1', '3'])).toEqual(['1', '3']);
+ it('expands each selected option into its task statuses', () => {
+ expect(adaptDocumentRunStatusFilter(['1', '3'])).toEqual([
+ 'RUNNING',
+ 'STOPPING',
+ 'COMPLETED',
+ ]);
});
});
diff --git a/web/src/services/document-filter-adapter.ts b/web/src/services/document-filter-adapter.ts
index 59202b3ac8..0f88b2c9d1 100644
--- a/web/src/services/document-filter-adapter.ts
+++ b/web/src/services/document-filter-adapter.ts
@@ -4,7 +4,6 @@ import {
RunningStatusOld,
} from '@/constants/knowledge';
import type { IDocumentInfoFilter } from '@/interfaces/database/document';
-import { pickByBackend } from '@/utils/backend-variant';
type DocumentFilterResponse = Omit<IDocumentInfoFilter, 'run_status'> & {
run_status?: IDocumentInfoFilter['run_status'];
@@ -35,24 +34,18 @@ const goStatusOptions = Object.fromEntries(
export const adaptDocumentFilter = (
filter: DocumentFilterResponse,
): IDocumentInfoFilter => {
- const goRunStatus: IDocumentInfoFilter['run_status'] = {};
+ const runStatus: IDocumentInfoFilter['run_status'] = {};
for (const [status, count] of Object.entries(filter.ingestion_status ?? {})) {
const option = goStatusOptions[status];
if (option) {
- goRunStatus[option] = (goRunStatus[option] ?? 0) + count;
+ runStatus[option] = (runStatus[option] ?? 0) + count;
}
}
- return pickByBackend({
- go: { ...filter, run_status: goRunStatus },
- python: { ...filter, run_status: filter.run_status ?? {} },
- });
+ return { ...filter, run_status: runStatus };
};
export const adaptDocumentRunStatusFilter = (
statuses?: string[],
): string[] | undefined =>
- pickByBackend({
- go: statuses?.flatMap((status) => goQueryStatuses[status] ?? [status]),
- python: statuses,
- });
+ statuses?.flatMap((status) => goQueryStatuses[status] ?? [status]);
diff --git a/web/src/services/document-ingest-adapter.test.ts b/web/src/services/document-ingest-adapter.test.ts
index dc9799fcb2..16e4d7c50d 100644
--- a/web/src/services/document-ingest-adapter.test.ts
+++ b/web/src/services/document-ingest-adapter.test.ts
@@ -1,20 +1,7 @@
-let mockIsGo = false;
-
-jest.mock('@/utils/backend-variant', () => ({
- pickByBackend: ({ go, python }: { go: unknown; python: unknown }) =>
- mockIsGo ? go : python,
-}));
-
import { buildDocumentIngestPayload } from './document-ingest-adapter';
describe('buildDocumentIngestPayload', () => {
- beforeEach(() => {
- mockIsGo = false;
- });
-
- it('forces delete for a Go parse request', () => {
- mockIsGo = true;
-
+ it('forces delete for a parse request', () => {
expect(
buildDocumentIngestPayload({
documentIds: ['doc-1'],
@@ -29,25 +16,15 @@ describe('buildDocumentIngestPayload', () => {
});
});
- it('adds delete when a Go parse request has no options', () => {
- mockIsGo = true;
-
+ it('adds delete when a parse request has no options', () => {
expect(
buildDocumentIngestPayload({ documentIds: ['doc-1'], run: 1 }),
).toEqual({ doc_ids: ['doc-1'], run: 1, delete: true });
});
- it('does not add delete to a Go cancel request', () => {
- mockIsGo = true;
-
+ it('does not add delete to a cancel request', () => {
expect(
buildDocumentIngestPayload({ documentIds: ['doc-1'], run: 2 }),
).toEqual({ doc_ids: ['doc-1'], run: 2 });
});
-
- it('preserves the Python parse payload', () => {
- expect(
- buildDocumentIngestPayload({ documentIds: ['doc-1'], run: 1 }),
- ).toEqual({ doc_ids: ['doc-1'], run: 1 });
- });
});
diff --git a/web/src/services/document-ingest-adapter.ts b/web/src/services/document-ingest-adapter.ts
index 5393aea4a1..51475a6739 100644
--- a/web/src/services/document-ingest-adapter.ts
+++ b/web/src/services/document-ingest-adapter.ts
@@ -1,5 +1,3 @@
-import { pickByBackend } from '@/utils/backend-variant';
-
export type DocumentIngestOption = {
delete: boolean;
apply_kb: boolean;
@@ -27,8 +25,5 @@ export const buildDocumentIngestPayload = ({
...(option || {}),
};
- return pickByBackend({
- go: run === 1 ? { ...payload, delete: true } : payload,
- python: payload,
- });
+ return run === 1 ? { ...payload, delete: true } : payload;
};
diff --git a/web/src/utils/__tests__/pipeline-operator.test.ts b/web/src/utils/__tests__/pipeline-operator.test.ts
index 56fdf941c7..ba2cb810b1 100644
--- a/web/src/utils/__tests__/pipeline-operator.test.ts
+++ b/web/src/utils/__tests__/pipeline-operator.test.ts
@@ -5,11 +5,6 @@ import {
transformFormConfigToApi,
} from '@/utils/pipeline-operator';
-let mockIsGoBackend = true;
-jest.mock('@/utils/backend-runtime', () => ({
- getBackendLanguage: () => (mockIsGoBackend ? 'go' : 'python'),
-}));
-
const extractorNode = {
id: 'Extractor:AutoExtractDefault',
data: { form: {} },
@@ -182,10 +177,6 @@ describe('Parser nested setups compatibility', () => {
});
describe('buildOperatorNode dataset-level metadata precedence', () => {
- beforeEach(() => {
- mockIsGoBackend = true;
- });
-
it('seeds the extractor metadata toggle from the dataset-level object', () => {
const node = buildOperatorNode(extractorNode, {
'Extractor:AutoExtractDefault': {
diff --git a/web/src/utils/backend-runtime.ts b/web/src/utils/backend-runtime.ts
deleted file mode 100644
index aac385b518..0000000000
--- a/web/src/utils/backend-runtime.ts
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Backend runtime language detection.
- *
- * Fetches /api/v1/language once at module load (app start) and caches the
- * result. Components subscribe via React's useSyncExternalStore; there is no
- * per-component fetch or useEffect.
- *
- * Pattern: module-level fetch + listener set, same subscription approach as
- * enterprise billingStatus.ts.
- */
-
-type Listener = () => void;
-const listeners = new Set<Listener>();
-
-let backendLanguage: string | null = null;
-
-// Kick off the fetch at module load — app start, not component mount.
-const promise: Promise<string> = fetch('/api/v1/language')
- .then((r) => r.json())
- .then((body: { data?: { language?: string } }) => {
- backendLanguage = body.data?.language === 'go' ? 'go' : 'python';
- listeners.forEach((fn) => fn());
- return backendLanguage;
- })
- .catch(() => {
- backendLanguage = 'python';
- listeners.forEach((fn) => fn());
- return 'python';
- });
-
-export const fetchBackendLanguage = (): Promise<string> => promise;
-
-export const getBackendLanguage = (): string | null => backendLanguage;
-
-export const subscribeBackendLanguage = (listener: Listener): (() => void) => {
- listeners.add(listener);
- return () => {
- listeners.delete(listener);
- };
-};
diff --git a/web/src/utils/backend-variant.tsx b/web/src/utils/backend-variant.tsx
deleted file mode 100644
index 9162f6c79c..0000000000
--- a/web/src/utils/backend-variant.tsx
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Backend variant dispatch primitives.
- *
- * This module is the ONLY supported way to branch UI/logic on the backend
- * language (Go vs Python). It wraps the raw store in
- * `@/utils/backend-runtime`, which no other file may import (enforced by
- * oxlint `no-restricted-imports`); the only other exception is the bootstrap
- * gate in `main.tsx`.
- *
- * Conventions (see web/AGENTS.md):
- * - JSX divergence: dispatch through `<BackendVariant go={...} python={...} />`
- * at a dispatcher file (page `index.tsx` / form dispatcher), never inline
- * in business components.
- * - Value divergence (field names, defaults, payload transforms): select
- * through `pickByBackend({ go, python })` inside an adapter file.
- * - Hook-level needs (e.g. a query `enabled` flag): `useIsGoBackend()`.
- *
- * The app render is gated on the language fetch in `main.tsx`, so below the
- * gate the variant never changes for the session lifetime and both sync
- * reads (`pickByBackend`) and hook reads are race-free.
- */
-
-// oxlint-disable-next-line no-restricted-imports -- sanctioned boundary over the raw store
-import {
- getBackendLanguage,
- subscribeBackendLanguage,
-} from '@/utils/backend-runtime';
-import { ReactElement, ReactNode, useSyncExternalStore } from 'react';
-
-// The store collapses every non-Go answer (including the not-yet-loaded and
-// fetch-failed cases) to Python, so the world is binary below the gate.
-const isGo = (): boolean => getBackendLanguage() === 'go';
-
-/** Whether the active backend is the Go one. Safe to call anywhere below the bootstrap gate. */
-export function useIsGoBackend(): boolean {
- return useSyncExternalStore(subscribeBackendLanguage, isGo, isGo);
-}
-
-type BackendVariantProps = {
- go: ReactNode;
- python: ReactNode;
-};
-
-/** Render the subtree matching the current backend. Use at dispatcher files only. */
-export function BackendVariant({
- go,
- python,
-}: BackendVariantProps): ReactElement {
- return <>{useIsGoBackend() ? go : python}</>;
-}
-
-/** Pick a value per backend, synchronously. Use inside adapter/dispatcher files only. */
-export function pickByBackend<T>(variants: { go: T; python: T }): T {
- return isGo() ? variants.go : variants.python;
-}
diff --git a/web/src/utils/pipeline-operator.ts b/web/src/utils/pipeline-operator.ts
index 7e8ee60213..1be071b63e 100644
--- a/web/src/utils/pipeline-operator.ts
+++ b/web/src/utils/pipeline-operator.ts
@@ -35,7 +35,6 @@ import {
transformTitleChunkerParams,
transformTokenChunkerParams,
} from '@/pages/agent/utils';
-import { pickByBackend } from '@/utils/backend-variant';
import { cloneDeep, isEmpty, omit } from 'lodash';
export const FileNodeId = 'File';
@@ -112,8 +111,8 @@ function transformLevelsToRules(
.filter((rule) => rule !== null);
}
-// Python form: flatten the DSL prompts array into the form's single field;
-// the Python extractor form consumes the legacy flat fields as-is.
+// Base normalization: flatten the DSL prompts array into the form's single
+// field. The Go transform below builds on top of this.
function transformExtractorConfigToFormPython(
config: Record<string, any> | undefined,
): Record<string, any> {
@@ -208,10 +207,7 @@ function transformExtractorConfigToFormGo(
export function transformExtractorConfigToForm(
config: Record<string, any> | undefined,
): Record<string, any> {
- return pickByBackend({
- go: transformExtractorConfigToFormGo,
- python: transformExtractorConfigToFormPython,
- })(config);
+ return transformExtractorConfigToFormGo(config);
}
/**