RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
/*
* 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 { RAGFlowFormItem } from '@/components/ragflow-form';
import { Input } from '@/components/ui/input';
import { SelectWithSearch } from './originui/select-with-search';
import { LLMFactory } from '@/constants/llm';
import { buildOptions } from '@/utils/form';
import { useFormContext, useWatch } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
const algorithmOptions = buildOptions([
'PaddleOCR-VL-1.6',
'PaddleOCR-VL-1.5',
'PaddleOCR-VL',
'PP-OCRv6',
'PP-OCRv5',
'PP-StructureV3',
]);
export function PaddleOCROptionsFormField({
namePrefix = 'parser_config',
}: {
namePrefix?: string;
}) {
const form = useFormContext();
const { t } = useTranslation();
const buildName = (field: string) =>
namePrefix ? `${namePrefix}.${field}` : field;
const layoutRecognize = useWatch({
control: form.control,
name: 'parser_config.layout_recognize',
});
// Check if PaddleOCR is selected (the value contains 'PaddleOCR' or matches the factory name)
const isPaddleOCRSelected =
layoutRecognize?.includes(LLMFactory.PaddleOCR) ||
layoutRecognize?.toLowerCase()?.includes('paddleocr');
if (!isPaddleOCRSelected) {
return null;
}
return (
<div className="space-y-4 border-l-2 border-primary/30 pl-4 ml-2">
<div className="text-sm font-medium text-text-secondary">
{t('knowledgeConfiguration.paddleocrOptions', 'PaddleOCR Options')}
</div>
<RAGFlowFormItem
name={buildName('paddleocr_api_url')}
label={t('knowledgeConfiguration.paddleocrApiUrl', 'PaddleOCR API URL')}
tooltip={t(
'knowledgeConfiguration.paddleocrApiUrlTip',
'The API endpoint URL for PaddleOCR service',
)}
horizontal={true}
>
{(field) => (
<Input
{...field}
placeholder={t('knowledgeConfiguration.paddleocrApiUrlPlaceholder')}
/>
)}
</RAGFlowFormItem>
<RAGFlowFormItem
name={buildName('paddleocr_access_token')}
label={t(
'knowledgeConfiguration.paddleocrAccessToken',
'AI Studio Access Token',
)}
tooltip={t(
'knowledgeConfiguration.paddleocrAccessTokenTip',
'Access token for PaddleOCR API',
)}
horizontal={true}
>
{(field) => (
<Input
{...field}
placeholder={t(
'knowledgeConfiguration.paddleocrAccessTokenPlaceholder',
)}
/>
)}
</RAGFlowFormItem>
<RAGFlowFormItem
name={buildName('paddleocr_algorithm')}
label={t(
'knowledgeConfiguration.paddleocrAlgorithm',
'PaddleOCR Algorithm',
)}
tooltip={t(
'knowledgeConfiguration.paddleocrAlgorithmTip',
'Algorithm to use for PaddleOCR parsing',
)}
horizontal={true}
>
{(field) => (
<SelectWithSearch
value={field.value || undefined}
onChange={field.onChange}
options={algorithmOptions}
placeholder={t('common.selectPlaceholder', 'Select value')}
/>
)}
</RAGFlowFormItem>
</div>
);
}