### What problem does this PR solve? Feat: Render WikipediaForm and BaiduForm with shadcn-ui. #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)tags/v0.17.1
| name={'top_n'} | name={'top_n'} | ||||
| render={({ field }) => ( | render={({ field }) => ( | ||||
| <FormItem> | <FormItem> | ||||
| <FormLabel>{t('topN')}</FormLabel> | |||||
| <FormLabel tooltip={t('topNTip')}>{t('topN')}</FormLabel> | |||||
| <FormControl> | <FormControl> | ||||
| <SingleFormSlider {...field} max={max}></SingleFormSlider> | <SingleFormSlider {...field} max={max}></SingleFormSlider> | ||||
| </FormControl> | </FormControl> |
| }, | }, | ||||
| [Operator.Baidu]: { | [Operator.Baidu]: { | ||||
| component: BaiduForm, | component: BaiduForm, | ||||
| defaultValues: {}, | |||||
| schema: z.object({}), | |||||
| defaultValues: { top_n: 10 }, | |||||
| schema: z.object({ top_n: z.number() }), | |||||
| }, | }, | ||||
| [Operator.DuckDuckGo]: { | [Operator.DuckDuckGo]: { | ||||
| component: DuckDuckGoForm, | component: DuckDuckGoForm, | ||||
| defaultValues: {}, | |||||
| schema: z.object({}), | |||||
| defaultValues: { | |||||
| top_n: 10, | |||||
| channel: 'text', | |||||
| }, | |||||
| schema: z.object({ | |||||
| top_n: z.number(), | |||||
| }), | |||||
| }, | }, | ||||
| [Operator.KeywordExtract]: { | [Operator.KeywordExtract]: { | ||||
| component: KeywordExtractForm, | component: KeywordExtractForm, | ||||
| defaultValues: {}, | |||||
| schema: z.object({}), | |||||
| defaultValues: { top_n: 3 }, | |||||
| schema: z.object({ | |||||
| llm_id: z.string(), | |||||
| top_n: z.number(), | |||||
| }), | |||||
| }, | }, | ||||
| [Operator.Wikipedia]: { | [Operator.Wikipedia]: { | ||||
| component: WikipediaForm, | component: WikipediaForm, | ||||
| defaultValues: {}, | |||||
| schema: z.object({}), | |||||
| defaultValues: { | |||||
| top_n: 10, | |||||
| }, | |||||
| schema: z.object({ | |||||
| language: z.string(), | |||||
| top_n: z.number(), | |||||
| }), | |||||
| }, | }, | ||||
| [Operator.PubMed]: { | [Operator.PubMed]: { | ||||
| component: PubMedForm, | component: PubMedForm, | ||||
| }, | }, | ||||
| [Operator.WenCai]: { | [Operator.WenCai]: { | ||||
| component: WenCaiForm, | component: WenCaiForm, | ||||
| defaultValues: {}, | |||||
| schema: z.object({}), | |||||
| defaultValues: { | |||||
| top_n: 20, | |||||
| }, | |||||
| schema: z.object({ | |||||
| top_n: z.number(), | |||||
| query_type: z.string(), | |||||
| }), | |||||
| }, | }, | ||||
| [Operator.AkShare]: { | [Operator.AkShare]: { | ||||
| component: AkShareForm, | component: AkShareForm, | ||||
| defaultValues: {}, | |||||
| schema: z.object({}), | |||||
| defaultValues: { | |||||
| top_n: 10, | |||||
| }, | |||||
| schema: z.object({ | |||||
| top_n: z.number(), | |||||
| }), | |||||
| }, | }, | ||||
| [Operator.YahooFinance]: { | [Operator.YahooFinance]: { | ||||
| component: YahooFinanceForm, | component: YahooFinanceForm, |
| import TopNItem from '@/components/top-n-item'; | |||||
| import { Form } from 'antd'; | |||||
| import { IOperatorForm } from '../../interface'; | |||||
| import DynamicInputVariable from '../components/dynamic-input-variable'; | |||||
| import { TopNFormField } from '@/components/top-n-item'; | |||||
| import { Form } from '@/components/ui/form'; | |||||
| import { INextOperatorForm } from '../../interface'; | |||||
| import { DynamicInputVariable } from '../components/next-dynamic-input-variable'; | |||||
| const AkShareForm = ({ onValuesChange, form, node }: IOperatorForm) => { | |||||
| const AkShareForm = ({ form, node }: INextOperatorForm) => { | |||||
| return ( | return ( | ||||
| <Form | |||||
| name="basic" | |||||
| autoComplete="off" | |||||
| form={form} | |||||
| onValuesChange={onValuesChange} | |||||
| layout={'vertical'} | |||||
| > | |||||
| <DynamicInputVariable node={node}></DynamicInputVariable> | |||||
| <TopNItem initialValue={10} max={99}></TopNItem> | |||||
| <Form {...form}> | |||||
| <form | |||||
| className="space-y-6" | |||||
| onSubmit={(e) => { | |||||
| e.preventDefault(); | |||||
| }} | |||||
| > | |||||
| <DynamicInputVariable node={node}></DynamicInputVariable> | |||||
| <TopNFormField max={99}></TopNFormField> | |||||
| </form> | |||||
| </Form> | </Form> | ||||
| ); | ); | ||||
| }; | }; |
| import TopNItem from '@/components/top-n-item'; | |||||
| import { Form } from 'antd'; | |||||
| import { IOperatorForm } from '../../interface'; | |||||
| import DynamicInputVariable from '../components/dynamic-input-variable'; | |||||
| import { TopNFormField } from '@/components/top-n-item'; | |||||
| import { Form } from '@/components/ui/form'; | |||||
| import { INextOperatorForm } from '../../interface'; | |||||
| import { DynamicInputVariable } from '../components/next-dynamic-input-variable'; | |||||
| const BaiduForm = ({ onValuesChange, form, node }: IOperatorForm) => { | |||||
| const BaiduForm = ({ form, node }: INextOperatorForm) => { | |||||
| return ( | return ( | ||||
| <Form | |||||
| name="basic" | |||||
| autoComplete="off" | |||||
| form={form} | |||||
| onValuesChange={onValuesChange} | |||||
| layout={'vertical'} | |||||
| > | |||||
| <DynamicInputVariable node={node}></DynamicInputVariable> | |||||
| <TopNItem initialValue={10}></TopNItem> | |||||
| <Form {...form}> | |||||
| <form | |||||
| className="space-y-6" | |||||
| onSubmit={(e) => { | |||||
| e.preventDefault(); | |||||
| }} | |||||
| > | |||||
| <DynamicInputVariable node={node}></DynamicInputVariable> | |||||
| <TopNFormField></TopNFormField> | |||||
| </form> | |||||
| </Form> | </Form> | ||||
| ); | ); | ||||
| }; | }; |
| import TopNItem from '@/components/top-n-item'; | |||||
| import { TopNFormField } from '@/components/top-n-item'; | |||||
| import { | |||||
| Form, | |||||
| FormControl, | |||||
| FormField, | |||||
| FormItem, | |||||
| FormLabel, | |||||
| FormMessage, | |||||
| } from '@/components/ui/form'; | |||||
| import { RAGFlowSelect } from '@/components/ui/select'; | |||||
| import { useTranslate } from '@/hooks/common-hooks'; | import { useTranslate } from '@/hooks/common-hooks'; | ||||
| import { Form, Select } from 'antd'; | |||||
| import { useMemo } from 'react'; | import { useMemo } from 'react'; | ||||
| import { Channel } from '../../constant'; | import { Channel } from '../../constant'; | ||||
| import { IOperatorForm } from '../../interface'; | |||||
| import DynamicInputVariable from '../components/dynamic-input-variable'; | |||||
| import { INextOperatorForm } from '../../interface'; | |||||
| import { DynamicInputVariable } from '../components/next-dynamic-input-variable'; | |||||
| const DuckDuckGoForm = ({ onValuesChange, form, node }: IOperatorForm) => { | |||||
| const DuckDuckGoForm = ({ form, node }: INextOperatorForm) => { | |||||
| const { t } = useTranslate('flow'); | const { t } = useTranslate('flow'); | ||||
| const options = useMemo(() => { | const options = useMemo(() => { | ||||
| }, [t]); | }, [t]); | ||||
| return ( | return ( | ||||
| <Form | |||||
| name="basic" | |||||
| autoComplete="off" | |||||
| form={form} | |||||
| onValuesChange={onValuesChange} | |||||
| layout={'vertical'} | |||||
| > | |||||
| <DynamicInputVariable node={node}></DynamicInputVariable> | |||||
| <TopNItem initialValue={10}></TopNItem> | |||||
| <Form.Item | |||||
| label={t('channel')} | |||||
| name={'channel'} | |||||
| tooltip={t('channelTip')} | |||||
| initialValue={'text'} | |||||
| <Form {...form}> | |||||
| <form | |||||
| className="space-y-6" | |||||
| onSubmit={(e) => { | |||||
| e.preventDefault(); | |||||
| }} | |||||
| > | > | ||||
| <Select options={options}></Select> | |||||
| </Form.Item> | |||||
| <DynamicInputVariable node={node}></DynamicInputVariable> | |||||
| <TopNFormField></TopNFormField> | |||||
| <FormField | |||||
| control={form.control} | |||||
| name="channel" | |||||
| render={({ field }) => ( | |||||
| <FormItem> | |||||
| <FormLabel tooltip={t('channelTip')}>{t('channel')}</FormLabel> | |||||
| <FormControl> | |||||
| <RAGFlowSelect {...field} options={options} /> | |||||
| </FormControl> | |||||
| <FormMessage /> | |||||
| </FormItem> | |||||
| )} | |||||
| /> | |||||
| </form> | |||||
| </Form> | </Form> | ||||
| ); | ); | ||||
| }; | }; |
| import LLMSelect from '@/components/llm-select'; | |||||
| import TopNItem from '@/components/top-n-item'; | |||||
| import { useTranslate } from '@/hooks/common-hooks'; | |||||
| import { Form } from 'antd'; | |||||
| import { IOperatorForm } from '../../interface'; | |||||
| import DynamicInputVariable from '../components/dynamic-input-variable'; | |||||
| import { NextLLMSelect } from '@/components/llm-select'; | |||||
| import { TopNFormField } from '@/components/top-n-item'; | |||||
| import { | |||||
| Form, | |||||
| FormControl, | |||||
| FormField, | |||||
| FormItem, | |||||
| FormLabel, | |||||
| FormMessage, | |||||
| } from '@/components/ui/form'; | |||||
| import { useTranslation } from 'react-i18next'; | |||||
| import { INextOperatorForm } from '../../interface'; | |||||
| import { DynamicInputVariable } from '../components/next-dynamic-input-variable'; | |||||
| const KeywordExtractForm = ({ onValuesChange, form, node }: IOperatorForm) => { | |||||
| const { t } = useTranslate('flow'); | |||||
| const KeywordExtractForm = ({ form, node }: INextOperatorForm) => { | |||||
| const { t } = useTranslation(); | |||||
| return ( | return ( | ||||
| <Form | |||||
| name="basic" | |||||
| autoComplete="off" | |||||
| form={form} | |||||
| onValuesChange={onValuesChange} | |||||
| layout={'vertical'} | |||||
| > | |||||
| <DynamicInputVariable node={node}></DynamicInputVariable> | |||||
| <Form.Item | |||||
| name={'llm_id'} | |||||
| label={t('model', { keyPrefix: 'chat' })} | |||||
| tooltip={t('modelTip', { keyPrefix: 'chat' })} | |||||
| <Form {...form}> | |||||
| <form | |||||
| className="space-y-6" | |||||
| onSubmit={(e) => { | |||||
| e.preventDefault(); | |||||
| }} | |||||
| > | > | ||||
| <LLMSelect></LLMSelect> | |||||
| </Form.Item> | |||||
| <TopNItem initialValue={3}></TopNItem> | |||||
| <DynamicInputVariable node={node}></DynamicInputVariable> | |||||
| <FormField | |||||
| control={form.control} | |||||
| name="llm_id" | |||||
| render={({ field }) => ( | |||||
| <FormItem> | |||||
| <FormLabel tooltip={t('chat.modelTip')}> | |||||
| {t('chat.model')} | |||||
| </FormLabel> | |||||
| <FormControl> | |||||
| <NextLLMSelect {...field} /> | |||||
| </FormControl> | |||||
| <FormMessage /> | |||||
| </FormItem> | |||||
| )} | |||||
| /> | |||||
| <TopNFormField></TopNFormField> | |||||
| </form> | |||||
| </Form> | </Form> | ||||
| ); | ); | ||||
| }; | }; |
| import TopNItem from '@/components/top-n-item'; | |||||
| import { useTranslate } from '@/hooks/common-hooks'; | |||||
| import { Form, Select } from 'antd'; | |||||
| import { TopNFormField } from '@/components/top-n-item'; | |||||
| import { | |||||
| Form, | |||||
| FormControl, | |||||
| FormField, | |||||
| FormItem, | |||||
| FormLabel, | |||||
| FormMessage, | |||||
| } from '@/components/ui/form'; | |||||
| import { RAGFlowSelect } from '@/components/ui/select'; | |||||
| import { useMemo } from 'react'; | import { useMemo } from 'react'; | ||||
| import { useTranslation } from 'react-i18next'; | |||||
| import { WenCaiQueryTypeOptions } from '../../constant'; | import { WenCaiQueryTypeOptions } from '../../constant'; | ||||
| import { IOperatorForm } from '../../interface'; | |||||
| import DynamicInputVariable from '../components/dynamic-input-variable'; | |||||
| import { INextOperatorForm } from '../../interface'; | |||||
| import { DynamicInputVariable } from '../components/next-dynamic-input-variable'; | |||||
| const WenCaiForm = ({ onValuesChange, form, node }: IOperatorForm) => { | |||||
| const { t } = useTranslate('flow'); | |||||
| const WenCaiForm = ({ form, node }: INextOperatorForm) => { | |||||
| const { t } = useTranslation(); | |||||
| const wenCaiQueryTypeOptions = useMemo(() => { | const wenCaiQueryTypeOptions = useMemo(() => { | ||||
| return WenCaiQueryTypeOptions.map((x) => ({ | return WenCaiQueryTypeOptions.map((x) => ({ | ||||
| value: x, | value: x, | ||||
| label: t(`wenCaiQueryTypeOptions.${x}`), | |||||
| label: t(`flow.wenCaiQueryTypeOptions.${x}`), | |||||
| })); | })); | ||||
| }, [t]); | }, [t]); | ||||
| return ( | return ( | ||||
| <Form | |||||
| name="basic" | |||||
| autoComplete="off" | |||||
| form={form} | |||||
| onValuesChange={onValuesChange} | |||||
| layout={'vertical'} | |||||
| > | |||||
| <DynamicInputVariable node={node}></DynamicInputVariable> | |||||
| <TopNItem initialValue={20} max={99}></TopNItem> | |||||
| <Form.Item label={t('queryType')} name={'query_type'}> | |||||
| <Select options={wenCaiQueryTypeOptions}></Select> | |||||
| </Form.Item> | |||||
| <Form {...form}> | |||||
| <form | |||||
| className="space-y-6" | |||||
| onSubmit={(e) => { | |||||
| e.preventDefault(); | |||||
| }} | |||||
| > | |||||
| <DynamicInputVariable node={node}></DynamicInputVariable> | |||||
| <TopNFormField max={99}></TopNFormField> | |||||
| <FormField | |||||
| control={form.control} | |||||
| name="query_type" | |||||
| render={({ field }) => ( | |||||
| <FormItem> | |||||
| <FormLabel>{t('flow.queryType')}</FormLabel> | |||||
| <FormControl> | |||||
| <RAGFlowSelect {...field} options={wenCaiQueryTypeOptions} /> | |||||
| </FormControl> | |||||
| <FormMessage /> | |||||
| </FormItem> | |||||
| )} | |||||
| /> | |||||
| </form> | |||||
| </Form> | </Form> | ||||
| ); | ); | ||||
| }; | }; |
| import TopNItem from '@/components/top-n-item'; | |||||
| import { TopNFormField } from '@/components/top-n-item'; | |||||
| import { | |||||
| Form, | |||||
| FormControl, | |||||
| FormField, | |||||
| FormItem, | |||||
| FormLabel, | |||||
| FormMessage, | |||||
| } from '@/components/ui/form'; | |||||
| import { RAGFlowSelect } from '@/components/ui/select'; | |||||
| import { useTranslate } from '@/hooks/common-hooks'; | import { useTranslate } from '@/hooks/common-hooks'; | ||||
| import { Form, Select } from 'antd'; | |||||
| import { LanguageOptions } from '../../constant'; | import { LanguageOptions } from '../../constant'; | ||||
| import { IOperatorForm } from '../../interface'; | |||||
| import DynamicInputVariable from '../components/dynamic-input-variable'; | |||||
| import { INextOperatorForm } from '../../interface'; | |||||
| import { DynamicInputVariable } from '../components/next-dynamic-input-variable'; | |||||
| const WikipediaForm = ({ onValuesChange, form, node }: IOperatorForm) => { | |||||
| const WikipediaForm = ({ form, node }: INextOperatorForm) => { | |||||
| const { t } = useTranslate('common'); | const { t } = useTranslate('common'); | ||||
| return ( | return ( | ||||
| <Form | |||||
| name="basic" | |||||
| autoComplete="off" | |||||
| form={form} | |||||
| onValuesChange={onValuesChange} | |||||
| layout={'vertical'} | |||||
| > | |||||
| <DynamicInputVariable node={node}></DynamicInputVariable> | |||||
| <TopNItem initialValue={10}></TopNItem> | |||||
| <Form.Item label={t('language')} name={'language'}> | |||||
| <Select options={LanguageOptions}></Select> | |||||
| </Form.Item> | |||||
| <Form {...form}> | |||||
| <form | |||||
| className="space-y-6" | |||||
| onSubmit={(e) => { | |||||
| e.preventDefault(); | |||||
| }} | |||||
| > | |||||
| <DynamicInputVariable node={node}></DynamicInputVariable> | |||||
| <TopNFormField></TopNFormField> | |||||
| <FormField | |||||
| control={form.control} | |||||
| name="language" | |||||
| render={({ field }) => ( | |||||
| <FormItem> | |||||
| <FormLabel>{t('language')}</FormLabel> | |||||
| <FormControl> | |||||
| <RAGFlowSelect {...field} options={LanguageOptions} /> | |||||
| </FormControl> | |||||
| <FormMessage /> | |||||
| </FormItem> | |||||
| )} | |||||
| /> | |||||
| </form> | |||||
| </Form> | </Form> | ||||
| ); | ); | ||||
| }; | }; |