Spaces:
Paused
Paused
File size: 842 Bytes
ab2ded1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import { variableEnabledFieldMap } from '@/constants/chat';
import omit from 'lodash/omit';
// chat model setting and generate operator
export const excludeUnEnabledVariables = (
values: any = {},
prefix = 'llm_setting.',
) => {
const unEnabledFields: Array<keyof typeof variableEnabledFieldMap> =
Object.keys(variableEnabledFieldMap).filter((key) => !values[key]) as Array<
keyof typeof variableEnabledFieldMap
>;
return unEnabledFields.map(
(key) => `${prefix}${variableEnabledFieldMap[key]}`,
);
};
// chat model setting and generate operator
export const removeUselessFieldsFromValues = (values: any, prefix?: string) => {
const nextValues: any = omit(values, [
...Object.keys(variableEnabledFieldMap),
'parameter',
...excludeUnEnabledVariables(values, prefix),
]);
return nextValues;
};
|