feat: model config required check;feat: dataset text model default setting (#3866)
* feat: model config required check * feat: dataset text model default setting * perf: collection list count * fix: ts * remove index count
This commit is contained in:
@@ -59,6 +59,7 @@ import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||
import AIModelSelector from '@/components/Select/AIModelSelector';
|
||||
import { useRefresh } from '../../../../../../packages/web/hooks/useRefresh';
|
||||
import { Prompt_CQJson, Prompt_ExtractJson } from '@fastgpt/global/core/ai/prompt/agent';
|
||||
import MyDivider from '@fastgpt/web/components/common/MyDivider';
|
||||
|
||||
const MyModal = dynamic(() => import('@fastgpt/web/components/common/MyModal'));
|
||||
|
||||
@@ -730,7 +731,12 @@ const ModelEditModal = ({
|
||||
<Td>{t('common:core.ai.Max context')}</Td>
|
||||
<Td textAlign={'right'}>
|
||||
<Flex justifyContent={'flex-end'}>
|
||||
<MyNumberInput register={register} name="maxContext" {...InputStyles} />
|
||||
<MyNumberInput
|
||||
register={register}
|
||||
isRequired
|
||||
name="maxContext"
|
||||
{...InputStyles}
|
||||
/>
|
||||
</Flex>
|
||||
</Td>
|
||||
</Tr>
|
||||
@@ -740,6 +746,7 @@ const ModelEditModal = ({
|
||||
<Flex justifyContent={'flex-end'}>
|
||||
<MyNumberInput
|
||||
register={register}
|
||||
isRequired
|
||||
name="quoteMaxToken"
|
||||
{...InputStyles}
|
||||
/>
|
||||
@@ -750,7 +757,12 @@ const ModelEditModal = ({
|
||||
<Td>{t('common:core.chat.response.module maxToken')}</Td>
|
||||
<Td textAlign={'right'}>
|
||||
<Flex justifyContent={'flex-end'}>
|
||||
<MyNumberInput register={register} name="maxResponse" {...InputStyles} />
|
||||
<MyNumberInput
|
||||
register={register}
|
||||
isRequired
|
||||
name="maxResponse"
|
||||
{...InputStyles}
|
||||
/>
|
||||
</Flex>
|
||||
</Td>
|
||||
</Tr>
|
||||
@@ -760,6 +772,7 @@ const ModelEditModal = ({
|
||||
<Flex justifyContent={'flex-end'}>
|
||||
<MyNumberInput
|
||||
register={register}
|
||||
isRequired
|
||||
name="maxTemperature"
|
||||
step={0.1}
|
||||
{...InputStyles}
|
||||
@@ -838,7 +851,12 @@ const ModelEditModal = ({
|
||||
</Td>
|
||||
<Td textAlign={'right'}>
|
||||
<Flex justifyContent={'flex-end'}>
|
||||
<MyNumberInput register={register} name="defaultToken" {...InputStyles} />
|
||||
<MyNumberInput
|
||||
register={register}
|
||||
isRequired
|
||||
name="defaultToken"
|
||||
{...InputStyles}
|
||||
/>
|
||||
</Flex>
|
||||
</Td>
|
||||
</Tr>
|
||||
@@ -846,7 +864,12 @@ const ModelEditModal = ({
|
||||
<Td>{t('common:core.ai.Max context')}</Td>
|
||||
<Td textAlign={'right'}>
|
||||
<Flex justifyContent={'flex-end'}>
|
||||
<MyNumberInput register={register} name="maxToken" {...InputStyles} />
|
||||
<MyNumberInput
|
||||
register={register}
|
||||
isRequired
|
||||
name="maxToken"
|
||||
{...InputStyles}
|
||||
/>
|
||||
</Flex>
|
||||
</Td>
|
||||
</Tr>
|
||||
@@ -1214,6 +1237,7 @@ const DefaultModelModal = ({
|
||||
const {
|
||||
defaultModels,
|
||||
llmModelList,
|
||||
datasetModelList,
|
||||
embeddingModelList,
|
||||
ttsModelList,
|
||||
sttModelList,
|
||||
@@ -1334,6 +1358,29 @@ const DefaultModelModal = ({
|
||||
/>
|
||||
</Box>
|
||||
</Box>
|
||||
<MyDivider />
|
||||
<Box>
|
||||
<Flex {...labelStyles} alignItems={'center'}>
|
||||
<Box mr={0.5}>{t('common:core.ai.model.Dataset Agent Model')}</Box>
|
||||
<QuestionTip label={t('common:dataset_text_model_tip')} />
|
||||
</Flex>
|
||||
<Box flex={1}>
|
||||
<AIModelSelector
|
||||
bg="myGray.50"
|
||||
value={defaultData.datasetTextLLM?.model}
|
||||
list={datasetModelList.map((item) => ({
|
||||
value: item.model,
|
||||
label: item.name
|
||||
}))}
|
||||
onchange={(e) => {
|
||||
setDefaultData((state) => ({
|
||||
...state,
|
||||
datasetTextLLM: datasetModelList.find((item) => item.model === e)
|
||||
}));
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
</Box>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button variant={'whiteBase'} mr={4} onClick={onClose}>
|
||||
@@ -1347,7 +1394,9 @@ const DefaultModelModal = ({
|
||||
[ModelTypeEnum.embedding]: defaultData.embedding?.model,
|
||||
[ModelTypeEnum.tts]: defaultData.tts?.model,
|
||||
[ModelTypeEnum.stt]: defaultData.stt?.model,
|
||||
[ModelTypeEnum.rerank]: defaultData.rerank?.model
|
||||
[ModelTypeEnum.rerank]: defaultData.rerank?.model,
|
||||
datasetTextLLM: defaultData.datasetTextLLM?.model,
|
||||
datasetImageLLM: defaultData.datasetImageLLM?.model
|
||||
})
|
||||
}
|
||||
>
|
||||
|
||||
@@ -5,7 +5,7 @@ import { llmModelTypeFilterMap } from '@fastgpt/global/core/ai/constants';
|
||||
import AIModelSelector from '@/components/Select/AIModelSelector';
|
||||
import { useContextSelector } from 'use-context-selector';
|
||||
import { WorkflowContext } from '@/pageComponents/app/detail/WorkflowComponents/context';
|
||||
import { getWebDefaultModel } from '@/web/common/system/utils';
|
||||
import { getWebDefaultLLMModel } from '@/web/common/system/utils';
|
||||
|
||||
const SelectAiModelRender = ({ item, nodeId }: RenderInputProps) => {
|
||||
const { llmModelList } = useSystemStore();
|
||||
@@ -23,7 +23,7 @@ const SelectAiModelRender = ({ item, nodeId }: RenderInputProps) => {
|
||||
[llmModelList, item.llmModelType]
|
||||
);
|
||||
const defaultModel = useMemo(() => {
|
||||
return getWebDefaultModel(modelList).model;
|
||||
return getWebDefaultLLMModel(modelList).model;
|
||||
}, [modelList]);
|
||||
|
||||
const onChangeModel = useCallback(
|
||||
|
||||
@@ -10,7 +10,7 @@ import { getCollectionIcon } from '@fastgpt/global/core/dataset/utils';
|
||||
import {
|
||||
delDatasetCollectionTag,
|
||||
getDatasetCollectionTags,
|
||||
getScrollCollectionList,
|
||||
getDatasetCollections,
|
||||
getTagUsage,
|
||||
postAddTagsToCollections,
|
||||
updateDatasetCollectionTag
|
||||
@@ -146,7 +146,7 @@ const TagManageModal = ({ onClose }: { onClose: () => void }) => {
|
||||
scrollDataList: collectionsList,
|
||||
ScrollList: ScrollListCollections,
|
||||
isLoading: collectionsListLoading
|
||||
} = useVirtualScrollPagination(getScrollCollectionList, {
|
||||
} = useVirtualScrollPagination(getDatasetCollections, {
|
||||
refreshDeps: [searchText],
|
||||
// debounceWait: 300,
|
||||
|
||||
@@ -156,6 +156,7 @@ const TagManageModal = ({ onClose }: { onClose: () => void }) => {
|
||||
pageSize: 30,
|
||||
defaultParams: {
|
||||
datasetId: datasetDetail._id,
|
||||
simple: true,
|
||||
searchText
|
||||
}
|
||||
});
|
||||
|
||||
@@ -195,7 +195,7 @@ const CollectionCard = () => {
|
||||
<Tr>
|
||||
<Th py={4}>{t('common:common.Name')}</Th>
|
||||
<Th py={4}>{t('dataset:collection.Training type')}</Th>
|
||||
<Th py={4}>{t('common:dataset.collections.Data Amount')}</Th>
|
||||
<Th py={4}>{t('dataset:collection_data_count')}</Th>
|
||||
<Th py={4}>{t('dataset:collection.Create update time')}</Th>
|
||||
<Th py={4}>{t('common:common.Status')}</Th>
|
||||
<Th py={4}>{t('dataset:Enable')}</Th>
|
||||
|
||||
@@ -29,10 +29,8 @@ import Markdown from '@/components/Markdown';
|
||||
import { useMemoizedFn } from 'ahooks';
|
||||
import { useScrollPagination } from '@fastgpt/web/hooks/useScrollPagination';
|
||||
import { TabEnum } from './NavBar';
|
||||
import {
|
||||
DatasetCollectionTypeEnum,
|
||||
ImportDataSourceEnum
|
||||
} from '@fastgpt/global/core/dataset/constants';
|
||||
import { ImportDataSourceEnum } from '@fastgpt/global/core/dataset/constants';
|
||||
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
|
||||
|
||||
const DataCard = () => {
|
||||
const theme = useTheme();
|
||||
@@ -76,19 +74,17 @@ const DataCard = () => {
|
||||
const [editDataId, setEditDataId] = useState<string>();
|
||||
|
||||
// get file info
|
||||
const { data: collection } = useQuery(
|
||||
['getDatasetCollectionById', collectionId],
|
||||
() => getDatasetCollectionById(collectionId),
|
||||
{
|
||||
onError: () => {
|
||||
router.replace({
|
||||
query: {
|
||||
datasetId
|
||||
}
|
||||
});
|
||||
}
|
||||
const { data: collection } = useRequest2(() => getDatasetCollectionById(collectionId), {
|
||||
refreshDeps: [collectionId],
|
||||
manual: false,
|
||||
onError: () => {
|
||||
router.replace({
|
||||
query: {
|
||||
datasetId
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
const canWrite = useMemo(() => datasetDetail.permission.hasWritePer, [datasetDetail]);
|
||||
|
||||
@@ -182,7 +178,10 @@ const DataCard = () => {
|
||||
<Flex align={'center'} color={'myGray.500'}>
|
||||
<MyIcon name="common/list" mr={2} w={'18px'} />
|
||||
<Box as={'span'} fontSize={['sm', '14px']} fontWeight={'500'}>
|
||||
{t('common:core.dataset.data.Total Amount', { total })}
|
||||
{t('dataset:data_amount', {
|
||||
dataAmount: total,
|
||||
indexAmount: collection?.indexAmount ?? '-'
|
||||
})}
|
||||
</Box>
|
||||
</Flex>
|
||||
<Box flex={1} mr={1} />
|
||||
|
||||
@@ -164,12 +164,12 @@ const Info = ({ datasetId }: { datasetId: string }) => {
|
||||
</Flex>
|
||||
|
||||
<Box mt={5} w={'100%'}>
|
||||
<Flex alignItems={'center'} fontSize={'mini'}>
|
||||
<FormLabel fontWeight={'500'} flex={'1 0 0'}>
|
||||
<Flex alignItems={'center'}>
|
||||
<FormLabel fontWeight={'500'} flex={'1 0 0'} fontSize={'mini'}>
|
||||
{t('common:core.ai.model.Vector Model')}
|
||||
</FormLabel>
|
||||
<MyTooltip label={t('dataset:vector_model_max_tokens_tip')}>
|
||||
<Box>
|
||||
<Box fontSize={'mini'}>
|
||||
{t('dataset:chunk_max_tokens')}: {vectorModel.maxToken}
|
||||
</Box>
|
||||
</MyTooltip>
|
||||
|
||||
@@ -21,7 +21,7 @@ import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||
import { getDocPath } from '@/web/common/system/doc';
|
||||
import { datasetTypeCourseMap } from '@/web/core/dataset/constants';
|
||||
import ApiDatasetForm from '../ApiDatasetForm';
|
||||
import { getWebDefaultModel } from '@/web/common/system/utils';
|
||||
import { getWebDefaultEmbeddingModel, getWebDefaultLLMModel } from '@/web/common/system/utils';
|
||||
|
||||
export type CreateDatasetType =
|
||||
| DatasetTypeEnum.dataset
|
||||
@@ -40,7 +40,6 @@ const CreateModal = ({
|
||||
type: CreateDatasetType;
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { toast } = useToast();
|
||||
const router = useRouter();
|
||||
const { defaultModels, embeddingModelList, datasetModelList } = useSystemStore();
|
||||
const { isPc } = useSystem();
|
||||
@@ -79,8 +78,10 @@ const CreateModal = ({
|
||||
avatar: datasetTypeMap[type].icon,
|
||||
name: '',
|
||||
intro: '',
|
||||
vectorModel: defaultModels.embedding?.model,
|
||||
agentModel: getWebDefaultModel(datasetModelList)?.model
|
||||
vectorModel:
|
||||
defaultModels.embedding?.model || getWebDefaultEmbeddingModel(embeddingModelList)?.model,
|
||||
agentModel:
|
||||
defaultModels.datasetTextLLM?.model || getWebDefaultLLMModel(datasetModelList)?.model
|
||||
}
|
||||
});
|
||||
const { register, setValue, handleSubmit, watch } = form;
|
||||
|
||||
Reference in New Issue
Block a user