feat: Add PDF parser selection to Agent Begin and Await Response comp… (#13325)

### Issue: #12756

### What problem does this PR solve?

When users upload files through Agent's Begin or Await Response
components, the parsing is hardcoded to "Plain Text", ignoring all other
available parsers (DeepDOC, TCADP, Docling, MinerU, PaddleOCR). This PR
adds a PDF parser dropdown to these components so users can select the
appropriate parser for their file inputs.


### Changes

**Backend**
- `agent/component/fillup.py` - Added `layout_recognize` param to
`UserFillUpParam`, forwarded to `FileService.get_files()`
- `agent/component/begin.py` - Same forwarding in `Begin._invoke()`
- `agent/canvas.py` - Extract Begin's `layout_recognize` for `sys.files`
parsing, added param to `get_files_async()` / `get_files()`
- `api/db/services/file_service.py` - Added `layout_recognize` param to
`parse()` and `get_files()`, replacing hardcoded `"Plain Text"`
- `rag/app/naive.py` - Added `"plain text"` and `"tcadp parser"` aliases
to PARSERS dict to match dropdown values after `.lower()`

**Frontend**
- `web/src/pages/agent/form/begin-form/index.tsx` - Show
`LayoutRecognizeFormField` dropdown when file inputs exist
- `web/src/pages/agent/form/begin-form/schema.ts` - Added
`layout_recognize` to Zod schema
- `web/src/pages/agent/form/user-fill-up-form/index.tsx` - Same dropdown
for Await Response component


### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
statxc
2026-03-04 05:09:33 +02:00
committed by GitHub
parent 7715bad04e
commit 839b603768
7 changed files with 55 additions and 15 deletions

View File

@@ -1,4 +1,5 @@
import { Collapse } from '@/components/collapse';
import { LayoutRecognizeFormField } from '@/components/layout-recognize-form-field';
import { Button } from '@/components/ui/button';
import {
Form,
@@ -15,10 +16,10 @@ import { FormTooltip } from '@/components/ui/tooltip';
import { zodResolver } from '@hookform/resolvers/zod';
import { t } from 'i18next';
import { Plus } from 'lucide-react';
import { memo, useEffect, useRef } from 'react';
import { memo, useEffect, useMemo, useRef } from 'react';
import { useForm, useWatch } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
import { AgentDialogueMode } from '../../constant';
import { AgentDialogueMode, BeginQueryType } from '../../constant';
import { INextOperatorForm } from '../../interface';
import { ParameterDialog } from './parameter-dialog';
import { QueryTable } from './query-table';
@@ -51,6 +52,11 @@ function BeginForm({ node }: INextOperatorForm) {
const inputs = useWatch({ control: form.control, name: 'inputs' });
const mode = useWatch({ control: form.control, name: 'mode' });
const hasFileInput = useMemo(
() => inputs?.some((x) => x.type === BeginQueryType.File),
[inputs],
);
const enablePrologue = useWatch({
control: form.control,
name: 'enablePrologue',
@@ -193,6 +199,14 @@ function BeginForm({ node }: INextOperatorForm) {
submit={ok}
></ParameterDialog>
)}
{hasFileInput && (
<LayoutRecognizeFormField
name="layout_recognize"
horizontal={false}
showMineruOptions={false}
showPaddleocrOptions={false}
></LayoutRecognizeFormField>
)}
</>
)}
</Form>

View File

@@ -5,6 +5,7 @@ export const BeginFormSchema = z.object({
enablePrologue: z.boolean().optional(),
prologue: z.string().trim().optional(),
mode: z.string(),
layout_recognize: z.string().optional(),
inputs: z
.array(
z.object({

View File

@@ -1,4 +1,5 @@
import { Collapse } from '@/components/collapse';
import { LayoutRecognizeFormField } from '@/components/layout-recognize-form-field';
import { Button } from '@/components/ui/button';
import {
Form,
@@ -12,10 +13,11 @@ import { Switch } from '@/components/ui/switch';
import { FormTooltip } from '@/components/ui/tooltip';
import { zodResolver } from '@hookform/resolvers/zod';
import { Plus } from 'lucide-react';
import { memo } from 'react';
import { memo, useMemo } from 'react';
import { useForm, useWatch } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
import { z } from 'zod';
import { BeginQueryType } from '../../constant';
import { BeginQuery, INextOperatorForm } from '../../interface';
import { ParameterDialog } from '../begin-form/parameter-dialog';
import { QueryTable } from '../begin-form/query-table';
@@ -33,6 +35,7 @@ function UserFillUpForm({ node }: INextOperatorForm) {
const FormSchema = z.object({
enable_tips: z.boolean().optional(),
tips: z.string().trim().optional(),
layout_recognize: z.string().optional(),
inputs: z
.array(
z.object({
@@ -59,6 +62,11 @@ function UserFillUpForm({ node }: INextOperatorForm) {
name: 'inputs',
});
const hasFileInput = useMemo(
() => inputs?.some((x) => x.type === BeginQueryType.File),
[inputs],
);
const outputList = inputs?.map((item) => ({
title: item.name,
type: item.type,
@@ -155,6 +163,14 @@ function UserFillUpForm({ node }: INextOperatorForm) {
submit={ok}
></ParameterDialog>
)}
{hasFileInput && (
<LayoutRecognizeFormField
name="layout_recognize"
horizontal={false}
showMineruOptions={false}
showPaddleocrOptions={false}
></LayoutRecognizeFormField>
)}
</Form>
<Output list={outputList}></Output>
</section>