mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-14 00:36:02 +08:00
### What problem does this PR solve? Feat: Disable Max_token by default #5283 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
parent
ec96426c00
commit
1137b04154
@ -3,12 +3,20 @@ export enum MessageType {
|
||||
User = 'user',
|
||||
}
|
||||
|
||||
export enum ChatVariableEnabledField {
|
||||
TemperatureEnabled = 'temperatureEnabled',
|
||||
TopPEnabled = 'topPEnabled',
|
||||
PresencePenaltyEnabled = 'presencePenaltyEnabled',
|
||||
FrequencyPenaltyEnabled = 'frequencyPenaltyEnabled',
|
||||
MaxTokensEnabled = 'maxTokensEnabled',
|
||||
}
|
||||
|
||||
export const variableEnabledFieldMap = {
|
||||
temperatureEnabled: 'temperature',
|
||||
topPEnabled: 'top_p',
|
||||
presencePenaltyEnabled: 'presence_penalty',
|
||||
frequencyPenaltyEnabled: 'frequency_penalty',
|
||||
maxTokensEnabled: 'max_tokens',
|
||||
[ChatVariableEnabledField.TemperatureEnabled]: 'temperature',
|
||||
[ChatVariableEnabledField.TopPEnabled]: 'top_p',
|
||||
[ChatVariableEnabledField.PresencePenaltyEnabled]: 'presence_penalty',
|
||||
[ChatVariableEnabledField.FrequencyPenaltyEnabled]: 'frequency_penalty',
|
||||
[ChatVariableEnabledField.MaxTokensEnabled]: 'max_tokens',
|
||||
};
|
||||
|
||||
export enum SharedFrom {
|
||||
|
@ -3,8 +3,12 @@ import { useEffect } from 'react';
|
||||
import { ISegmentedContentProps } from '../interface';
|
||||
|
||||
import LlmSettingItems from '@/components/llm-setting-items';
|
||||
import { variableEnabledFieldMap } from '@/constants/chat';
|
||||
import {
|
||||
ChatVariableEnabledField,
|
||||
variableEnabledFieldMap,
|
||||
} from '@/constants/chat';
|
||||
import { Variable } from '@/interfaces/database/chat';
|
||||
import { setInitialChatVariableEnabledFieldValue } from '@/utils/chat';
|
||||
import styles from './index.less';
|
||||
|
||||
const ModelSetting = ({
|
||||
@ -23,7 +27,9 @@ const ModelSetting = ({
|
||||
>((pre, field) => {
|
||||
pre[field] =
|
||||
initialLlmSetting === undefined
|
||||
? true
|
||||
? setInitialChatVariableEnabledFieldValue(
|
||||
field as ChatVariableEnabledField,
|
||||
)
|
||||
: !!initialLlmSetting[
|
||||
variableEnabledFieldMap[
|
||||
field as keyof typeof variableEnabledFieldMap
|
||||
|
@ -30,8 +30,12 @@ import { ReactComponent as YahooFinanceIcon } from '@/assets/svg/yahoo-finance.s
|
||||
|
||||
// 邮件功能
|
||||
|
||||
import { variableEnabledFieldMap } from '@/constants/chat';
|
||||
import {
|
||||
ChatVariableEnabledField,
|
||||
variableEnabledFieldMap,
|
||||
} from '@/constants/chat';
|
||||
import i18n from '@/locales/config';
|
||||
import { setInitialChatVariableEnabledFieldValue } from '@/utils/chat';
|
||||
|
||||
// DuckDuckGo's channel options
|
||||
export enum Channel {
|
||||
@ -403,7 +407,9 @@ export const initialBeginValues = {
|
||||
export const variableCheckBoxFieldMap = Object.keys(
|
||||
variableEnabledFieldMap,
|
||||
).reduce<Record<string, boolean>>((pre, cur) => {
|
||||
pre[cur] = true;
|
||||
pre[cur] = setInitialChatVariableEnabledFieldValue(
|
||||
cur as ChatVariableEnabledField,
|
||||
);
|
||||
return pre;
|
||||
}, {});
|
||||
|
||||
|
@ -13,22 +13,17 @@ import React, {
|
||||
useState,
|
||||
} from 'react';
|
||||
// import { shallow } from 'zustand/shallow';
|
||||
import { variableEnabledFieldMap } from '@/constants/chat';
|
||||
import {
|
||||
ModelVariableType,
|
||||
settledModelVariableMap,
|
||||
} from '@/constants/knowledge';
|
||||
import { settledModelVariableMap } from '@/constants/knowledge';
|
||||
import { useFetchModelId } from '@/hooks/logic-hooks';
|
||||
import { Variable } from '@/interfaces/database/chat';
|
||||
import {
|
||||
ICategorizeForm,
|
||||
IRelevantForm,
|
||||
ISwitchForm,
|
||||
RAGFlowNodeType,
|
||||
} from '@/interfaces/database/flow';
|
||||
import { FormInstance, message } from 'antd';
|
||||
import { message } from 'antd';
|
||||
import { humanId } from 'human-id';
|
||||
import { get, isEmpty, lowerFirst, pick } from 'lodash';
|
||||
import { get, lowerFirst } from 'lodash';
|
||||
import trim from 'lodash/trim';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
@ -291,38 +286,6 @@ export const useHandleFormValuesChange = (id?: string) => {
|
||||
return { handleValuesChange };
|
||||
};
|
||||
|
||||
export const useSetLlmSetting = (
|
||||
form?: FormInstance,
|
||||
formData?: Record<string, any>,
|
||||
) => {
|
||||
const initialLlmSetting = pick(
|
||||
formData,
|
||||
Object.values(variableEnabledFieldMap),
|
||||
);
|
||||
useEffect(() => {
|
||||
const switchBoxValues = Object.keys(variableEnabledFieldMap).reduce<
|
||||
Record<string, boolean>
|
||||
>((pre, field) => {
|
||||
pre[field] = isEmpty(initialLlmSetting)
|
||||
? true
|
||||
: !!initialLlmSetting[
|
||||
variableEnabledFieldMap[
|
||||
field as keyof typeof variableEnabledFieldMap
|
||||
] as keyof Variable
|
||||
];
|
||||
return pre;
|
||||
}, {});
|
||||
let otherValues = settledModelVariableMap[ModelVariableType.Precise];
|
||||
if (!isEmpty(initialLlmSetting)) {
|
||||
otherValues = initialLlmSetting;
|
||||
}
|
||||
form?.setFieldsValue({
|
||||
...switchBoxValues,
|
||||
...otherValues,
|
||||
});
|
||||
}, [form, initialLlmSetting]);
|
||||
};
|
||||
|
||||
export const useValidateConnection = () => {
|
||||
const { edges, getOperatorTypeFromId, getParentIdById } = useGraphStore(
|
||||
(state) => state,
|
||||
|
@ -1,4 +1,7 @@
|
||||
import { EmptyConversationId } from '@/constants/chat';
|
||||
import {
|
||||
ChatVariableEnabledField,
|
||||
EmptyConversationId,
|
||||
} from '@/constants/chat';
|
||||
import { Message } from '@/interfaces/database/chat';
|
||||
import { IMessage } from '@/pages/chat/interface';
|
||||
import { omit } from 'lodash';
|
||||
@ -57,3 +60,9 @@ export function replaceThinkToSection(text: string = '') {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export function setInitialChatVariableEnabledFieldValue(
|
||||
field: ChatVariableEnabledField,
|
||||
) {
|
||||
return field !== ChatVariableEnabledField.MaxTokensEnabled;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user