Feat: Support vLLM #4316 (#5395)

### What problem does this PR solve?
Feat: Support vLLM #4316

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-02-26 18:33:43 +08:00
committed by GitHub
parent fefea3a2a5
commit d9dd1171a3
9 changed files with 235 additions and 115 deletions

View File

@ -6,6 +6,7 @@ import {
ProfileIcon,
TeamIcon,
} from '@/assets/icon/Icon';
import { LLMFactory } from '@/constants/llm';
import { UserSettingRouteKey } from '@/constants/setting';
import { MonitorOutlined } from '@ant-design/icons';
@ -22,17 +23,18 @@ export const UserSettingIconMap = {
export * from '@/constants/setting';
export const LocalLlmFactories = [
'Ollama',
'Xinference',
'LocalAI',
'LM-Studio',
'OpenAI-API-Compatible',
'TogetherAI',
'Replicate',
'OpenRouter',
'HuggingFace',
'GPUStack',
'ModelScope',
LLMFactory.Ollama,
LLMFactory.Xinference,
LLMFactory.LocalAI,
LLMFactory.LMStudio,
LLMFactory.OpenAiAPICompatible,
LLMFactory.TogetherAI,
LLMFactory.Replicate,
LLMFactory.OpenRouter,
LLMFactory.HuggingFace,
LLMFactory.GPUStack,
LLMFactory.ModelScope,
LLMFactory.VLLM,
];
export enum TenantRole {

View File

@ -1,4 +1,5 @@
import { IModalManagerChildrenProps } from '@/components/modal-manager';
import { LLMFactory } from '@/constants/llm';
import { useTranslate } from '@/hooks/common-hooks';
import { Form, Input, Modal } from 'antd';
import { useEffect } from 'react';
@ -18,7 +19,7 @@ type FieldType = {
group_id?: string;
};
const modelsWithBaseUrl = ['OpenAI', 'Azure-OpenAI'];
const modelsWithBaseUrl = [LLMFactory.OpenAI, LLMFactory.AzureOpenAI];
const ApiKeyModal = ({
visible,

View File

@ -1,6 +1,7 @@
import { ReactComponent as MoreModelIcon } from '@/assets/svg/more-model.svg';
import { LlmIcon } from '@/components/svg-icon';
import { useTheme } from '@/components/theme-provider';
import { LLMFactory } from '@/constants/llm';
import { useSetModalState, useTranslate } from '@/hooks/common-hooks';
import { LlmItem, useSelectLlmList } from '@/hooks/llm-hooks';
import { CloseCircleOutlined, SettingOutlined } from '@ant-design/icons';
@ -94,14 +95,14 @@ const ModelCard = ({ item, clickApiKey }: IModelCardProps) => {
<Button onClick={handleApiKeyClick}>
<Flex align="center" gap={4}>
{isLocalLlmFactory(item.name) ||
item.name === 'VolcEngine' ||
item.name === 'Tencent Hunyuan' ||
item.name === 'XunFei Spark' ||
item.name === 'BaiduYiyan' ||
item.name === 'Fish Audio' ||
item.name === 'Tencent Cloud' ||
item.name === 'Google Cloud' ||
item.name === 'Azure OpenAI'
item.name === LLMFactory.VolcEngine ||
item.name === LLMFactory.TencentHunYuan ||
item.name === LLMFactory.XunFeiSpark ||
item.name === LLMFactory.BaiduYiYan ||
item.name === LLMFactory.FishAudio ||
item.name === LLMFactory.TencentCloud ||
item.name === LLMFactory.GoogleCloud ||
item.name === LLMFactory.AzureOpenAI
? t('addTheModel')
: 'API-Key'}
<SettingOutlined />
@ -248,15 +249,15 @@ const UserSettingModel = () => {
const ModalMap = useMemo(
() => ({
Bedrock: showBedrockAddingModal,
VolcEngine: showVolcAddingModal,
'Tencent Hunyuan': showHunyuanAddingModal,
'XunFei Spark': showSparkAddingModal,
BaiduYiyan: showyiyanAddingModal,
'Fish Audio': showFishAudioAddingModal,
'Tencent Cloud': showTencentCloudAddingModal,
'Google Cloud': showGoogleAddingModal,
'Azure-OpenAI': showAzureAddingModal,
[LLMFactory.Bedrock]: showBedrockAddingModal,
[LLMFactory.VolcEngine]: showVolcAddingModal,
[LLMFactory.TencentHunYuan]: showHunyuanAddingModal,
[LLMFactory.XunFeiSpark]: showSparkAddingModal,
[LLMFactory.BaiduYiYan]: showyiyanAddingModal,
[LLMFactory.FishAudio]: showFishAudioAddingModal,
[LLMFactory.TencentCloud]: showTencentCloudAddingModal,
[LLMFactory.GoogleCloud]: showGoogleAddingModal,
[LLMFactory.AzureOpenAI]: showAzureAddingModal,
}),
[
showBedrockAddingModal,
@ -396,63 +397,63 @@ const UserSettingModel = () => {
hideModal={hideVolcAddingModal}
onOk={onVolcAddingOk}
loading={volcAddingLoading}
llmFactory={'VolcEngine'}
llmFactory={LLMFactory.VolcEngine}
></VolcEngineModal>
<HunyuanModal
visible={HunyuanAddingVisible}
hideModal={hideHunyuanAddingModal}
onOk={onHunyuanAddingOk}
loading={HunyuanAddingLoading}
llmFactory={'Tencent Hunyuan'}
llmFactory={LLMFactory.TencentHunYuan}
></HunyuanModal>
<GoogleModal
visible={GoogleAddingVisible}
hideModal={hideGoogleAddingModal}
onOk={onGoogleAddingOk}
loading={GoogleAddingLoading}
llmFactory={'Google Cloud'}
llmFactory={LLMFactory.GoogleCloud}
></GoogleModal>
<TencentCloudModal
visible={TencentCloudAddingVisible}
hideModal={hideTencentCloudAddingModal}
onOk={onTencentCloudAddingOk}
loading={TencentCloudAddingLoading}
llmFactory={'Tencent Cloud'}
llmFactory={LLMFactory.TencentCloud}
></TencentCloudModal>
<SparkModal
visible={SparkAddingVisible}
hideModal={hideSparkAddingModal}
onOk={onSparkAddingOk}
loading={SparkAddingLoading}
llmFactory={'XunFei Spark'}
llmFactory={LLMFactory.XunFeiSpark}
></SparkModal>
<YiyanModal
visible={yiyanAddingVisible}
hideModal={hideyiyanAddingModal}
onOk={onyiyanAddingOk}
loading={yiyanAddingLoading}
llmFactory={'BaiduYiyan'}
llmFactory={LLMFactory.BaiduYiYan}
></YiyanModal>
<FishAudioModal
visible={FishAudioAddingVisible}
hideModal={hideFishAudioAddingModal}
onOk={onFishAudioAddingOk}
loading={FishAudioAddingLoading}
llmFactory={'Fish Audio'}
llmFactory={LLMFactory.FishAudio}
></FishAudioModal>
<BedrockModal
visible={bedrockAddingVisible}
hideModal={hideBedrockAddingModal}
onOk={onBedrockAddingOk}
loading={bedrockAddingLoading}
llmFactory={'Bedrock'}
llmFactory={LLMFactory.Bedrock}
></BedrockModal>
<AzureOpenAIModal
visible={AzureAddingVisible}
hideModal={hideAzureAddingModal}
onOk={onAzureAddingOk}
loading={AzureAddingLoading}
llmFactory={'Azure-OpenAI'}
llmFactory={LLMFactory.AzureOpenAI}
></AzureOpenAIModal>
</section>
);

View File

@ -1,3 +1,4 @@
import { LLMFactory } from '@/constants/llm';
import { useTranslate } from '@/hooks/common-hooks';
import { IModalProps } from '@/interfaces/common';
import { IAddLlmRequestBody } from '@/interfaces/request/llm';
@ -18,19 +19,23 @@ type FieldType = IAddLlmRequestBody & { vision: boolean };
const { Option } = Select;
const llmFactoryToUrlMap = {
Ollama:
[LLMFactory.Ollama]:
'https://github.com/infiniflow/ragflow/blob/main/docs/guides/deploy_local_llm.mdx',
Xinference: 'https://inference.readthedocs.io/en/latest/user_guide',
ModelScope: 'https://www.modelscope.cn/docs/model-service/API-Inference/intro',
LocalAI: 'https://localai.io/docs/getting-started/models/',
'LM-Studio': 'https://lmstudio.ai/docs/basics',
'OpenAI-API-Compatible': 'https://platform.openai.com/docs/models/gpt-4',
TogetherAI: 'https://docs.together.ai/docs/deployment-options',
Replicate: 'https://replicate.com/docs/topics/deployments',
OpenRouter: 'https://openrouter.ai/docs',
HuggingFace:
[LLMFactory.Xinference]:
'https://inference.readthedocs.io/en/latest/user_guide',
[LLMFactory.ModelScope]:
'https://www.modelscope.cn/docs/model-service/API-Inference/intro',
[LLMFactory.LocalAI]: 'https://localai.io/docs/getting-started/models/',
[LLMFactory.LMStudio]: 'https://lmstudio.ai/docs/basics',
[LLMFactory.OpenAiAPICompatible]:
'https://platform.openai.com/docs/models/gpt-4',
[LLMFactory.TogetherAI]: 'https://docs.together.ai/docs/deployment-options',
[LLMFactory.Replicate]: 'https://replicate.com/docs/topics/deployments',
[LLMFactory.OpenRouter]: 'https://openrouter.ai/docs',
[LLMFactory.HuggingFace]:
'https://huggingface.co/docs/text-embeddings-inference/quick_tour',
GPUStack: 'https://docs.gpustack.ai/latest/quickstart',
[LLMFactory.GPUStack]: 'https://docs.gpustack.ai/latest/quickstart',
[LLMFactory.VLLM]: 'https://docs.vllm.ai/en/latest/',
};
type LlmFactory = keyof typeof llmFactoryToUrlMap;
@ -66,11 +71,11 @@ const OllamaModal = ({
llmFactoryToUrlMap[llmFactory as LlmFactory] ||
'https://github.com/infiniflow/ragflow/blob/main/docs/guides/deploy_local_llm.mdx';
const optionsMap = {
HuggingFace: [
[LLMFactory.HuggingFace]: [
{ value: 'embedding', label: 'embedding' },
{ value: 'chat', label: 'chat' },
],
Xinference: [
[LLMFactory.Xinference]: [
{ value: 'chat', label: 'chat' },
{ value: 'embedding', label: 'embedding' },
{ value: 'rerank', label: 'rerank' },
@ -78,10 +83,8 @@ const OllamaModal = ({
{ value: 'speech2text', label: 'sequence2text' },
{ value: 'tts', label: 'tts' },
],
ModelScope: [
{ value: 'chat', label: 'chat' },
],
GPUStack: [
[LLMFactory.ModelScope]: [{ value: 'chat', label: 'chat' }],
[LLMFactory.GPUStack]: [
{ value: 'chat', label: 'chat' },
{ value: 'embedding', label: 'embedding' },
{ value: 'rerank', label: 'rerank' },