mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-06-30 10:15:15 +08:00
### 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)
This commit is contained in:
parent
c813c1ff4c
commit
1075b975c5
@ -50,7 +50,7 @@ export function TopNFormField({ max = 30 }: SimilaritySliderFormFieldProps) {
|
|||||||
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>
|
||||||
|
@ -125,23 +125,36 @@ export function useFormConfigMap() {
|
|||||||
},
|
},
|
||||||
[Operator.Baidu]: {
|
[Operator.Baidu]: {
|
||||||
component: BaiduForm,
|
component: BaiduForm,
|
||||||
defaultValues: {},
|
defaultValues: { top_n: 10 },
|
||||||
schema: z.object({}),
|
schema: z.object({ top_n: z.number() }),
|
||||||
},
|
},
|
||||||
[Operator.DuckDuckGo]: {
|
[Operator.DuckDuckGo]: {
|
||||||
component: DuckDuckGoForm,
|
component: DuckDuckGoForm,
|
||||||
defaultValues: {},
|
defaultValues: {
|
||||||
schema: z.object({}),
|
top_n: 10,
|
||||||
|
channel: 'text',
|
||||||
|
},
|
||||||
|
schema: z.object({
|
||||||
|
top_n: z.number(),
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
[Operator.KeywordExtract]: {
|
[Operator.KeywordExtract]: {
|
||||||
component: KeywordExtractForm,
|
component: KeywordExtractForm,
|
||||||
defaultValues: {},
|
defaultValues: { top_n: 3 },
|
||||||
schema: z.object({}),
|
schema: z.object({
|
||||||
|
llm_id: z.string(),
|
||||||
|
top_n: z.number(),
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
[Operator.Wikipedia]: {
|
[Operator.Wikipedia]: {
|
||||||
component: WikipediaForm,
|
component: WikipediaForm,
|
||||||
defaultValues: {},
|
defaultValues: {
|
||||||
schema: z.object({}),
|
top_n: 10,
|
||||||
|
},
|
||||||
|
schema: z.object({
|
||||||
|
language: z.string(),
|
||||||
|
top_n: z.number(),
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
[Operator.PubMed]: {
|
[Operator.PubMed]: {
|
||||||
component: PubMedForm,
|
component: PubMedForm,
|
||||||
@ -206,13 +219,22 @@ export function useFormConfigMap() {
|
|||||||
},
|
},
|
||||||
[Operator.WenCai]: {
|
[Operator.WenCai]: {
|
||||||
component: WenCaiForm,
|
component: WenCaiForm,
|
||||||
defaultValues: {},
|
defaultValues: {
|
||||||
schema: z.object({}),
|
top_n: 20,
|
||||||
|
},
|
||||||
|
schema: z.object({
|
||||||
|
top_n: z.number(),
|
||||||
|
query_type: z.string(),
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
[Operator.AkShare]: {
|
[Operator.AkShare]: {
|
||||||
component: AkShareForm,
|
component: AkShareForm,
|
||||||
defaultValues: {},
|
defaultValues: {
|
||||||
schema: z.object({}),
|
top_n: 10,
|
||||||
|
},
|
||||||
|
schema: z.object({
|
||||||
|
top_n: z.number(),
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
[Operator.YahooFinance]: {
|
[Operator.YahooFinance]: {
|
||||||
component: YahooFinanceForm,
|
component: YahooFinanceForm,
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
import TopNItem from '@/components/top-n-item';
|
import { TopNFormField } from '@/components/top-n-item';
|
||||||
import { Form } from 'antd';
|
import { Form } from '@/components/ui/form';
|
||||||
import { IOperatorForm } from '../../interface';
|
import { INextOperatorForm } from '../../interface';
|
||||||
import DynamicInputVariable from '../components/dynamic-input-variable';
|
import { DynamicInputVariable } from '../components/next-dynamic-input-variable';
|
||||||
|
|
||||||
const AkShareForm = ({ onValuesChange, form, node }: IOperatorForm) => {
|
const AkShareForm = ({ form, node }: INextOperatorForm) => {
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form {...form}>
|
||||||
name="basic"
|
<form
|
||||||
autoComplete="off"
|
className="space-y-6"
|
||||||
form={form}
|
onSubmit={(e) => {
|
||||||
onValuesChange={onValuesChange}
|
e.preventDefault();
|
||||||
layout={'vertical'}
|
}}
|
||||||
>
|
>
|
||||||
<DynamicInputVariable node={node}></DynamicInputVariable>
|
<DynamicInputVariable node={node}></DynamicInputVariable>
|
||||||
<TopNItem initialValue={10} max={99}></TopNItem>
|
<TopNFormField max={99}></TopNFormField>
|
||||||
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
import TopNItem from '@/components/top-n-item';
|
import { TopNFormField } from '@/components/top-n-item';
|
||||||
import { Form } from 'antd';
|
import { Form } from '@/components/ui/form';
|
||||||
import { IOperatorForm } from '../../interface';
|
import { INextOperatorForm } from '../../interface';
|
||||||
import DynamicInputVariable from '../components/dynamic-input-variable';
|
import { DynamicInputVariable } from '../components/next-dynamic-input-variable';
|
||||||
|
|
||||||
const BaiduForm = ({ onValuesChange, form, node }: IOperatorForm) => {
|
const BaiduForm = ({ form, node }: INextOperatorForm) => {
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form {...form}>
|
||||||
name="basic"
|
<form
|
||||||
autoComplete="off"
|
className="space-y-6"
|
||||||
form={form}
|
onSubmit={(e) => {
|
||||||
onValuesChange={onValuesChange}
|
e.preventDefault();
|
||||||
layout={'vertical'}
|
}}
|
||||||
>
|
>
|
||||||
<DynamicInputVariable node={node}></DynamicInputVariable>
|
<DynamicInputVariable node={node}></DynamicInputVariable>
|
||||||
<TopNItem initialValue={10}></TopNItem>
|
<TopNFormField></TopNFormField>
|
||||||
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,12 +1,20 @@
|
|||||||
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 { INextOperatorForm } from '../../interface';
|
||||||
import DynamicInputVariable from '../components/dynamic-input-variable';
|
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(() => {
|
||||||
@ -14,23 +22,29 @@ const DuckDuckGoForm = ({ onValuesChange, form, node }: IOperatorForm) => {
|
|||||||
}, [t]);
|
}, [t]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form {...form}>
|
||||||
name="basic"
|
<form
|
||||||
autoComplete="off"
|
className="space-y-6"
|
||||||
form={form}
|
onSubmit={(e) => {
|
||||||
onValuesChange={onValuesChange}
|
e.preventDefault();
|
||||||
layout={'vertical'}
|
}}
|
||||||
>
|
|
||||||
<DynamicInputVariable node={node}></DynamicInputVariable>
|
|
||||||
<TopNItem initialValue={10}></TopNItem>
|
|
||||||
<Form.Item
|
|
||||||
label={t('channel')}
|
|
||||||
name={'channel'}
|
|
||||||
tooltip={t('channelTip')}
|
|
||||||
initialValue={'text'}
|
|
||||||
>
|
>
|
||||||
<Select options={options}></Select>
|
<DynamicInputVariable node={node}></DynamicInputVariable>
|
||||||
</Form.Item>
|
<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>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,30 +1,46 @@
|
|||||||
import LLMSelect from '@/components/llm-select';
|
import { NextLLMSelect } from '@/components/llm-select';
|
||||||
import TopNItem from '@/components/top-n-item';
|
import { TopNFormField } from '@/components/top-n-item';
|
||||||
import { useTranslate } from '@/hooks/common-hooks';
|
import {
|
||||||
import { Form } from 'antd';
|
Form,
|
||||||
import { IOperatorForm } from '../../interface';
|
FormControl,
|
||||||
import DynamicInputVariable from '../components/dynamic-input-variable';
|
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 KeywordExtractForm = ({ form, node }: INextOperatorForm) => {
|
||||||
const { t } = useTranslate('flow');
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form {...form}>
|
||||||
name="basic"
|
<form
|
||||||
autoComplete="off"
|
className="space-y-6"
|
||||||
form={form}
|
onSubmit={(e) => {
|
||||||
onValuesChange={onValuesChange}
|
e.preventDefault();
|
||||||
layout={'vertical'}
|
}}
|
||||||
>
|
|
||||||
<DynamicInputVariable node={node}></DynamicInputVariable>
|
|
||||||
<Form.Item
|
|
||||||
name={'llm_id'}
|
|
||||||
label={t('model', { keyPrefix: 'chat' })}
|
|
||||||
tooltip={t('modelTip', { keyPrefix: 'chat' })}
|
|
||||||
>
|
>
|
||||||
<LLMSelect></LLMSelect>
|
<DynamicInputVariable node={node}></DynamicInputVariable>
|
||||||
</Form.Item>
|
<FormField
|
||||||
<TopNItem initialValue={3}></TopNItem>
|
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>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,34 +1,53 @@
|
|||||||
import TopNItem from '@/components/top-n-item';
|
import { TopNFormField } from '@/components/top-n-item';
|
||||||
import { useTranslate } from '@/hooks/common-hooks';
|
import {
|
||||||
import { Form, Select } from 'antd';
|
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 { INextOperatorForm } from '../../interface';
|
||||||
import DynamicInputVariable from '../components/dynamic-input-variable';
|
import { DynamicInputVariable } from '../components/next-dynamic-input-variable';
|
||||||
|
|
||||||
const WenCaiForm = ({ onValuesChange, form, node }: IOperatorForm) => {
|
const WenCaiForm = ({ form, node }: INextOperatorForm) => {
|
||||||
const { t } = useTranslate('flow');
|
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
|
<Form {...form}>
|
||||||
name="basic"
|
<form
|
||||||
autoComplete="off"
|
className="space-y-6"
|
||||||
form={form}
|
onSubmit={(e) => {
|
||||||
onValuesChange={onValuesChange}
|
e.preventDefault();
|
||||||
layout={'vertical'}
|
}}
|
||||||
>
|
>
|
||||||
<DynamicInputVariable node={node}></DynamicInputVariable>
|
<DynamicInputVariable node={node}></DynamicInputVariable>
|
||||||
<TopNItem initialValue={20} max={99}></TopNItem>
|
<TopNFormField max={99}></TopNFormField>
|
||||||
<Form.Item label={t('queryType')} name={'query_type'}>
|
<FormField
|
||||||
<Select options={wenCaiQueryTypeOptions}></Select>
|
control={form.control}
|
||||||
</Form.Item>
|
name="query_type"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>{t('flow.queryType')}</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<RAGFlowSelect {...field} options={wenCaiQueryTypeOptions} />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,26 +1,46 @@
|
|||||||
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 { INextOperatorForm } from '../../interface';
|
||||||
import DynamicInputVariable from '../components/dynamic-input-variable';
|
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
|
<Form {...form}>
|
||||||
name="basic"
|
<form
|
||||||
autoComplete="off"
|
className="space-y-6"
|
||||||
form={form}
|
onSubmit={(e) => {
|
||||||
onValuesChange={onValuesChange}
|
e.preventDefault();
|
||||||
layout={'vertical'}
|
}}
|
||||||
>
|
>
|
||||||
<DynamicInputVariable node={node}></DynamicInputVariable>
|
<DynamicInputVariable node={node}></DynamicInputVariable>
|
||||||
<TopNItem initialValue={10}></TopNItem>
|
<TopNFormField></TopNFormField>
|
||||||
<Form.Item label={t('language')} name={'language'}>
|
|
||||||
<Select options={LanguageOptions}></Select>
|
<FormField
|
||||||
</Form.Item>
|
control={form.control}
|
||||||
|
name="language"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>{t('language')}</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<RAGFlowSelect {...field} options={LanguageOptions} />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user