feat: Add DynamicInputVariable to RetrievalForm #1739 (#3112)

### What problem does this PR solve?

feat: Add DynamicInputVariable to RetrievalForm #1739
### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu 2024-11-01 13:31:48 +08:00 committed by GitHub
parent 33e5e5db5b
commit 3963aaa23e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
29 changed files with 271 additions and 68 deletions

View File

@ -30,6 +30,8 @@ export default {
warn: 'Warn', warn: 'Warn',
action: 'Action', action: 'Action',
s: 'S', s: 'S',
pleaseSelect: 'Please select',
pleaseInput: 'Please input',
}, },
login: { login: {
login: 'Sign in', login: 'Sign in',
@ -744,7 +746,7 @@ The above is the content you need to summarize.`,
googleDescription: googleDescription:
'This component is used to get search result fromhttps://www.google.com/ . Typically, it performs as a supplement to knowledgebases. Top N and SerpApi API key specifies the number of search results you need to adapt.', 'This component is used to get search result fromhttps://www.google.com/ . Typically, it performs as a supplement to knowledgebases. Top N and SerpApi API key specifies the number of search results you need to adapt.',
bing: 'Bing', bing: 'Bing',
bingTip: bingDescription:
'This component is used to get search result from https://www.bing.com/. Typically, it performs as a supplement to knowledgebases. Top N and Bing Subscription-Key specifies the number of search results you need to adapt.', 'This component is used to get search result from https://www.bing.com/. Typically, it performs as a supplement to knowledgebases. Top N and Bing Subscription-Key specifies the number of search results you need to adapt.',
apiKey: 'API KEY', apiKey: 'API KEY',
country: 'Country', country: 'Country',
@ -1024,6 +1026,8 @@ The above is the content you need to summarize.`,
timeout: 'Timeout', timeout: 'Timeout',
headers: 'Headers', headers: 'Headers',
cleanHtml: 'Clean html', cleanHtml: 'Clean html',
reference: 'Reference',
input: 'Input',
}, },
footer: { footer: {
profile: 'All rights reserved @ React', profile: 'All rights reserved @ React',

View File

@ -30,6 +30,8 @@ export default {
warn: '提醒', warn: '提醒',
action: '操作', action: '操作',
s: '秒', s: '秒',
pleaseSelect: '請選擇',
pleaseInput: '請輸入',
}, },
login: { login: {
login: '登入', login: '登入',
@ -697,7 +699,7 @@ export default {
googleDescription: googleDescription:
'此元件用於從https://www.google.com/取得搜尋結果。通常,它作為知識庫的補充。 Top N 和 SerpApi API 金鑰指定您需要調整的搜尋結果數量。', '此元件用於從https://www.google.com/取得搜尋結果。通常,它作為知識庫的補充。 Top N 和 SerpApi API 金鑰指定您需要調整的搜尋結果數量。',
bing: 'Bing', bing: 'Bing',
bingTip: bingDescription:
'此元件用於從 https://www.bing.com/ 取得搜尋結果。通常,它充當知識庫的補充。 Top N 和 Bing Subscription-Key 指定您需要適配的搜尋結果數量。', '此元件用於從 https://www.bing.com/ 取得搜尋結果。通常,它充當知識庫的補充。 Top N 和 Bing Subscription-Key 指定您需要適配的搜尋結果數量。',
apiKey: 'API KEY', apiKey: 'API KEY',
country: '國家', country: '國家',
@ -973,6 +975,8 @@ export default {
timeout: '超時', timeout: '超時',
headers: '請求頭', headers: '請求頭',
cleanHtml: '清除 html', cleanHtml: '清除 html',
reference: '引用',
input: '輸入',
}, },
footer: { footer: {
profile: '“保留所有權利 @ react”', profile: '“保留所有權利 @ react”',

View File

@ -30,6 +30,8 @@ export default {
warn: '提醒', warn: '提醒',
action: '操作', action: '操作',
s: '秒', s: '秒',
pleaseSelect: '请选择',
pleaseInput: '请输入',
}, },
login: { login: {
login: '登录', login: '登录',
@ -717,7 +719,7 @@ export default {
googleDescription: googleDescription:
'此组件用于从https://www.google.com/获取搜索结果。通常它作为知识库的补充。Top N 和 SerpApi API 密钥指定您需要调整的搜索结果数量。', '此组件用于从https://www.google.com/获取搜索结果。通常它作为知识库的补充。Top N 和 SerpApi API 密钥指定您需要调整的搜索结果数量。',
bing: 'Bing', bing: 'Bing',
bingTip: bingDescription:
'此组件用于从 https://www.bing.com/ 获取搜索结果。通常它作为知识库的补充。Top N 和 Bing Subscription-Key 指定您需要调整的搜索结果数量。', '此组件用于从 https://www.bing.com/ 获取搜索结果。通常它作为知识库的补充。Top N 和 Bing Subscription-Key 指定您需要调整的搜索结果数量。',
apiKey: 'API KEY', apiKey: 'API KEY',
country: '国家', country: '国家',
@ -993,6 +995,8 @@ export default {
timeout: '超时', timeout: '超时',
headers: '请求头', headers: '请求头',
cleanHtml: '清除 html', cleanHtml: '清除 html',
reference: '引用',
input: '输入',
}, },
footer: { footer: {
profile: 'All rights reserved @ React', profile: 'All rights reserved @ React',

View File

@ -343,10 +343,15 @@ export const componentMenuList = [
}, },
]; ];
const initialQueryBaseValues = {
query: [],
};
export const initialRetrievalValues = { export const initialRetrievalValues = {
similarity_threshold: 0.2, similarity_threshold: 0.2,
keywords_similarity_weight: 0.3, keywords_similarity_weight: 0.3,
top_n: 8, top_n: 8,
...initialQueryBaseValues,
}; };
export const initialBeginValues = { export const initialBeginValues = {
@ -390,6 +395,7 @@ export const initialCategorizeValues = {
...initialLlmBaseValues, ...initialLlmBaseValues,
message_history_window_size: 1, message_history_window_size: 1,
category_description: {}, category_description: {},
...initialQueryBaseValues,
}; };
export const initialMessageValues = { export const initialMessageValues = {
@ -399,29 +405,35 @@ export const initialMessageValues = {
export const initialKeywordExtractValues = { export const initialKeywordExtractValues = {
...initialLlmBaseValues, ...initialLlmBaseValues,
top_n: 1, top_n: 1,
...initialQueryBaseValues,
}; };
export const initialDuckValues = { export const initialDuckValues = {
top_n: 10, top_n: 10,
channel: Channel.Text, channel: Channel.Text,
...initialQueryBaseValues,
}; };
export const initialBaiduValues = { export const initialBaiduValues = {
top_n: 10, top_n: 10,
...initialQueryBaseValues,
}; };
export const initialWikipediaValues = { export const initialWikipediaValues = {
top_n: 10, top_n: 10,
language: 'en', language: 'en',
...initialQueryBaseValues,
}; };
export const initialPubMedValues = { export const initialPubMedValues = {
top_n: 10, top_n: 10,
email: '', email: '',
...initialQueryBaseValues,
}; };
export const initialArXivValues = { export const initialArXivValues = {
top_n: 10, top_n: 10,
sort_by: 'relevance', sort_by: 'relevance',
...initialQueryBaseValues,
}; };
export const initialGoogleValues = { export const initialGoogleValues = {
@ -429,6 +441,7 @@ export const initialGoogleValues = {
api_key: 'Xxx(get from https://serpapi.com/manage-api-key)', api_key: 'Xxx(get from https://serpapi.com/manage-api-key)',
country: 'cn', country: 'cn',
language: 'en', language: 'en',
...initialQueryBaseValues,
}; };
export const initialBingValues = { export const initialBingValues = {
@ -438,12 +451,14 @@ export const initialBingValues = {
'"YOUR_ACCESS_KEY"(get from https://www.microsoft.com/en-us/bing/apis/bing-web-search-api)', '"YOUR_ACCESS_KEY"(get from https://www.microsoft.com/en-us/bing/apis/bing-web-search-api)',
country: 'CH', country: 'CH',
language: 'en', language: 'en',
...initialQueryBaseValues,
}; };
export const initialGoogleScholarValues = { export const initialGoogleScholarValues = {
top_n: 5, top_n: 5,
sort_by: 'relevance', sort_by: 'relevance',
patents: true, patents: true,
...initialQueryBaseValues,
}; };
export const initialDeepLValues = { export const initialDeepLValues = {
@ -453,12 +468,14 @@ export const initialDeepLValues = {
export const initialGithubValues = { export const initialGithubValues = {
top_n: 5, top_n: 5,
...initialQueryBaseValues,
}; };
export const initialBaiduFanyiValues = { export const initialBaiduFanyiValues = {
appid: 'xxx', appid: 'xxx',
secret_key: 'xxx', secret_key: 'xxx',
trans_type: 'translate', trans_type: 'translate',
...initialQueryBaseValues,
}; };
export const initialQWeatherValues = { export const initialQWeatherValues = {
@ -466,6 +483,7 @@ export const initialQWeatherValues = {
type: 'weather', type: 'weather',
user_type: 'free', user_type: 'free',
time_period: 'now', time_period: 'now',
...initialQueryBaseValues,
}; };
export const initialExeSqlValues = { export const initialExeSqlValues = {
@ -477,13 +495,18 @@ export const initialExeSqlValues = {
password: '', password: '',
loop: 3, loop: 3,
top_n: 30, top_n: 30,
...initialQueryBaseValues,
}; };
export const initialSwitchValues = { conditions: [] }; export const initialSwitchValues = { conditions: [] };
export const initialWenCaiValues = { top_n: 20, query_type: 'stock' }; export const initialWenCaiValues = {
top_n: 20,
query_type: 'stock',
...initialQueryBaseValues,
};
export const initialAkShareValues = { top_n: 10 }; export const initialAkShareValues = { top_n: 10, ...initialQueryBaseValues };
export const initialYahooFinanceValues = { export const initialYahooFinanceValues = {
info: true, info: true,
@ -492,6 +515,7 @@ export const initialYahooFinanceValues = {
balance_sheet: false, balance_sheet: false,
cash_flow_statement: false, cash_flow_statement: false,
news: true, news: true,
...initialQueryBaseValues,
}; };
export const initialJin10Values = { export const initialJin10Values = {
@ -500,6 +524,7 @@ export const initialJin10Values = {
flash_type: '1', flash_type: '1',
contain: '', contain: '',
filter: '', filter: '',
...initialQueryBaseValues,
}; };
export const initialConcentratorValues = {}; export const initialConcentratorValues = {};
@ -508,6 +533,7 @@ export const initialTuShareValues = {
token: 'xxx', token: 'xxx',
src: 'eastmoney', src: 'eastmoney',
start_date: '2024-01-01 09:00:00', start_date: '2024-01-01 09:00:00',
...initialQueryBaseValues,
}; };
export const initialNoteValues = { export const initialNoteValues = {
@ -516,6 +542,7 @@ export const initialNoteValues = {
export const initialCrawlerValues = { export const initialCrawlerValues = {
extract_type: 'markdown', extract_type: 'markdown',
...initialQueryBaseValues,
}; };
export const initialInvokeValues = { export const initialInvokeValues = {

View File

@ -1,17 +1,18 @@
import TopNItem from '@/components/top-n-item'; import TopNItem from '@/components/top-n-item';
import { Form } from 'antd'; import { Form } from 'antd';
import { IOperatorForm } from '../../interface'; import { IOperatorForm } from '../../interface';
import DynamicInputVariable from '../components/dynamic-input-variable';
const AkShareForm = ({ onValuesChange, form }: IOperatorForm) => { const AkShareForm = ({ onValuesChange, form, node }: IOperatorForm) => {
return ( return (
<Form <Form
name="basic" name="basic"
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
autoComplete="off" autoComplete="off"
form={form} form={form}
onValuesChange={onValuesChange} onValuesChange={onValuesChange}
layout={'vertical'}
> >
<DynamicInputVariable nodeId={node?.id}></DynamicInputVariable>
<TopNItem initialValue={10} max={99}></TopNItem> <TopNItem initialValue={10} max={99}></TopNItem>
</Form> </Form>
); );

View File

@ -3,8 +3,9 @@ import { useTranslate } from '@/hooks/common-hooks';
import { Form, Select } from 'antd'; import { Form, Select } from 'antd';
import { useMemo } from 'react'; import { useMemo } from 'react';
import { IOperatorForm } from '../../interface'; import { IOperatorForm } from '../../interface';
import DynamicInputVariable from '../components/dynamic-input-variable';
const ArXivForm = ({ onValuesChange, form }: IOperatorForm) => { const ArXivForm = ({ onValuesChange, form, node }: IOperatorForm) => {
const { t } = useTranslate('flow'); const { t } = useTranslate('flow');
const options = useMemo(() => { const options = useMemo(() => {
@ -17,12 +18,13 @@ const ArXivForm = ({ onValuesChange, form }: IOperatorForm) => {
return ( return (
<Form <Form
name="basic" name="basic"
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
autoComplete="off" autoComplete="off"
form={form} form={form}
onValuesChange={onValuesChange} onValuesChange={onValuesChange}
layout={'vertical'}
> >
<DynamicInputVariable nodeId={node?.id}></DynamicInputVariable>
<TopNItem initialValue={10}></TopNItem> <TopNItem initialValue={10}></TopNItem>
<Form.Item label={t('sortBy')} name={'sort_by'}> <Form.Item label={t('sortBy')} name={'sort_by'}>
<Select options={options}></Select> <Select options={options}></Select>

View File

@ -6,8 +6,9 @@ import {
BaiduFanyiSourceLangOptions, BaiduFanyiSourceLangOptions,
} from '../../constant'; } from '../../constant';
import { IOperatorForm } from '../../interface'; import { IOperatorForm } from '../../interface';
import DynamicInputVariable from '../components/dynamic-input-variable';
const BaiduFanyiForm = ({ onValuesChange, form }: IOperatorForm) => { const BaiduFanyiForm = ({ onValuesChange, form, node }: IOperatorForm) => {
const { t } = useTranslate('flow'); const { t } = useTranslate('flow');
const options = useMemo(() => { const options = useMemo(() => {
return ['translate', 'fieldtranslate'].map((x) => ({ return ['translate', 'fieldtranslate'].map((x) => ({
@ -33,12 +34,12 @@ const BaiduFanyiForm = ({ onValuesChange, form }: IOperatorForm) => {
return ( return (
<Form <Form
name="basic" name="basic"
labelCol={{ span: 8 }}
wrapperCol={{ span: 16 }}
autoComplete="off" autoComplete="off"
form={form} form={form}
onValuesChange={onValuesChange} onValuesChange={onValuesChange}
layout={'vertical'}
> >
<DynamicInputVariable nodeId={node?.id}></DynamicInputVariable>
<Form.Item label={t('appid')} name={'appid'}> <Form.Item label={t('appid')} name={'appid'}>
<Input></Input> <Input></Input>
</Form.Item> </Form.Item>

View File

@ -1,17 +1,18 @@
import TopNItem from '@/components/top-n-item'; import TopNItem from '@/components/top-n-item';
import { Form } from 'antd'; import { Form } from 'antd';
import { IOperatorForm } from '../../interface'; import { IOperatorForm } from '../../interface';
import DynamicInputVariable from '../components/dynamic-input-variable';
const BaiduForm = ({ onValuesChange, form }: IOperatorForm) => { const BaiduForm = ({ onValuesChange, form, node }: IOperatorForm) => {
return ( return (
<Form <Form
name="basic" name="basic"
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
autoComplete="off" autoComplete="off"
form={form} form={form}
onValuesChange={onValuesChange} onValuesChange={onValuesChange}
layout={'vertical'}
> >
<DynamicInputVariable nodeId={node?.id}></DynamicInputVariable>
<TopNItem initialValue={10}></TopNItem> <TopNItem initialValue={10}></TopNItem>
</Form> </Form>
); );

View File

@ -4,8 +4,9 @@ import { Form, Input, Select } from 'antd';
import { useMemo } from 'react'; import { useMemo } from 'react';
import { BingCountryOptions, BingLanguageOptions } from '../../constant'; import { BingCountryOptions, BingLanguageOptions } from '../../constant';
import { IOperatorForm } from '../../interface'; import { IOperatorForm } from '../../interface';
import DynamicInputVariable from '../components/dynamic-input-variable';
const BingForm = ({ onValuesChange, form }: IOperatorForm) => { const BingForm = ({ onValuesChange, form, node }: IOperatorForm) => {
const { t } = useTranslate('flow'); const { t } = useTranslate('flow');
const options = useMemo(() => { const options = useMemo(() => {
@ -15,12 +16,12 @@ const BingForm = ({ onValuesChange, form }: IOperatorForm) => {
return ( return (
<Form <Form
name="basic" name="basic"
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
autoComplete="off" autoComplete="off"
form={form} form={form}
onValuesChange={onValuesChange} onValuesChange={onValuesChange}
layout={'vertical'}
> >
<DynamicInputVariable nodeId={node?.id}></DynamicInputVariable>
<TopNItem initialValue={10}></TopNItem> <TopNItem initialValue={10}></TopNItem>
<Form.Item label={t('channel')} name={'channel'}> <Form.Item label={t('channel')} name={'channel'}>
<Select options={options}></Select> <Select options={options}></Select>

View File

@ -1,5 +1,5 @@
import { useTranslate } from '@/hooks/common-hooks'; import { useTranslate } from '@/hooks/common-hooks';
import { CloseOutlined } from '@ant-design/icons'; import { CloseOutlined, PlusOutlined } from '@ant-design/icons';
import { import {
Button, Button,
Card, Card,
@ -197,8 +197,9 @@ const DynamicCategorize = ({ nodeId }: IProps) => {
onClick={handleAdd} onClick={handleAdd}
block block
className={styles.addButton} className={styles.addButton}
icon={<PlusOutlined />}
> >
+ {t('addItem')} {t('addItem')}
</Button> </Button>
</Flex> </Flex>
); );

View File

@ -4,6 +4,7 @@ import { useTranslate } from '@/hooks/common-hooks';
import { Form } from 'antd'; import { Form } from 'antd';
import { useSetLlmSetting } from '../../hooks'; import { useSetLlmSetting } from '../../hooks';
import { IOperatorForm } from '../../interface'; import { IOperatorForm } from '../../interface';
import DynamicInputVariable from '../components/dynamic-input-variable';
import DynamicCategorize from './dynamic-categorize'; import DynamicCategorize from './dynamic-categorize';
import { useHandleFormValuesChange } from './hooks'; import { useHandleFormValuesChange } from './hooks';
@ -25,6 +26,7 @@ const CategorizeForm = ({ form, onValuesChange, node }: IOperatorForm) => {
initialValues={{ items: [{}] }} initialValues={{ items: [{}] }}
layout={'vertical'} layout={'vertical'}
> >
<DynamicInputVariable nodeId={node?.id}></DynamicInputVariable>
<Form.Item <Form.Item
name={'llm_id'} name={'llm_id'}
label={t('model', { keyPrefix: 'chat' })} label={t('model', { keyPrefix: 'chat' })}

View File

@ -0,0 +1,116 @@
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
import { Button, Collapse, Flex, Form, Input, Select } from 'antd';
import { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { useBuildComponentIdSelectOptions } from '../../hooks';
import styles from './index.less';
interface IProps {
nodeId?: string;
}
enum VariableType {
Reference = 'reference',
Input = 'input',
}
const getVariableName = (type: string) =>
type === VariableType.Reference ? 'component_id' : 'value';
const DynamicVariableForm = ({ nodeId }: IProps) => {
const { t } = useTranslation();
const valueOptions = useBuildComponentIdSelectOptions(nodeId);
const form = Form.useFormInstance();
const options = [
{ value: VariableType.Reference, label: t('flow.reference') },
{ value: VariableType.Input, label: t('flow.input') },
];
const handleTypeChange = useCallback(
(name: number) => () => {
setTimeout(() => {
form.setFieldValue(['query', name, 'component_id'], undefined);
form.setFieldValue(['query', name, 'value'], undefined);
}, 0);
},
[form],
);
return (
<Form.List name="query">
{(fields, { add, remove }) => (
<>
{fields.map(({ key, name, ...restField }) => (
<Flex key={key} gap={10} align={'baseline'}>
<Form.Item
{...restField}
name={[name, 'type']}
className={styles.variableType}
>
<Select
options={options}
onChange={handleTypeChange(name)}
></Select>
</Form.Item>
<Form.Item noStyle dependencies={[name, 'type']}>
{({ getFieldValue }) => {
const type = getFieldValue(['query', name, 'type']);
return (
<Form.Item
{...restField}
name={[name, getVariableName(type)]}
className={styles.variableValue}
>
{type === VariableType.Reference ? (
<Select
placeholder={t('common.pleaseSelect')}
options={valueOptions}
></Select>
) : (
<Input placeholder={t('common.pleaseInput')} />
)}
</Form.Item>
);
}}
</Form.Item>
<MinusCircleOutlined onClick={() => remove(name)} />
</Flex>
))}
<Form.Item>
<Button
type="dashed"
onClick={() => add({ type: VariableType.Reference })}
block
icon={<PlusOutlined />}
className={styles.addButton}
>
{t('flow.addItem')}
</Button>
</Form.Item>
</>
)}
</Form.List>
);
};
const DynamicInputVariable = ({ nodeId }: IProps) => {
const { t } = useTranslation();
return (
<Collapse
className={styles.dynamicInputVariable}
defaultActiveKey={['1']}
items={[
{
key: '1',
label: <span className={styles.title}>{t('flow.input')}</span>,
children: <DynamicVariableForm nodeId={nodeId}></DynamicVariableForm>,
},
]}
/>
);
};
export default DynamicInputVariable;

View File

@ -0,0 +1,22 @@
.dynamicInputVariable {
background-color: #ebe9e9;
:global(.ant-collapse-content) {
background-color: #f6f6f6;
}
margin-bottom: 20px;
.title {
font-weight: 600;
font-size: 16px;
}
.variableType {
width: 30%;
}
.variableValue {
flex: 1;
}
.addButton {
color: rgb(22, 119, 255);
font-weight: 600;
}
}

View File

@ -3,7 +3,8 @@ import { Form, Input, Select } from 'antd';
import { useMemo } from 'react'; import { useMemo } from 'react';
import { CrawlerResultOptions } from '../../constant'; import { CrawlerResultOptions } from '../../constant';
import { IOperatorForm } from '../../interface'; import { IOperatorForm } from '../../interface';
const CrawlerForm = ({ onValuesChange, form }: IOperatorForm) => { import DynamicInputVariable from '../components/dynamic-input-variable';
const CrawlerForm = ({ onValuesChange, form, node }: IOperatorForm) => {
const { t } = useTranslate('flow'); const { t } = useTranslate('flow');
const crawlerResultOptions = useMemo(() => { const crawlerResultOptions = useMemo(() => {
return CrawlerResultOptions.map((x) => ({ return CrawlerResultOptions.map((x) => ({
@ -14,12 +15,12 @@ const CrawlerForm = ({ onValuesChange, form }: IOperatorForm) => {
return ( return (
<Form <Form
name="basic" name="basic"
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
autoComplete="off" autoComplete="off"
form={form} form={form}
onValuesChange={onValuesChange} onValuesChange={onValuesChange}
layout={'vertical'}
> >
<DynamicInputVariable nodeId={node?.id}></DynamicInputVariable>
<Form.Item label={t('proxy')} name={'proxy'}> <Form.Item label={t('proxy')} name={'proxy'}>
<Input placeholder="like: http://127.0.0.1:8888"></Input> <Input placeholder="like: http://127.0.0.1:8888"></Input>
</Form.Item> </Form.Item>

View File

@ -4,20 +4,21 @@ import { Form, Select } from 'antd';
import { DeepLSourceLangOptions, DeepLTargetLangOptions } from '../../constant'; import { DeepLSourceLangOptions, DeepLTargetLangOptions } from '../../constant';
import { useBuildSortOptions } from '../../form-hooks'; import { useBuildSortOptions } from '../../form-hooks';
import { IOperatorForm } from '../../interface'; import { IOperatorForm } from '../../interface';
import DynamicInputVariable from '../components/dynamic-input-variable';
const DeepLForm = ({ onValuesChange, form }: IOperatorForm) => { const DeepLForm = ({ onValuesChange, form, node }: IOperatorForm) => {
const { t } = useTranslate('flow'); const { t } = useTranslate('flow');
const options = useBuildSortOptions(); const options = useBuildSortOptions();
return ( return (
<Form <Form
name="basic" name="basic"
labelCol={{ span: 8 }}
wrapperCol={{ span: 16 }}
autoComplete="off" autoComplete="off"
form={form} form={form}
onValuesChange={onValuesChange} onValuesChange={onValuesChange}
layout={'vertical'}
> >
<DynamicInputVariable nodeId={node?.id}></DynamicInputVariable>
<TopNItem initialValue={5}></TopNItem> <TopNItem initialValue={5}></TopNItem>
<Form.Item label={t('authKey')} name={'auth_key'}> <Form.Item label={t('authKey')} name={'auth_key'}>
<Select options={options}></Select> <Select options={options}></Select>

View File

@ -4,8 +4,9 @@ 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 { IOperatorForm } from '../../interface';
import DynamicInputVariable from '../components/dynamic-input-variable';
const DuckDuckGoForm = ({ onValuesChange, form }: IOperatorForm) => { const DuckDuckGoForm = ({ onValuesChange, form, node }: IOperatorForm) => {
const { t } = useTranslate('flow'); const { t } = useTranslate('flow');
const options = useMemo(() => { const options = useMemo(() => {
@ -15,12 +16,12 @@ const DuckDuckGoForm = ({ onValuesChange, form }: IOperatorForm) => {
return ( return (
<Form <Form
name="basic" name="basic"
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
autoComplete="off" autoComplete="off"
form={form} form={form}
onValuesChange={onValuesChange} onValuesChange={onValuesChange}
layout={'vertical'}
> >
<DynamicInputVariable nodeId={node?.id}></DynamicInputVariable>
<TopNItem initialValue={10}></TopNItem> <TopNItem initialValue={10}></TopNItem>
<Form.Item <Form.Item
label={t('channel')} label={t('channel')}

View File

@ -5,8 +5,9 @@ import { Button, Flex, Form, Input, InputNumber, Select } from 'antd';
import { useCallback } from 'react'; import { useCallback } from 'react';
import { ExeSQLOptions } from '../../constant'; import { ExeSQLOptions } from '../../constant';
import { IOperatorForm } from '../../interface'; import { IOperatorForm } from '../../interface';
import DynamicInputVariable from '../components/dynamic-input-variable';
const ExeSQLForm = ({ onValuesChange, form }: IOperatorForm) => { const ExeSQLForm = ({ onValuesChange, form, node }: IOperatorForm) => {
const { t } = useTranslate('flow'); const { t } = useTranslate('flow');
const { testDbConnect, loading } = useTestDbConnect(); const { testDbConnect, loading } = useTestDbConnect();
@ -18,12 +19,12 @@ const ExeSQLForm = ({ onValuesChange, form }: IOperatorForm) => {
return ( return (
<Form <Form
name="basic" name="basic"
labelCol={{ span: 7 }}
wrapperCol={{ span: 17 }}
autoComplete="off" autoComplete="off"
form={form} form={form}
onValuesChange={onValuesChange} onValuesChange={onValuesChange}
layout={'vertical'}
> >
<DynamicInputVariable nodeId={node?.id}></DynamicInputVariable>
<Form.Item <Form.Item
label={t('dbType')} label={t('dbType')}
name={'db_type'} name={'db_type'}

View File

@ -1,17 +1,18 @@
import TopNItem from '@/components/top-n-item'; import TopNItem from '@/components/top-n-item';
import { Form } from 'antd'; import { Form } from 'antd';
import { IOperatorForm } from '../../interface'; import { IOperatorForm } from '../../interface';
import DynamicInputVariable from '../components/dynamic-input-variable';
const GithubForm = ({ onValuesChange, form }: IOperatorForm) => { const GithubForm = ({ onValuesChange, form, node }: IOperatorForm) => {
return ( return (
<Form <Form
name="basic" name="basic"
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
autoComplete="off" autoComplete="off"
form={form} form={form}
onValuesChange={onValuesChange} onValuesChange={onValuesChange}
layout={'vertical'}
> >
<DynamicInputVariable nodeId={node?.id}></DynamicInputVariable>
<TopNItem initialValue={5}></TopNItem> <TopNItem initialValue={5}></TopNItem>
</Form> </Form>
); );

View File

@ -3,19 +3,20 @@ import { useTranslate } from '@/hooks/common-hooks';
import { Form, Input, Select } from 'antd'; import { Form, Input, Select } from 'antd';
import { GoogleCountryOptions, GoogleLanguageOptions } from '../../constant'; import { GoogleCountryOptions, GoogleLanguageOptions } from '../../constant';
import { IOperatorForm } from '../../interface'; import { IOperatorForm } from '../../interface';
import DynamicInputVariable from '../components/dynamic-input-variable';
const GoogleForm = ({ onValuesChange, form }: IOperatorForm) => { const GoogleForm = ({ onValuesChange, form, node }: IOperatorForm) => {
const { t } = useTranslate('flow'); const { t } = useTranslate('flow');
return ( return (
<Form <Form
name="basic" name="basic"
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
autoComplete="off" autoComplete="off"
form={form} form={form}
onValuesChange={onValuesChange} onValuesChange={onValuesChange}
layout={'vertical'}
> >
<DynamicInputVariable nodeId={node?.id}></DynamicInputVariable>
<TopNItem initialValue={10}></TopNItem> <TopNItem initialValue={10}></TopNItem>
<Form.Item label={t('apiKey')} name={'api_key'}> <Form.Item label={t('apiKey')} name={'api_key'}>
<Input></Input> <Input></Input>

View File

@ -5,6 +5,7 @@ import dayjs from 'dayjs';
import { useCallback, useMemo } from 'react'; import { useCallback, useMemo } from 'react';
import { useBuildSortOptions } from '../../form-hooks'; import { useBuildSortOptions } from '../../form-hooks';
import { IOperatorForm } from '../../interface'; import { IOperatorForm } from '../../interface';
import DynamicInputVariable from '../components/dynamic-input-variable';
const YearPicker = ({ const YearPicker = ({
onChange, onChange,
@ -31,7 +32,7 @@ const YearPicker = ({
return <DatePicker picker="year" onChange={handleChange} value={nextValue} />; return <DatePicker picker="year" onChange={handleChange} value={nextValue} />;
}; };
const GoogleScholarForm = ({ onValuesChange, form }: IOperatorForm) => { const GoogleScholarForm = ({ onValuesChange, form, node }: IOperatorForm) => {
const { t } = useTranslate('flow'); const { t } = useTranslate('flow');
const options = useBuildSortOptions(); const options = useBuildSortOptions();
@ -39,12 +40,12 @@ const GoogleScholarForm = ({ onValuesChange, form }: IOperatorForm) => {
return ( return (
<Form <Form
name="basic" name="basic"
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
autoComplete="off" autoComplete="off"
form={form} form={form}
onValuesChange={onValuesChange} onValuesChange={onValuesChange}
layout={'vertical'}
> >
<DynamicInputVariable nodeId={node?.id}></DynamicInputVariable>
<TopNItem initialValue={5}></TopNItem> <TopNItem initialValue={5}></TopNItem>
<Form.Item <Form.Item
label={t('sortBy')} label={t('sortBy')}

View File

@ -10,8 +10,9 @@ import {
Jin10TypeOptions, Jin10TypeOptions,
} from '../../constant'; } from '../../constant';
import { IOperatorForm } from '../../interface'; import { IOperatorForm } from '../../interface';
import DynamicInputVariable from '../components/dynamic-input-variable';
const Jin10Form = ({ onValuesChange, form }: IOperatorForm) => { const Jin10Form = ({ onValuesChange, form, node }: IOperatorForm) => {
const { t } = useTranslate('flow'); const { t } = useTranslate('flow');
const jin10TypeOptions = useMemo(() => { const jin10TypeOptions = useMemo(() => {
@ -59,12 +60,12 @@ const Jin10Form = ({ onValuesChange, form }: IOperatorForm) => {
return ( return (
<Form <Form
name="basic" name="basic"
labelCol={{ span: 9 }}
wrapperCol={{ span: 15 }}
autoComplete="off" autoComplete="off"
form={form} form={form}
onValuesChange={onValuesChange} onValuesChange={onValuesChange}
layout={'vertical'}
> >
<DynamicInputVariable nodeId={node?.id}></DynamicInputVariable>
<Form.Item label={t('type')} name={'type'} initialValue={'flash'}> <Form.Item label={t('type')} name={'type'} initialValue={'flash'}>
<Select options={jin10TypeOptions}></Select> <Select options={jin10TypeOptions}></Select>
</Form.Item> </Form.Item>

View File

@ -4,8 +4,9 @@ import { useTranslate } from '@/hooks/common-hooks';
import { Form } from 'antd'; import { Form } from 'antd';
import { useSetLlmSetting } from '../../hooks'; import { useSetLlmSetting } from '../../hooks';
import { IOperatorForm } from '../../interface'; import { IOperatorForm } from '../../interface';
import DynamicInputVariable from '../components/dynamic-input-variable';
const KeywordExtractForm = ({ onValuesChange, form }: IOperatorForm) => { const KeywordExtractForm = ({ onValuesChange, form, node }: IOperatorForm) => {
const { t } = useTranslate('flow'); const { t } = useTranslate('flow');
useSetLlmSetting(form); useSetLlmSetting(form);
@ -13,12 +14,12 @@ const KeywordExtractForm = ({ onValuesChange, form }: IOperatorForm) => {
return ( return (
<Form <Form
name="basic" name="basic"
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
autoComplete="off" autoComplete="off"
form={form} form={form}
onValuesChange={onValuesChange} onValuesChange={onValuesChange}
layout={'vertical'}
> >
<DynamicInputVariable nodeId={node?.id}></DynamicInputVariable>
<Form.Item <Form.Item
name={'llm_id'} name={'llm_id'}
label={t('model', { keyPrefix: 'chat' })} label={t('model', { keyPrefix: 'chat' })}

View File

@ -2,19 +2,20 @@ import TopNItem from '@/components/top-n-item';
import { useTranslate } from '@/hooks/common-hooks'; import { useTranslate } from '@/hooks/common-hooks';
import { Form, Input } from 'antd'; import { Form, Input } from 'antd';
import { IOperatorForm } from '../../interface'; import { IOperatorForm } from '../../interface';
import DynamicInputVariable from '../components/dynamic-input-variable';
const PubMedForm = ({ onValuesChange, form }: IOperatorForm) => { const PubMedForm = ({ onValuesChange, form, node }: IOperatorForm) => {
const { t } = useTranslate('flow'); const { t } = useTranslate('flow');
return ( return (
<Form <Form
name="basic" name="basic"
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
autoComplete="off" autoComplete="off"
form={form} form={form}
onValuesChange={onValuesChange} onValuesChange={onValuesChange}
layout={'vertical'}
> >
<DynamicInputVariable nodeId={node?.id}></DynamicInputVariable>
<TopNItem initialValue={10}></TopNItem> <TopNItem initialValue={10}></TopNItem>
<Form.Item <Form.Item
label={t('email')} label={t('email')}

View File

@ -8,8 +8,9 @@ import {
QWeatherUserTypeOptions, QWeatherUserTypeOptions,
} from '../../constant'; } from '../../constant';
import { IOperatorForm } from '../../interface'; import { IOperatorForm } from '../../interface';
import DynamicInputVariable from '../components/dynamic-input-variable';
const QWeatherForm = ({ onValuesChange, form }: IOperatorForm) => { const QWeatherForm = ({ onValuesChange, form, node }: IOperatorForm) => {
const { t } = useTranslate('flow'); const { t } = useTranslate('flow');
const qWeatherLangOptions = useMemo(() => { const qWeatherLangOptions = useMemo(() => {
return QWeatherLangOptions.map((x) => ({ return QWeatherLangOptions.map((x) => ({
@ -49,12 +50,12 @@ const QWeatherForm = ({ onValuesChange, form }: IOperatorForm) => {
return ( return (
<Form <Form
name="basic" name="basic"
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
autoComplete="off" autoComplete="off"
form={form} form={form}
onValuesChange={onValuesChange} onValuesChange={onValuesChange}
layout={'vertical'}
> >
<DynamicInputVariable nodeId={node?.id}></DynamicInputVariable>
<Form.Item label={t('webApiKey')} name={'web_apikey'}> <Form.Item label={t('webApiKey')} name={'web_apikey'}>
<Input></Input> <Input></Input>
</Form.Item> </Form.Item>

View File

@ -6,6 +6,7 @@ import { useTranslate } from '@/hooks/common-hooks';
import type { FormProps } from 'antd'; import type { FormProps } from 'antd';
import { Form, Input } from 'antd'; import { Form, Input } from 'antd';
import { IOperatorForm } from '../../interface'; import { IOperatorForm } from '../../interface';
import DynamicInputVariable from '../components/dynamic-input-variable';
type FieldType = { type FieldType = {
top_n?: number; top_n?: number;
@ -19,7 +20,7 @@ const onFinishFailed: FormProps<FieldType>['onFinishFailed'] = (errorInfo) => {
console.log('Failed:', errorInfo); console.log('Failed:', errorInfo);
}; };
const RetrievalForm = ({ onValuesChange, form }: IOperatorForm) => { const RetrievalForm = ({ onValuesChange, form, node }: IOperatorForm) => {
const { t } = useTranslate('flow'); const { t } = useTranslate('flow');
return ( return (
<Form <Form
@ -31,6 +32,7 @@ const RetrievalForm = ({ onValuesChange, form }: IOperatorForm) => {
form={form} form={form}
layout={'vertical'} layout={'vertical'}
> >
<DynamicInputVariable nodeId={node?.id}></DynamicInputVariable>
<SimilaritySlider <SimilaritySlider
isTooltipShown isTooltipShown
vectorSimilarityWeightName="keywords_similarity_weight" vectorSimilarityWeightName="keywords_similarity_weight"

View File

@ -4,6 +4,7 @@ import dayjs from 'dayjs';
import { useCallback, useMemo } from 'react'; import { useCallback, useMemo } from 'react';
import { TuShareSrcOptions } from '../../constant'; import { TuShareSrcOptions } from '../../constant';
import { IOperatorForm } from '../../interface'; import { IOperatorForm } from '../../interface';
import DynamicInputVariable from '../components/dynamic-input-variable';
const DateTimePicker = ({ const DateTimePicker = ({
onChange, onChange,
@ -37,7 +38,7 @@ const DateTimePicker = ({
); );
}; };
const TuShareForm = ({ onValuesChange, form }: IOperatorForm) => { const TuShareForm = ({ onValuesChange, form, node }: IOperatorForm) => {
const { t } = useTranslate('flow'); const { t } = useTranslate('flow');
const tuShareSrcOptions = useMemo(() => { const tuShareSrcOptions = useMemo(() => {
@ -50,12 +51,12 @@ const TuShareForm = ({ onValuesChange, form }: IOperatorForm) => {
return ( return (
<Form <Form
name="basic" name="basic"
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
autoComplete="off" autoComplete="off"
form={form} form={form}
onValuesChange={onValuesChange} onValuesChange={onValuesChange}
layout={'vertical'}
> >
<DynamicInputVariable nodeId={node?.id}></DynamicInputVariable>
<Form.Item <Form.Item
label={t('token')} label={t('token')}
name={'token'} name={'token'}

View File

@ -4,8 +4,9 @@ import { Form, Select } from 'antd';
import { useMemo } from 'react'; import { useMemo } from 'react';
import { WenCaiQueryTypeOptions } from '../../constant'; import { WenCaiQueryTypeOptions } from '../../constant';
import { IOperatorForm } from '../../interface'; import { IOperatorForm } from '../../interface';
import DynamicInputVariable from '../components/dynamic-input-variable';
const WenCaiForm = ({ onValuesChange, form }: IOperatorForm) => { const WenCaiForm = ({ onValuesChange, form, node }: IOperatorForm) => {
const { t } = useTranslate('flow'); const { t } = useTranslate('flow');
const wenCaiQueryTypeOptions = useMemo(() => { const wenCaiQueryTypeOptions = useMemo(() => {
@ -18,12 +19,12 @@ const WenCaiForm = ({ onValuesChange, form }: IOperatorForm) => {
return ( return (
<Form <Form
name="basic" name="basic"
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
autoComplete="off" autoComplete="off"
form={form} form={form}
onValuesChange={onValuesChange} onValuesChange={onValuesChange}
layout={'vertical'}
> >
<DynamicInputVariable nodeId={node?.id}></DynamicInputVariable>
<TopNItem initialValue={20} max={99}></TopNItem> <TopNItem initialValue={20} max={99}></TopNItem>
<Form.Item label={t('queryType')} name={'query_type'}> <Form.Item label={t('queryType')} name={'query_type'}>
<Select options={wenCaiQueryTypeOptions}></Select> <Select options={wenCaiQueryTypeOptions}></Select>

View File

@ -3,19 +3,20 @@ import { useTranslate } from '@/hooks/common-hooks';
import { Form, Select } from 'antd'; import { Form, Select } from 'antd';
import { LanguageOptions } from '../../constant'; import { LanguageOptions } from '../../constant';
import { IOperatorForm } from '../../interface'; import { IOperatorForm } from '../../interface';
import DynamicInputVariable from '../components/dynamic-input-variable';
const WikipediaForm = ({ onValuesChange, form }: IOperatorForm) => { const WikipediaForm = ({ onValuesChange, form, node }: IOperatorForm) => {
const { t } = useTranslate('common'); const { t } = useTranslate('common');
return ( return (
<Form <Form
name="basic" name="basic"
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
autoComplete="off" autoComplete="off"
form={form} form={form}
onValuesChange={onValuesChange} onValuesChange={onValuesChange}
layout={'vertical'}
> >
<DynamicInputVariable nodeId={node?.id}></DynamicInputVariable>
<TopNItem initialValue={10}></TopNItem> <TopNItem initialValue={10}></TopNItem>
<Form.Item label={t('language')} name={'language'}> <Form.Item label={t('language')} name={'language'}>
<Select options={LanguageOptions}></Select> <Select options={LanguageOptions}></Select>

View File

@ -1,19 +1,20 @@
import { useTranslate } from '@/hooks/common-hooks'; import { useTranslate } from '@/hooks/common-hooks';
import { Form, Switch } from 'antd'; import { Form, Switch } from 'antd';
import { IOperatorForm } from '../../interface'; import { IOperatorForm } from '../../interface';
import DynamicInputVariable from '../components/dynamic-input-variable';
const YahooFinanceForm = ({ onValuesChange, form }: IOperatorForm) => { const YahooFinanceForm = ({ onValuesChange, form, node }: IOperatorForm) => {
const { t } = useTranslate('flow'); const { t } = useTranslate('flow');
return ( return (
<Form <Form
name="basic" name="basic"
labelCol={{ span: 10 }}
wrapperCol={{ span: 14 }}
autoComplete="off" autoComplete="off"
form={form} form={form}
onValuesChange={onValuesChange} onValuesChange={onValuesChange}
layout={'vertical'}
> >
<DynamicInputVariable nodeId={node?.id}></DynamicInputVariable>
<Form.Item label={t('info')} name={'info'}> <Form.Item label={t('info')} name={'info'}>
<Switch></Switch> <Switch></Switch>
</Form.Item> </Form.Item>