### What problem does this PR solve? fix: Fixed the issue that the related form value does not change after selecting the freedom field of the model #1804 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)tags/v0.9.0
| ); | ); | ||||
| return ( | return ( | ||||
| <Popover content={content} trigger="click" placement="left" arrow={false}> | |||||
| <Popover | |||||
| content={content} | |||||
| trigger="click" | |||||
| placement="left" | |||||
| arrow={false} | |||||
| destroyTooltipOnHide | |||||
| > | |||||
| <Select | <Select | ||||
| style={{ width: '100%' }} | style={{ width: '100%' }} | ||||
| dropdownStyle={{ display: 'none' }} | dropdownStyle={{ display: 'none' }} |
| const handleParametersChange = useCallback( | const handleParametersChange = useCallback( | ||||
| (value: ModelVariableType) => { | (value: ModelVariableType) => { | ||||
| const variable = settledModelVariableMap[value]; | const variable = settledModelVariableMap[value]; | ||||
| form?.setFieldsValue(variable); | |||||
| let nextVariable: Record<string, any> = variable; | |||||
| if (prefix) { | |||||
| nextVariable = { [prefix]: variable }; | |||||
| } | |||||
| form.setFieldsValue(nextVariable); | |||||
| }, | }, | ||||
| [form], | |||||
| [form, prefix], | |||||
| ); | ); | ||||
| const memorizedPrefix = useMemo(() => (prefix ? [prefix] : []), [prefix]); | const memorizedPrefix = useMemo(() => (prefix ? [prefix] : []), [prefix]); | ||||
| {...formItemLayout} | {...formItemLayout} | ||||
| rules={[{ required: true, message: t('modelMessage') }]} | rules={[{ required: true, message: t('modelMessage') }]} | ||||
| > | > | ||||
| <Select options={[...modelOptions[LlmModelType.Chat], ...modelOptions[LlmModelType.Image2text],]} showSearch/> | |||||
| <Select | |||||
| options={[ | |||||
| ...modelOptions[LlmModelType.Chat], | |||||
| ...modelOptions[LlmModelType.Image2text], | |||||
| ]} | |||||
| showSearch | |||||
| /> | |||||
| </Form.Item> | </Form.Item> | ||||
| <Divider></Divider> | <Divider></Divider> | ||||
| <Form.Item | <Form.Item |
| function* ({ payload }, { call, put }) { | function* ({ payload }, { call, put }) { | ||||
| yield put({ type: 'getKfList', payload: { kb_id: payload } }); | yield put({ type: 'getKfList', payload: { kb_id: payload } }); | ||||
| }, | }, | ||||
| { type: 'poll', delay: 5000 }, // TODO: Provide type support for this effect | |||||
| { type: 'poll', delay: 15000 }, // TODO: Provide type support for this effect | |||||
| ], | ], | ||||
| *updateDocumentStatus({ payload = {} }, { call, put }) { | *updateDocumentStatus({ payload = {} }, { call, put }) { | ||||
| const { data } = yield call( | const { data } = yield call( |
| const updateNodeForm = useGraphStore((state) => state.updateNodeForm); | const updateNodeForm = useGraphStore((state) => state.updateNodeForm); | ||||
| const handleValuesChange = useCallback( | const handleValuesChange = useCallback( | ||||
| (changedValues: any, values: any) => { | (changedValues: any, values: any) => { | ||||
| let nextValues: any = values; | |||||
| // Fixed the issue that the related form value does not change after selecting the freedom field of the model | |||||
| if ( | |||||
| Object.keys(changedValues).length === 1 && | |||||
| 'parameter' in changedValues && | |||||
| changedValues['parameter'] in settledModelVariableMap | |||||
| ) { | |||||
| nextValues = { | |||||
| ...values, | |||||
| ...settledModelVariableMap[ | |||||
| changedValues['parameter'] as keyof typeof settledModelVariableMap | |||||
| ], | |||||
| }; | |||||
| } | |||||
| if (id) { | if (id) { | ||||
| updateNodeForm(id, values); | |||||
| updateNodeForm(id, nextValues); | |||||
| } | } | ||||
| }, | }, | ||||
| [updateNodeForm, id], | [updateNodeForm, id], |