import { LlmModelType } from '@/constants/knowledge'; import { useTranslate } from '@/hooks/common-hooks'; import { useSelectLlmOptionsByModelType } from '@/hooks/use-llm-request'; import { useFormContext } from 'react-hook-form'; import { z } from 'zod'; import { SelectWithSearch } from './originui/select-with-search'; import { SliderInputFormField } from './slider-input-form-field'; import { FormControl, FormField, FormItem, FormLabel, FormMessage, } from './ui/form'; export const topKSchema = { top_k: z.number().optional(), }; export const initialTopKValue = { top_k: 1024, }; const RerankId = 'rerank_id'; function RerankFormField() { const form = useFormContext(); const { t } = useTranslate('knowledgeDetails'); const allOptions = useSelectLlmOptionsByModelType(); const options = allOptions[LlmModelType.Rerank]; return ( ( {t('rerankModel')} )} /> ); } export const rerankFormSchema = { [RerankId]: z.string().optional(), top_k: z.coerce.number().optional(), }; export function RerankFormFields() { const { watch } = useFormContext(); const { t } = useTranslate('knowledgeDetails'); const rerankId = watch(RerankId); return ( <> {rerankId && ( )} ); }