mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-06-26 22:19:57 +00:00
Feat: Fixed the issue where the parameters could not be set after switching the large model parameter template. #8282 (#8283)
### What problem does this PR solve? Feat: Fixed the issue where the parameters could not be set after switching the large model parameter template. #8282 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
parent
601e024d77
commit
36ee1d271d
@ -6,9 +6,9 @@ import {
|
||||
import { Flex, Form, InputNumber, Select, Slider, Switch, Tooltip } from 'antd';
|
||||
import camelCase from 'lodash/camelCase';
|
||||
|
||||
import { ChatVariableEnabledField } from '@/constants/chat';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { useComposeLlmOptionsByModelTypes } from '@/hooks/llm-hooks';
|
||||
import { setChatVariableEnabledFieldValuePage } from '@/utils/chat';
|
||||
import { QuestionCircleOutlined } from '@ant-design/icons';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import styles from './index.less';
|
||||
@ -35,12 +35,7 @@ const LlmSettingItems = ({ prefix, formItemLayout = {}, onChange }: IProps) => {
|
||||
if (prefix) {
|
||||
nextVariable = { [prefix]: variable };
|
||||
}
|
||||
const variableCheckBoxFieldMap = Object.values(
|
||||
ChatVariableEnabledField,
|
||||
).reduce<Record<string, boolean>>((pre, cur) => {
|
||||
pre[cur] = cur !== ChatVariableEnabledField.MaxTokensEnabled;
|
||||
return pre;
|
||||
}, {});
|
||||
const variableCheckBoxFieldMap = setChatVariableEnabledFieldValuePage();
|
||||
form.setFieldsValue({ ...nextVariable, ...variableCheckBoxFieldMap });
|
||||
},
|
||||
[form, prefix],
|
||||
@ -109,7 +104,11 @@ const LlmSettingItems = ({ prefix, formItemLayout = {}, onChange }: IProps) => {
|
||||
>
|
||||
<Switch size="small" />
|
||||
</Form.Item>
|
||||
<Form.Item noStyle dependencies={['temperatureEnabled']}>
|
||||
<Form.Item
|
||||
noStyle
|
||||
dependencies={['temperatureEnabled']}
|
||||
shouldUpdate
|
||||
>
|
||||
{({ getFieldValue }) => {
|
||||
const disabled = !getFieldValue('temperatureEnabled');
|
||||
return (
|
||||
@ -154,7 +153,7 @@ const LlmSettingItems = ({ prefix, formItemLayout = {}, onChange }: IProps) => {
|
||||
<Form.Item name={'topPEnabled'} valuePropName="checked" noStyle>
|
||||
<Switch size="small" />
|
||||
</Form.Item>
|
||||
<Form.Item noStyle dependencies={['topPEnabled']}>
|
||||
<Form.Item noStyle dependencies={['topPEnabled']} shouldUpdate>
|
||||
{({ getFieldValue }) => {
|
||||
const disabled = !getFieldValue('topPEnabled');
|
||||
return (
|
||||
@ -197,7 +196,11 @@ const LlmSettingItems = ({ prefix, formItemLayout = {}, onChange }: IProps) => {
|
||||
>
|
||||
<Switch size="small" />
|
||||
</Form.Item>
|
||||
<Form.Item noStyle dependencies={['presencePenaltyEnabled']}>
|
||||
<Form.Item
|
||||
noStyle
|
||||
dependencies={['presencePenaltyEnabled']}
|
||||
shouldUpdate
|
||||
>
|
||||
{({ getFieldValue }) => {
|
||||
const disabled = !getFieldValue('presencePenaltyEnabled');
|
||||
return (
|
||||
@ -246,7 +249,11 @@ const LlmSettingItems = ({ prefix, formItemLayout = {}, onChange }: IProps) => {
|
||||
>
|
||||
<Switch size="small" />
|
||||
</Form.Item>
|
||||
<Form.Item noStyle dependencies={['frequencyPenaltyEnabled']}>
|
||||
<Form.Item
|
||||
noStyle
|
||||
dependencies={['frequencyPenaltyEnabled']}
|
||||
shouldUpdate
|
||||
>
|
||||
{({ getFieldValue }) => {
|
||||
const disabled = !getFieldValue('frequencyPenaltyEnabled');
|
||||
return (
|
||||
@ -295,7 +302,11 @@ const LlmSettingItems = ({ prefix, formItemLayout = {}, onChange }: IProps) => {
|
||||
>
|
||||
<Switch size="small" />
|
||||
</Form.Item>
|
||||
<Form.Item noStyle dependencies={['maxTokensEnabled']}>
|
||||
<Form.Item
|
||||
noStyle
|
||||
dependencies={['maxTokensEnabled']}
|
||||
shouldUpdate
|
||||
>
|
||||
{({ getFieldValue }) => {
|
||||
const disabled = !getFieldValue('maxTokensEnabled');
|
||||
|
||||
|
@ -21,6 +21,7 @@ import {
|
||||
ISwitchForm,
|
||||
RAGFlowNodeType,
|
||||
} from '@/interfaces/database/flow';
|
||||
import { setChatVariableEnabledFieldValuePage } from '@/utils/chat';
|
||||
import { message } from 'antd';
|
||||
import { humanId } from 'human-id';
|
||||
import { get, lowerFirst } from 'lodash';
|
||||
@ -271,11 +272,13 @@ export const useHandleFormValuesChange = (id?: string) => {
|
||||
'parameter' in changedValues &&
|
||||
changedValues['parameter'] in settledModelVariableMap
|
||||
) {
|
||||
const enabledValues = setChatVariableEnabledFieldValuePage();
|
||||
nextValues = {
|
||||
...values,
|
||||
...settledModelVariableMap[
|
||||
changedValues['parameter'] as keyof typeof settledModelVariableMap
|
||||
],
|
||||
...enabledValues,
|
||||
};
|
||||
}
|
||||
if (id) {
|
||||
|
@ -73,3 +73,14 @@ const ShowImageFields = ['image', 'table'];
|
||||
export function showImage(filed?: string) {
|
||||
return ShowImageFields.some((x) => x === filed);
|
||||
}
|
||||
|
||||
export function setChatVariableEnabledFieldValuePage() {
|
||||
const variableCheckBoxFieldMap = Object.values(
|
||||
ChatVariableEnabledField,
|
||||
).reduce<Record<string, boolean>>((pre, cur) => {
|
||||
pre[cur] = cur !== ChatVariableEnabledField.MaxTokensEnabled;
|
||||
return pre;
|
||||
}, {});
|
||||
|
||||
return variableCheckBoxFieldMap;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user