* model config

* feat: model config ui

* perf: rename variable

* feat: custom request url

* perf: model buffer

* perf: init model

* feat: json model config

* auto login

* fix: ts

* update packages

* package

* fix: dockerfile
This commit is contained in:
Archer
2025-01-22 22:59:28 +08:00
committed by archer
parent c393002f1d
commit 12c6ecb987
93 changed files with 2361 additions and 564 deletions

View File

@@ -22,7 +22,7 @@ type Props = SelectProps & {
const OneRowSelector = ({ list, onchange, disableTip, ...props }: Props) => {
const { t } = useTranslation();
const { feConfigs, llmModelList, vectorModelList } = useSystemStore();
const { feConfigs, llmModelList, embeddingModelList } = useSystemStore();
const avatarSize = useMemo(() => {
const size = {
@@ -35,7 +35,7 @@ const OneRowSelector = ({ list, onchange, disableTip, ...props }: Props) => {
}, [props.size]);
const avatarList = list.map((item) => {
const modelData = getModelFromList([...llmModelList, ...vectorModelList], item.value);
const modelData = getModelFromList([...llmModelList, ...embeddingModelList], item.value);
return {
value: item.value,
@@ -100,7 +100,7 @@ const OneRowSelector = ({ list, onchange, disableTip, ...props }: Props) => {
};
const MultipleRowSelector = ({ list, onchange, disableTip, ...props }: Props) => {
const { t } = useTranslation();
const { llmModelList, vectorModelList } = useSystemStore();
const { llmModelList, embeddingModelList } = useSystemStore();
const [value, setValue] = useState<string[]>([]);
const avatarSize = useMemo(() => {
@@ -136,7 +136,7 @@ const MultipleRowSelector = ({ list, onchange, disableTip, ...props }: Props) =>
}));
for (const item of list) {
const modelData = getModelFromList([...llmModelList, ...vectorModelList], item.value);
const modelData = getModelFromList([...llmModelList, ...embeddingModelList], item.value);
const provider =
renderList.find((item) => item.value === (modelData?.provider || 'Other')) ??
renderList[renderList.length - 1];
@@ -148,7 +148,7 @@ const MultipleRowSelector = ({ list, onchange, disableTip, ...props }: Props) =>
}
return renderList.filter((item) => item.children.length > 0);
}, [avatarSize, list, llmModelList, t, vectorModelList]);
}, [avatarSize, list, llmModelList, t, embeddingModelList]);
const onSelect = useCallback(
(e: string[]) => {
@@ -158,7 +158,7 @@ const MultipleRowSelector = ({ list, onchange, disableTip, ...props }: Props) =>
);
const SelectedModel = useMemo(() => {
const modelData = getModelFromList([...llmModelList, ...vectorModelList], props.value);
const modelData = getModelFromList([...llmModelList, ...embeddingModelList], props.value);
setValue([modelData.provider, props.value]);
@@ -174,7 +174,7 @@ const MultipleRowSelector = ({ list, onchange, disableTip, ...props }: Props) =>
<Box>{modelData?.name}</Box>
</HStack>
);
}, [avatarSize, llmModelList, props.value, vectorModelList]);
}, [avatarSize, llmModelList, props.value, embeddingModelList]);
return (
<Box

View File

@@ -53,7 +53,8 @@ const ModelTable = () => {
const [search, setSearch] = useState('');
const { llmModelList, audioSpeechModelList, vectorModelList, whisperModel } = useSystemStore();
const { llmModelList, ttsModelList, embeddingModelList, sttModelList, reRankModelList } =
useSystemStore();
const modelList = useMemo(() => {
const formatLLMModelList = llmModelList.map((item) => ({
@@ -87,7 +88,7 @@ const ModelTable = () => {
),
tagColor: 'blue'
}));
const formatVectorModelList = vectorModelList.map((item) => ({
const formatVectorModelList = embeddingModelList.map((item) => ({
...item,
typeLabel: t('common:model.type.embedding'),
priceLabel: (
@@ -100,7 +101,7 @@ const ModelTable = () => {
),
tagColor: 'yellow'
}));
const formatAudioSpeechModelList = audioSpeechModelList.map((item) => ({
const formatAudioSpeechModelList = ttsModelList.map((item) => ({
...item,
typeLabel: t('common:model.type.tts'),
priceLabel: (
@@ -113,31 +114,39 @@ const ModelTable = () => {
),
tagColor: 'green'
}));
const formatWhisperModel = {
...whisperModel,
const formatWhisperModelList = sttModelList.map((item) => ({
...item,
typeLabel: t('common:model.type.stt'),
priceLabel: (
<Flex color={'myGray.700'}>
<Box fontWeight={'bold'} color={'myGray.900'} mr={0.5}>
{whisperModel.charsPointsPrice}
{item.charsPointsPrice}
</Box>
{` ${t('common:support.wallet.subscription.point')} / 60${t('common:unit.seconds')}`}
</Flex>
),
tagColor: 'purple'
};
}));
const formatRerankModelList = reRankModelList.map((item) => ({
...item,
typeLabel: t('common:model.type.reRank'),
priceLabel: <Flex color={'myGray.700'}>- </Flex>,
tagColor: 'red'
}));
const list = (() => {
if (modelType === ModelTypeEnum.chat) return formatLLMModelList;
if (modelType === ModelTypeEnum.llm) return formatLLMModelList;
if (modelType === ModelTypeEnum.embedding) return formatVectorModelList;
if (modelType === ModelTypeEnum.tts) return formatAudioSpeechModelList;
if (modelType === ModelTypeEnum.stt) return [formatWhisperModel];
if (modelType === ModelTypeEnum.stt) return formatWhisperModelList;
if (modelType === ModelTypeEnum.rerank) return formatRerankModelList;
return [
...formatLLMModelList,
...formatVectorModelList,
...formatAudioSpeechModelList,
formatWhisperModel
...formatWhisperModelList,
...formatRerankModelList
];
})();
const formatList = list.map((item) => {
@@ -167,9 +176,10 @@ const ModelTable = () => {
return filterList;
}, [
llmModelList,
vectorModelList,
audioSpeechModelList,
whisperModel,
embeddingModelList,
ttsModelList,
sttModelList,
reRankModelList,
t,
modelType,
provider,
@@ -179,15 +189,16 @@ const ModelTable = () => {
const filterProviderList = useMemo(() => {
const allProviderIds: string[] = [
...llmModelList,
...vectorModelList,
...audioSpeechModelList,
whisperModel
...embeddingModelList,
...ttsModelList,
...sttModelList,
...reRankModelList
].map((model) => model.provider);
return providerList.current.filter(
(item) => allProviderIds.includes(item.value) || item.value === ''
);
}, [audioSpeechModelList, llmModelList, vectorModelList, whisperModel]);
}, [ttsModelList, llmModelList, embeddingModelList, sttModelList, reRankModelList]);
return (
<Flex flexDirection={'column'} h={'100%'}>

View File

@@ -70,12 +70,10 @@ const DatasetParamsModal = ({
const [currentTabType, setCurrentTabType] = useState(SearchSettingTabEnum.searchMode);
const chatModelSelectList = (() =>
llmModelList
.filter((model) => model.usedInQueryExtension)
.map((item) => ({
value: item.model,
label: item.name
})))();
llmModelList.map((item) => ({
value: item.model,
label: item.name
})))();
const { register, setValue, getValues, handleSubmit, watch } = useForm<DatasetParamsProps>({
defaultValues: {

View File

@@ -25,7 +25,7 @@ const TTSSelect = ({
onChange: (e: AppTTSConfigType) => void;
}) => {
const { t } = useTranslation();
const { audioSpeechModelList } = useSystemStore();
const { ttsModelList } = useSystemStore();
const { isOpen, onOpen, onClose } = useDisclosure();
const appId = useContextSelector(AppContext, (v) => v.appId);
@@ -34,9 +34,9 @@ const TTSSelect = ({
() => [
{ label: t('common:core.app.tts.Close'), value: TTSTypeEnum.none },
{ label: t('common:core.app.tts.Web'), value: TTSTypeEnum.web },
...audioSpeechModelList.map((item) => item?.voices || []).flat()
...ttsModelList.map((item) => item?.voices || []).flat()
],
[audioSpeechModelList, t]
[ttsModelList, t]
);
const formatValue = useMemo(() => {
@@ -63,7 +63,7 @@ const TTSSelect = ({
if (e === TTSTypeEnum.none || e === TTSTypeEnum.web) {
onChange({ type: e as `${TTSTypeEnum}` });
} else {
const audioModel = audioSpeechModelList.find((item) =>
const audioModel = ttsModelList.find((item) =>
item.voices?.find((voice) => voice.value === e)
);
if (!audioModel) {
@@ -77,7 +77,7 @@ const TTSSelect = ({
});
}
},
[audioSpeechModelList, onChange, value]
[ttsModelList, onChange, value]
);
const onCloseTTSModal = useCallback(() => {

View File

@@ -107,7 +107,7 @@ const ChatInput = ({
);
/* whisper init */
const { whisperModel } = useSystemStore();
const { sttModelList } = useSystemStore();
const canvasRef = useRef<HTMLCanvasElement>(null);
const {
isSpeaking,
@@ -293,7 +293,7 @@ const ChatInput = ({
/>
<Flex alignItems={'center'} position={'absolute'} right={[2, 4]} bottom={['10px', '12px']}>
{/* voice-input */}
{whisperConfig.open && !inputValue && !isChatting && !!whisperModel && (
{whisperConfig.open && !inputValue && !isChatting && sttModelList.length > 0 && (
<>
<canvas
ref={canvasRef}
@@ -431,7 +431,7 @@ const ChatInput = ({
stopSpeak,
t,
whisperConfig.open,
whisperModel
sttModelList
]
);