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 { Flex, Form, InputNumber, Select, Slider, Switch, Tooltip } from 'antd';
|
||||||
import camelCase from 'lodash/camelCase';
|
import camelCase from 'lodash/camelCase';
|
||||||
|
|
||||||
import { ChatVariableEnabledField } from '@/constants/chat';
|
|
||||||
import { useTranslate } from '@/hooks/common-hooks';
|
import { useTranslate } from '@/hooks/common-hooks';
|
||||||
import { useComposeLlmOptionsByModelTypes } from '@/hooks/llm-hooks';
|
import { useComposeLlmOptionsByModelTypes } from '@/hooks/llm-hooks';
|
||||||
|
import { setChatVariableEnabledFieldValuePage } from '@/utils/chat';
|
||||||
import { QuestionCircleOutlined } from '@ant-design/icons';
|
import { QuestionCircleOutlined } from '@ant-design/icons';
|
||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
@ -35,12 +35,7 @@ const LlmSettingItems = ({ prefix, formItemLayout = {}, onChange }: IProps) => {
|
|||||||
if (prefix) {
|
if (prefix) {
|
||||||
nextVariable = { [prefix]: variable };
|
nextVariable = { [prefix]: variable };
|
||||||
}
|
}
|
||||||
const variableCheckBoxFieldMap = Object.values(
|
const variableCheckBoxFieldMap = setChatVariableEnabledFieldValuePage();
|
||||||
ChatVariableEnabledField,
|
|
||||||
).reduce<Record<string, boolean>>((pre, cur) => {
|
|
||||||
pre[cur] = cur !== ChatVariableEnabledField.MaxTokensEnabled;
|
|
||||||
return pre;
|
|
||||||
}, {});
|
|
||||||
form.setFieldsValue({ ...nextVariable, ...variableCheckBoxFieldMap });
|
form.setFieldsValue({ ...nextVariable, ...variableCheckBoxFieldMap });
|
||||||
},
|
},
|
||||||
[form, prefix],
|
[form, prefix],
|
||||||
@ -109,7 +104,11 @@ const LlmSettingItems = ({ prefix, formItemLayout = {}, onChange }: IProps) => {
|
|||||||
>
|
>
|
||||||
<Switch size="small" />
|
<Switch size="small" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item noStyle dependencies={['temperatureEnabled']}>
|
<Form.Item
|
||||||
|
noStyle
|
||||||
|
dependencies={['temperatureEnabled']}
|
||||||
|
shouldUpdate
|
||||||
|
>
|
||||||
{({ getFieldValue }) => {
|
{({ getFieldValue }) => {
|
||||||
const disabled = !getFieldValue('temperatureEnabled');
|
const disabled = !getFieldValue('temperatureEnabled');
|
||||||
return (
|
return (
|
||||||
@ -154,7 +153,7 @@ const LlmSettingItems = ({ prefix, formItemLayout = {}, onChange }: IProps) => {
|
|||||||
<Form.Item name={'topPEnabled'} valuePropName="checked" noStyle>
|
<Form.Item name={'topPEnabled'} valuePropName="checked" noStyle>
|
||||||
<Switch size="small" />
|
<Switch size="small" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item noStyle dependencies={['topPEnabled']}>
|
<Form.Item noStyle dependencies={['topPEnabled']} shouldUpdate>
|
||||||
{({ getFieldValue }) => {
|
{({ getFieldValue }) => {
|
||||||
const disabled = !getFieldValue('topPEnabled');
|
const disabled = !getFieldValue('topPEnabled');
|
||||||
return (
|
return (
|
||||||
@ -197,7 +196,11 @@ const LlmSettingItems = ({ prefix, formItemLayout = {}, onChange }: IProps) => {
|
|||||||
>
|
>
|
||||||
<Switch size="small" />
|
<Switch size="small" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item noStyle dependencies={['presencePenaltyEnabled']}>
|
<Form.Item
|
||||||
|
noStyle
|
||||||
|
dependencies={['presencePenaltyEnabled']}
|
||||||
|
shouldUpdate
|
||||||
|
>
|
||||||
{({ getFieldValue }) => {
|
{({ getFieldValue }) => {
|
||||||
const disabled = !getFieldValue('presencePenaltyEnabled');
|
const disabled = !getFieldValue('presencePenaltyEnabled');
|
||||||
return (
|
return (
|
||||||
@ -246,7 +249,11 @@ const LlmSettingItems = ({ prefix, formItemLayout = {}, onChange }: IProps) => {
|
|||||||
>
|
>
|
||||||
<Switch size="small" />
|
<Switch size="small" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item noStyle dependencies={['frequencyPenaltyEnabled']}>
|
<Form.Item
|
||||||
|
noStyle
|
||||||
|
dependencies={['frequencyPenaltyEnabled']}
|
||||||
|
shouldUpdate
|
||||||
|
>
|
||||||
{({ getFieldValue }) => {
|
{({ getFieldValue }) => {
|
||||||
const disabled = !getFieldValue('frequencyPenaltyEnabled');
|
const disabled = !getFieldValue('frequencyPenaltyEnabled');
|
||||||
return (
|
return (
|
||||||
@ -295,7 +302,11 @@ const LlmSettingItems = ({ prefix, formItemLayout = {}, onChange }: IProps) => {
|
|||||||
>
|
>
|
||||||
<Switch size="small" />
|
<Switch size="small" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item noStyle dependencies={['maxTokensEnabled']}>
|
<Form.Item
|
||||||
|
noStyle
|
||||||
|
dependencies={['maxTokensEnabled']}
|
||||||
|
shouldUpdate
|
||||||
|
>
|
||||||
{({ getFieldValue }) => {
|
{({ getFieldValue }) => {
|
||||||
const disabled = !getFieldValue('maxTokensEnabled');
|
const disabled = !getFieldValue('maxTokensEnabled');
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ import {
|
|||||||
ISwitchForm,
|
ISwitchForm,
|
||||||
RAGFlowNodeType,
|
RAGFlowNodeType,
|
||||||
} from '@/interfaces/database/flow';
|
} from '@/interfaces/database/flow';
|
||||||
|
import { setChatVariableEnabledFieldValuePage } from '@/utils/chat';
|
||||||
import { message } from 'antd';
|
import { message } from 'antd';
|
||||||
import { humanId } from 'human-id';
|
import { humanId } from 'human-id';
|
||||||
import { get, lowerFirst } from 'lodash';
|
import { get, lowerFirst } from 'lodash';
|
||||||
@ -271,11 +272,13 @@ export const useHandleFormValuesChange = (id?: string) => {
|
|||||||
'parameter' in changedValues &&
|
'parameter' in changedValues &&
|
||||||
changedValues['parameter'] in settledModelVariableMap
|
changedValues['parameter'] in settledModelVariableMap
|
||||||
) {
|
) {
|
||||||
|
const enabledValues = setChatVariableEnabledFieldValuePage();
|
||||||
nextValues = {
|
nextValues = {
|
||||||
...values,
|
...values,
|
||||||
...settledModelVariableMap[
|
...settledModelVariableMap[
|
||||||
changedValues['parameter'] as keyof typeof settledModelVariableMap
|
changedValues['parameter'] as keyof typeof settledModelVariableMap
|
||||||
],
|
],
|
||||||
|
...enabledValues,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (id) {
|
if (id) {
|
||||||
|
@ -73,3 +73,14 @@ const ShowImageFields = ['image', 'table'];
|
|||||||
export function showImage(filed?: string) {
|
export function showImage(filed?: string) {
|
||||||
return ShowImageFields.some((x) => x === filed);
|
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