import { LlmModelType, ModelVariableType } from '@/constants/knowledge'; import { useTranslate } from '@/hooks/common-hooks'; import { useComposeLlmOptionsByModelTypes } from '@/hooks/llm-hooks'; import { camelCase } from 'lodash'; import { useCallback } from 'react'; import { useFormContext } from 'react-hook-form'; import { FormControl, FormField, FormItem, FormLabel, FormMessage, } from '../ui/form'; import { Input } from '../ui/input'; import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue, } from '../ui/select'; import { FormSlider } from '../ui/slider'; import { Switch } from '../ui/switch'; interface SliderWithInputNumberFormFieldProps { name: string; label: string; checkName: string; max: number; min?: number; step?: number; } function SliderWithInputNumberFormField({ name, label, checkName, max, min = 0, step = 1, }: SliderWithInputNumberFormFieldProps) { const { control, watch } = useFormContext(); const { t } = useTranslate('chat'); const disabled = !watch(checkName); return ( (
{t(label)} ( )} />
)} /> ); } interface LlmSettingFieldItemsProps { prefix?: string; } export function LlmSettingFieldItems({ prefix }: LlmSettingFieldItemsProps) { const form = useFormContext(); const { t } = useTranslate('chat'); const modelOptions = useComposeLlmOptionsByModelTypes([ LlmModelType.Chat, LlmModelType.Image2text, ]); const parameterOptions = Object.values(ModelVariableType).map((x) => ({ label: t(camelCase(x)), value: x, })); const getFieldWithPrefix = useCallback( (name: string) => { return `${prefix}.${name}`; }, [prefix], ); return (
( {t('model')} )} /> ( {t('freedom')} )} />
); }