mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-25 09:53:29 +08:00
### Summary This PR adds **aimlapi.com** as a model provider, so a RAGFlow user can enter one API key in the model settings and use AIMLAPI's models across the app. AIMLAPI ([aimlapi.com](https://aimlapi.com)) is an OpenAI-compatible aggregator that serves 700+ models (LLM, embedding, vision, TTS, ASR) from many providers behind a single API. The change mirrors the repo's existing "add provider" pattern (e.g. FuturMix / OpenRouter): provider logic lives in the same files those providers use, and shared / UI files get only registration entries. **Backend** - `conf/llm_factories.json` — the `aimlapi.com` factory entry. - `rag/llm/__init__.py`, `rag/llm/{chat,embedding,cv}_model.py` — LiteLLM adapters (chat, embedding, image2text) with a production base URL, overridable via `AIMLAPI_API_URL`. - `rag/llm/model_meta.py` — an `AIMLAPI` model-meta so the provider lists its full `/v1/models` catalog dynamically (classified by the endpoint `type`), the same way OpenRouter does. - `api/apps/restful_apis/aimlapi_api.py` — an optional "Get API key" flow using AIMLAPI's agent-authorization (OAuth 2.0 Device Authorization Grant, RFC 8628). The device code is kept server-side (Redis); only the issued key reaches the browser. **Frontend (`web/`)** - Provider registration (constant, icon allowlist, brand logo), the model picker (`LIST_MODEL_PROVIDERS` + a `buildLocalConfig` entry), and the "Get API key" button in the provider dialog. Locales added to `en` and `zh`. **Configuration** — production defaults are compiled in; endpoints and the partner id are overridable through `AIMLAPI_*` environment variables, so the same build works across environments. **Testing** — the `web` build passes; chat, embedding and dynamic model listing were smoke-tested against the live API.
286 lines
10 KiB
TypeScript
286 lines
10 KiB
TypeScript
export enum ModelStatus {
|
|
Active = 'active',
|
|
Inactive = 'inactive',
|
|
}
|
|
|
|
export enum LLMFactory {
|
|
TongYiQianWen = 'Tongyi-Qianwen',
|
|
Moonshot = 'Moonshot',
|
|
OpenAI = 'OpenAI',
|
|
ZhipuAI = 'ZHIPU-AI',
|
|
WenXinYiYan = '文心一言',
|
|
Ollama = 'Ollama',
|
|
Xinference = 'Xinference',
|
|
ModelScope = 'ModelScope',
|
|
DeepSeek = 'DeepSeek',
|
|
VolcEngine = 'VolcEngine',
|
|
BaiChuan = 'BaiChuan',
|
|
Jina = 'Jina',
|
|
MiniMax = 'MiniMax',
|
|
Mistral = 'Mistral',
|
|
AzureOpenAI = 'Azure-OpenAI',
|
|
Bedrock = 'Bedrock',
|
|
Gemini = 'Gemini',
|
|
Groq = 'Groq',
|
|
OpenRouter = 'OpenRouter',
|
|
LocalAI = 'LocalAI',
|
|
StepFun = 'StepFun',
|
|
NVIDIA = 'NVIDIA',
|
|
LMStudio = 'LM-Studio',
|
|
OpenAiAPICompatible = 'OpenAI-API-Compatible',
|
|
Cohere = 'Cohere',
|
|
LeptonAI = 'LeptonAI',
|
|
TogetherAI = 'TogetherAI',
|
|
PerfXCloud = 'PerfXCloud',
|
|
Upstage = 'Upstage',
|
|
NovitaAI = 'NovitaAI',
|
|
SILICONFLOW = 'SILICONFLOW',
|
|
PPIO = 'PPIO',
|
|
Replicate = 'Replicate',
|
|
TencentHunYuan = 'Tencent Hunyuan',
|
|
XunFeiSpark = 'XunFei Spark',
|
|
BaiduYiYan = 'BaiduYiyan',
|
|
FishAudio = 'Fish Audio',
|
|
TencentCloud = 'Tencent Cloud',
|
|
Anthropic = 'Anthropic',
|
|
VoyageAI = 'Voyage AI',
|
|
GoogleCloud = 'Google Cloud',
|
|
HuggingFace = 'HuggingFace',
|
|
YouDao = 'Youdao',
|
|
BAAI = 'BAAI',
|
|
NomicAI = 'nomic-ai',
|
|
JinaAI = 'jinaai',
|
|
SentenceTransformers = 'sentence-transformers',
|
|
GPUStack = 'GPUStack',
|
|
VLLM = 'VLLM',
|
|
GiteeAI = 'GiteeAI',
|
|
Ai302 = '302.AI',
|
|
DeepInfra = 'DeepInfra',
|
|
Grok = 'Grok',
|
|
XAI = 'xAI',
|
|
TokenPony = 'TokenPony',
|
|
Meituan = 'Meituan',
|
|
Longcat = 'LongCat',
|
|
CometAPI = 'CometAPI',
|
|
DeerAPI = 'DeerAPI',
|
|
JiekouAI = 'Jiekou.AI',
|
|
Builtin = 'Builtin',
|
|
MinerU = 'MinerU',
|
|
MinerUNet = 'MinerU.Net',
|
|
PaddleOCR = 'PaddleOCR',
|
|
PaddleOCRNet = 'PaddleOCR.Net',
|
|
OpenDataLoader = 'OpenDataLoader',
|
|
SoMark = 'SoMark',
|
|
N1n = 'n1n',
|
|
Avian = 'Avian',
|
|
RAGcon = 'RAGcon',
|
|
Perplexity = 'Perplexity',
|
|
Astraflow = 'Astraflow',
|
|
AstraflowCN = 'Astraflow-CN',
|
|
FastEmbed = 'FastEmbed',
|
|
FuturMix = 'FuturMix',
|
|
SiliconflowIntl = 'siliconflow_intl',
|
|
Xiaomi = 'Xiaomi',
|
|
HuaweiCloud = 'HuaweiCloud',
|
|
OrcaRouter = 'OrcaRouter',
|
|
Qiniu = 'Qiniu',
|
|
TokenHub = 'TokenHub',
|
|
NewAPI = 'New API',
|
|
FunASR = 'FunASR',
|
|
AIMLAPI = 'aimlapi.com',
|
|
}
|
|
|
|
// Please lowercase the file name
|
|
export const IconMap = {
|
|
[LLMFactory.TongYiQianWen]: 'tongyi-qianwen',
|
|
[LLMFactory.Moonshot]: 'moonshot',
|
|
[LLMFactory.OpenAI]: 'openai',
|
|
[LLMFactory.ZhipuAI]: 'zhipu',
|
|
[LLMFactory.WenXinYiYan]: 'wenxin',
|
|
[LLMFactory.Ollama]: 'ollama',
|
|
[LLMFactory.Xinference]: 'xinference',
|
|
[LLMFactory.ModelScope]: 'modelscope',
|
|
[LLMFactory.DeepSeek]: 'deepseek',
|
|
[LLMFactory.VolcEngine]: 'volcengine',
|
|
[LLMFactory.BaiChuan]: 'baichuan',
|
|
[LLMFactory.Jina]: 'jina',
|
|
[LLMFactory.MiniMax]: 'MiniMax',
|
|
[LLMFactory.Mistral]: 'mistral',
|
|
[LLMFactory.AzureOpenAI]: 'azure',
|
|
[LLMFactory.Bedrock]: 'bedrock',
|
|
[LLMFactory.Gemini]: 'gemini',
|
|
[LLMFactory.Groq]: 'groq-next',
|
|
[LLMFactory.OpenRouter]: 'open-router',
|
|
[LLMFactory.LocalAI]: 'local-ai',
|
|
[LLMFactory.StepFun]: 'stepfun',
|
|
[LLMFactory.NVIDIA]: 'nvidia',
|
|
[LLMFactory.LMStudio]: 'lm-studio',
|
|
[LLMFactory.OpenAiAPICompatible]: 'openai-api',
|
|
[LLMFactory.Cohere]: 'cohere',
|
|
[LLMFactory.LeptonAI]: 'lepton',
|
|
[LLMFactory.TogetherAI]: 'together',
|
|
[LLMFactory.PerfXCloud]: 'perfx-cloud',
|
|
[LLMFactory.Upstage]: 'upstage',
|
|
[LLMFactory.NovitaAI]: 'novita-ai',
|
|
[LLMFactory.SILICONFLOW]: 'siliconflow',
|
|
[LLMFactory.PPIO]: 'ppio',
|
|
[LLMFactory.Replicate]: 'replicate',
|
|
[LLMFactory.TencentHunYuan]: 'hunyuan',
|
|
[LLMFactory.XunFeiSpark]: 'spark',
|
|
[LLMFactory.BaiduYiYan]: 'wenxinyiyan',
|
|
[LLMFactory.FishAudio]: 'fish-audio',
|
|
[LLMFactory.TencentCloud]: 'tencent-cloud',
|
|
[LLMFactory.Anthropic]: 'anthropic',
|
|
[LLMFactory.VoyageAI]: 'voyage',
|
|
[LLMFactory.GoogleCloud]: 'google-cloud',
|
|
[LLMFactory.HuggingFace]: 'huggingface',
|
|
[LLMFactory.YouDao]: 'youdao',
|
|
[LLMFactory.BAAI]: 'baai',
|
|
[LLMFactory.NomicAI]: 'nomic-ai',
|
|
[LLMFactory.JinaAI]: 'jina',
|
|
[LLMFactory.SentenceTransformers]: 'sentence-transformers',
|
|
[LLMFactory.GPUStack]: 'gpustack',
|
|
[LLMFactory.VLLM]: 'vllm',
|
|
[LLMFactory.GiteeAI]: 'gitee-ai',
|
|
[LLMFactory.Ai302]: 'ai302',
|
|
[LLMFactory.DeepInfra]: 'deepinfra',
|
|
[LLMFactory.Grok]: 'grok',
|
|
[LLMFactory.XAI]: 'xai',
|
|
[LLMFactory.TokenPony]: 'tokenpony',
|
|
[LLMFactory.Meituan]: 'longcat',
|
|
[LLMFactory.Longcat]: 'longcat',
|
|
[LLMFactory.CometAPI]: 'cometapi',
|
|
[LLMFactory.DeerAPI]: 'deerapi',
|
|
[LLMFactory.JiekouAI]: 'jiekouai',
|
|
[LLMFactory.Builtin]: 'builtin',
|
|
[LLMFactory.MinerU]: 'mineru',
|
|
[LLMFactory.MinerUNet]: 'mineru',
|
|
[LLMFactory.PaddleOCR]: 'paddleocr',
|
|
[LLMFactory.PaddleOCRNet]: 'paddleocr',
|
|
[LLMFactory.N1n]: 'n1n',
|
|
[LLMFactory.Avian]: 'avian',
|
|
[LLMFactory.RAGcon]: 'ragcon',
|
|
[LLMFactory.Perplexity]: 'perplexity',
|
|
[LLMFactory.Astraflow]: 'astraflow',
|
|
[LLMFactory.AstraflowCN]: 'astraflow',
|
|
[LLMFactory.FastEmbed]: 'fastembed',
|
|
[LLMFactory.FuturMix]: 'futurmix',
|
|
[LLMFactory.SiliconflowIntl]: 'siliconflow',
|
|
[LLMFactory.Xiaomi]: 'xiaomi',
|
|
[LLMFactory.HuaweiCloud]: 'huaweicloud',
|
|
[LLMFactory.OrcaRouter]: 'orcarouter',
|
|
[LLMFactory.Qiniu]: 'qiniu',
|
|
[LLMFactory.TokenHub]: 'tokenhub',
|
|
[LLMFactory.SoMark]: 'somark',
|
|
[LLMFactory.NewAPI]: 'new-api',
|
|
[LLMFactory.FunASR]: 'funasr',
|
|
[LLMFactory.AIMLAPI]: 'aimlapi',
|
|
};
|
|
|
|
export const ModelTypeToField: Record<string, string> = {
|
|
chat: 'llm_id',
|
|
embedding: 'embd_id',
|
|
vision: 'img2txt_id',
|
|
asr: 'asr_id',
|
|
rerank: 'rerank_id',
|
|
tts: 'tts_id',
|
|
};
|
|
|
|
export const FieldToModelType: Record<string, string> = {
|
|
llm_id: 'chat',
|
|
embd_id: 'embedding',
|
|
img2txt_id: 'vision',
|
|
asr_id: 'asr',
|
|
rerank_id: 'rerank',
|
|
tts_id: 'tts',
|
|
};
|
|
|
|
export const APIMapUrl = {
|
|
[LLMFactory.OpenAI]: 'https://platform.openai.com/api-keys',
|
|
[LLMFactory.AIMLAPI]: 'https://aimlapi.com/app/keys',
|
|
[LLMFactory.Anthropic]: 'https://console.anthropic.com/settings/keys',
|
|
[LLMFactory.Gemini]: 'https://aistudio.google.com/app/apikey',
|
|
[LLMFactory.DeepSeek]: 'https://platform.deepseek.com/api_keys',
|
|
[LLMFactory.Moonshot]: 'https://platform.moonshot.cn/console/api-keys',
|
|
[LLMFactory.TongYiQianWen]: 'https://dashscope.console.aliyun.com/apiKey',
|
|
[LLMFactory.ZhipuAI]: 'https://open.bigmodel.cn/usercenter/apikeys',
|
|
[LLMFactory.XAI]: 'https://x.ai/api/',
|
|
[LLMFactory.HuggingFace]: 'https://huggingface.co/settings/tokens',
|
|
[LLMFactory.Mistral]: 'https://console.mistral.ai/api-keys/',
|
|
[LLMFactory.Cohere]: 'https://dashboard.cohere.com/api-keys',
|
|
[LLMFactory.BaiduYiYan]:
|
|
'https://console.bce.baidu.com/qianfan/ais/console/apiKey',
|
|
[LLMFactory.Meituan]: 'https://longcat.chat/platform/api_keys',
|
|
[LLMFactory.Bedrock]:
|
|
'https://us-east-1.console.aws.amazon.com/iam/home?region=us-east-2#/users',
|
|
[LLMFactory.AzureOpenAI]:
|
|
'https://portal.azure.com/#create/Microsoft.CognitiveServicesOpenAI',
|
|
[LLMFactory.OpenRouter]: 'https://openrouter.ai/keys',
|
|
[LLMFactory.XunFeiSpark]: 'https://console.xfyun.cn/services/cbm',
|
|
[LLMFactory.MiniMax]:
|
|
'https://platform.minimaxi.com/user-center/basic-information',
|
|
[LLMFactory.Groq]: 'https://console.groq.com/keys',
|
|
[LLMFactory.NVIDIA]: 'https://build.nvidia.com/settings/api-keys',
|
|
[LLMFactory.SILICONFLOW]: 'https://cloud.siliconflow.cn/account/ak',
|
|
[LLMFactory.Replicate]: 'https://replicate.com/account/api-tokens',
|
|
[LLMFactory.VolcEngine]: 'https://console.volcengine.com/ark',
|
|
[LLMFactory.Jina]: 'https://jina.ai/embeddings/',
|
|
[LLMFactory.TencentHunYuan]:
|
|
'https://console.cloud.tencent.com/hunyuan/api-key',
|
|
[LLMFactory.TencentCloud]: 'https://console.cloud.tencent.com/cam/capi',
|
|
[LLMFactory.ModelScope]: 'https://modelscope.cn/my/myaccesstoken',
|
|
[LLMFactory.GoogleCloud]: 'https://console.cloud.google.com/apis/credentials',
|
|
[LLMFactory.FishAudio]: 'https://fish.audio/app/api-keys/',
|
|
[LLMFactory.GiteeAI]: 'https://ai.gitee.com/dashboard/settings/tokens',
|
|
[LLMFactory.StepFun]: 'https://platform.stepfun.com/interface-key',
|
|
[LLMFactory.BaiChuan]: 'https://platform.baichuan-ai.com/console/apikey',
|
|
[LLMFactory.PPIO]: 'https://ppio.com/settings/key-management',
|
|
[LLMFactory.VoyageAI]: 'https://dash.voyageai.com/api-keys',
|
|
[LLMFactory.TogetherAI]: 'https://api.together.xyz/settings/api-keys',
|
|
[LLMFactory.NovitaAI]: 'https://novita.ai/dashboard/key',
|
|
[LLMFactory.Upstage]: 'https://console.upstage.ai/api-keys',
|
|
[LLMFactory.CometAPI]: 'https://api.cometapi.com/console/token',
|
|
[LLMFactory.Ai302]: 'https://302.ai/apis/list',
|
|
[LLMFactory.DeerAPI]: 'https://api.deerapi.com/token',
|
|
[LLMFactory.TokenPony]: 'https://www.tokenpony.cn/#/user/keys',
|
|
[LLMFactory.DeepInfra]: 'https://deepinfra.com/dash/api_keys',
|
|
[LLMFactory.PaddleOCR]: 'https://www.paddleocr.ai/latest/',
|
|
[LLMFactory.SoMark]: 'https://somark.cn/workbench/apikey',
|
|
[LLMFactory.N1n]: 'https://docs.n1n.ai',
|
|
[LLMFactory.Avian]: 'https://avian.io',
|
|
[LLMFactory.Perplexity]:
|
|
'https://docs.perplexity.ai/docs/embeddings/quickstart',
|
|
[LLMFactory.Astraflow]: 'https://astraflow.ucloud-global.com/en-us',
|
|
[LLMFactory.AstraflowCN]: 'https://astraflow.ucloud.cn/',
|
|
[LLMFactory.FastEmbed]: 'https://qdrant.github.io/fastembed/',
|
|
[LLMFactory.FuturMix]: 'https://futurmix.ai',
|
|
[LLMFactory.SiliconflowIntl]: 'https://cloud.siliconflow.us/account/ak',
|
|
[LLMFactory.Xiaomi]: 'https://mimo.mi.com/',
|
|
[LLMFactory.HuaweiCloud]: 'https://www.huaweicloud.com',
|
|
[LLMFactory.OrcaRouter]: 'https://orcarouter.ai',
|
|
[LLMFactory.Qiniu]: 'https://www.qiniu.com',
|
|
[LLMFactory.TokenHub]: 'https://aitok.cc',
|
|
[LLMFactory.WenXinYiYan]: 'https://yiyan.baidu.com',
|
|
[LLMFactory.Ollama]: 'https://ollama.com',
|
|
[LLMFactory.Xinference]: 'https://github.com/xorbitsai/inference',
|
|
[LLMFactory.LocalAI]: 'https://localai.io',
|
|
[LLMFactory.LMStudio]: 'https://lmstudio.ai',
|
|
[LLMFactory.LeptonAI]: 'https://lepton.ai',
|
|
[LLMFactory.PerfXCloud]: 'https://www.perfxcloud.cn',
|
|
[LLMFactory.YouDao]: 'https://ai.youdao.com',
|
|
[LLMFactory.BAAI]: 'https://www.baai.ac.cn',
|
|
[LLMFactory.NomicAI]: 'https://nomic.ai',
|
|
[LLMFactory.JinaAI]: 'https://jina.ai/embeddings/',
|
|
[LLMFactory.SentenceTransformers]: 'https://www.sbert.net',
|
|
[LLMFactory.GPUStack]: 'https://gpustack.ai',
|
|
[LLMFactory.VLLM]: 'https://vllm.ai',
|
|
[LLMFactory.Grok]: 'https://x.ai',
|
|
[LLMFactory.Longcat]: 'https://longcat.chat',
|
|
[LLMFactory.JiekouAI]: 'https://jiekou.ai',
|
|
[LLMFactory.MinerU]: 'https://mineru.net',
|
|
[LLMFactory.MinerUNet]: 'https://mineru.net',
|
|
[LLMFactory.PaddleOCRNet]: 'https://www.paddleocr.ai/latest/',
|
|
[LLMFactory.RAGcon]: 'https://connect.ragcon.com',
|
|
[LLMFactory.FunASR]: 'https://github.com/modelscope/FunASR',
|
|
};
|