import { LlmModelType, ModelVariableType, settledModelVariableMap, } from '@/constants/knowledge'; import { Divider, Flex, Form, InputNumber, Select, Slider, Switch } from 'antd'; import classNames from 'classnames'; import camelCase from 'lodash/camelCase'; import { useEffect } from 'react'; import { ISegmentedContentProps } from '../interface'; import { useTranslate } from '@/hooks/commonHooks'; import { useFetchLlmList, useSelectLlmOptions } from '@/hooks/llmHooks'; import { Variable } from '@/interfaces/database/chat'; import { variableEnabledFieldMap } from '../constants'; import styles from './index.less'; const ModelSetting = ({ show, form, initialLlmSetting, visible, }: ISegmentedContentProps & { initialLlmSetting?: Variable; visible?: boolean; }) => { const { t } = useTranslate('chat'); const parameterOptions = Object.values(ModelVariableType).map((x) => ({ label: t(camelCase(x)), value: x, })); const modelOptions = useSelectLlmOptions(); const handleParametersChange = (value: ModelVariableType) => { const variable = settledModelVariableMap[value]; form.setFieldsValue({ llm_setting: variable }); }; useEffect(() => { if (visible) { const values = Object.keys(variableEnabledFieldMap).reduce< Record >((pre, field) => { pre[field] = initialLlmSetting === undefined ? true : !!initialLlmSetting[ variableEnabledFieldMap[ field as keyof typeof variableEnabledFieldMap ] as keyof Variable ]; return pre; }, {}); form.setFieldsValue(values); } }, [form, initialLlmSetting, visible]); useFetchLlmList(LlmModelType.Chat); return (