2024-01-15 08:46:22 +08:00
|
|
|
#
|
2024-01-19 19:51:57 +08:00
|
|
|
# Copyright 2024 The InfiniFlow Authors. All Rights Reserved.
|
2024-01-15 08:46:22 +08:00
|
|
|
#
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
|
#
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
#
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
|
# limitations under the License.
|
|
|
|
|
#
|
2025-01-26 12:25:02 +08:00
|
|
|
# AFTER UPDATING THIS FILE, PLEASE ENSURE THAT docs/references/supported_models.mdx IS ALSO UPDATED for consistency!
|
|
|
|
|
#
|
2024-12-08 14:21:12 +08:00
|
|
|
|
2025-07-03 19:05:31 +08:00
|
|
|
import importlib
|
|
|
|
|
import inspect
|
2025-03-06 10:44:04 +08:00
|
|
|
|
2025-08-12 10:59:20 +08:00
|
|
|
from strenum import StrEnum
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SupportedLiteLLMProvider(StrEnum):
|
|
|
|
|
Tongyi_Qianwen = "Tongyi-Qianwen"
|
|
|
|
|
Dashscope = "Dashscope"
|
|
|
|
|
Bedrock = "Bedrock"
|
|
|
|
|
Moonshot = "Moonshot"
|
|
|
|
|
xAI = "xAI"
|
|
|
|
|
DeepInfra = "DeepInfra"
|
|
|
|
|
Groq = "Groq"
|
|
|
|
|
Cohere = "Cohere"
|
|
|
|
|
Gemini = "Gemini"
|
|
|
|
|
DeepSeek = "DeepSeek"
|
|
|
|
|
Nvidia = "NVIDIA"
|
|
|
|
|
TogetherAI = "TogetherAI"
|
|
|
|
|
Anthropic = "Anthropic"
|
2025-08-25 17:56:31 +08:00
|
|
|
Ollama = "Ollama"
|
2025-11-11 16:58:47 +08:00
|
|
|
LongCat = "LongCat"
|
2025-09-18 17:16:59 +08:00
|
|
|
CometAPI = "CometAPI"
|
|
|
|
|
SILICONFLOW = "SILICONFLOW"
|
|
|
|
|
OpenRouter = "OpenRouter"
|
|
|
|
|
StepFun = "StepFun"
|
|
|
|
|
PPIO = "PPIO"
|
|
|
|
|
PerfXCloud = "PerfXCloud"
|
|
|
|
|
Upstage = "Upstage"
|
|
|
|
|
NovitaAI = "NovitaAI"
|
|
|
|
|
Lingyi_AI = "01.AI"
|
|
|
|
|
GiteeAI = "GiteeAI"
|
|
|
|
|
AI_302 = "302.AI"
|
2025-11-17 19:47:46 +08:00
|
|
|
JiekouAI = "Jiekou.AI"
|
2025-12-01 14:24:06 +08:00
|
|
|
ZHIPU_AI = "ZHIPU-AI"
|
2025-12-02 14:43:44 +08:00
|
|
|
MiniMax = "MiniMax"
|
2025-12-08 09:43:03 +08:00
|
|
|
DeerAPI = "DeerAPI"
|
|
|
|
|
GPUStack = "GPUStack"
|
2025-12-12 17:35:08 +08:00
|
|
|
OpenAI = "OpenAI"
|
2025-12-13 11:32:46 +08:00
|
|
|
Azure_OpenAI = "Azure-OpenAI"
|
2026-01-19 13:12:42 +08:00
|
|
|
n1n = "n1n"
|
2026-01-27 17:04:53 +08:00
|
|
|
HunYuan = "Tencent Hunyuan"
|
feat: Add Avian as an LLM provider (#13256)
### What problem does this PR solve?
This PR adds [Avian](https://avian.io) as a new LLM provider to RAGFlow.
Avian provides an OpenAI-compatible API with competitive pricing,
offering access to models like DeepSeek V3.2, Kimi K2.5, GLM-5, and
MiniMax M2.5.
**Provider details:**
- API Base URL: `https://api.avian.io/v1`
- Auth: Bearer token via API key
- OpenAI-compatible (chat completions, streaming, function calling)
- Models:
- `deepseek/deepseek-v3.2` — 164K context, $0.26/$0.38 per 1M tokens
- `moonshotai/kimi-k2.5` — 131K context, $0.45/$2.20 per 1M tokens
- `z-ai/glm-5` — 131K context, $0.30/$2.55 per 1M tokens
- `minimax/minimax-m2.5` — 1M context, $0.30/$1.10 per 1M tokens
**Changes:**
- `rag/llm/chat_model.py` — Add `AvianChat` class extending `Base`
- `rag/llm/__init__.py` — Register in `SupportedLiteLLMProvider`,
`FACTORY_DEFAULT_BASE_URL`, `LITELLM_PROVIDER_PREFIX`
- `conf/llm_factories.json` — Add Avian factory with model definitions
- `web/src/constants/llm.ts` — Add to `LLMFactory` enum, `IconMap`,
`APIMapUrl`
- `web/src/components/svg-icon.tsx` — Register SVG icon
- `web/src/assets/svg/llm/avian.svg` — Provider icon
- `docs/references/supported_models.mdx` — Add to supported models table
This follows the same pattern as other OpenAI-compatible providers
(e.g., n1n #12680, TokenPony).
cc @KevinHuSh @JinHai-CN
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Documentation Update
2026-02-27 09:36:55 +00:00
|
|
|
Avian = "Avian"
|
2025-08-12 10:59:20 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
FACTORY_DEFAULT_BASE_URL = {
|
|
|
|
|
SupportedLiteLLMProvider.Tongyi_Qianwen: "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
|
|
|
SupportedLiteLLMProvider.Dashscope: "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
|
|
|
SupportedLiteLLMProvider.Moonshot: "https://api.moonshot.cn/v1",
|
2025-08-29 13:35:41 +08:00
|
|
|
SupportedLiteLLMProvider.Ollama: "",
|
2025-11-11 16:58:47 +08:00
|
|
|
SupportedLiteLLMProvider.LongCat: "https://api.longcat.chat/openai",
|
2025-09-18 17:16:59 +08:00
|
|
|
SupportedLiteLLMProvider.CometAPI: "https://api.cometapi.com/v1",
|
|
|
|
|
SupportedLiteLLMProvider.SILICONFLOW: "https://api.siliconflow.cn/v1",
|
|
|
|
|
SupportedLiteLLMProvider.OpenRouter: "https://openrouter.ai/api/v1",
|
|
|
|
|
SupportedLiteLLMProvider.StepFun: "https://api.stepfun.com/v1",
|
|
|
|
|
SupportedLiteLLMProvider.PPIO: "https://api.ppinfra.com/v3/openai",
|
|
|
|
|
SupportedLiteLLMProvider.PerfXCloud: "https://cloud.perfxlab.cn/v1",
|
|
|
|
|
SupportedLiteLLMProvider.Upstage: "https://api.upstage.ai/v1/solar",
|
|
|
|
|
SupportedLiteLLMProvider.NovitaAI: "https://api.novita.ai/v3/openai",
|
|
|
|
|
SupportedLiteLLMProvider.Lingyi_AI: "https://api.lingyiwanwu.com/v1",
|
|
|
|
|
SupportedLiteLLMProvider.GiteeAI: "https://ai.gitee.com/v1/",
|
|
|
|
|
SupportedLiteLLMProvider.AI_302: "https://api.302.ai/v1",
|
2025-09-19 19:06:14 +08:00
|
|
|
SupportedLiteLLMProvider.Anthropic: "https://api.anthropic.com/",
|
2025-11-17 19:47:46 +08:00
|
|
|
SupportedLiteLLMProvider.JiekouAI: "https://api.jiekou.ai/openai",
|
2025-12-01 14:24:06 +08:00
|
|
|
SupportedLiteLLMProvider.ZHIPU_AI: "https://open.bigmodel.cn/api/paas/v4",
|
2026-03-12 20:41:46 +08:00
|
|
|
SupportedLiteLLMProvider.MiniMax: "https://api.minimax.io/v1",
|
2025-12-08 09:43:03 +08:00
|
|
|
SupportedLiteLLMProvider.DeerAPI: "https://api.deerapi.com/v1",
|
2025-12-12 17:35:08 +08:00
|
|
|
SupportedLiteLLMProvider.OpenAI: "https://api.openai.com/v1",
|
2026-01-19 13:12:42 +08:00
|
|
|
SupportedLiteLLMProvider.n1n: "https://api.n1n.ai/v1",
|
2026-01-27 17:04:53 +08:00
|
|
|
SupportedLiteLLMProvider.HunYuan: "https://api.hunyuan.cloud.tencent.com/v1",
|
feat: Add Avian as an LLM provider (#13256)
### What problem does this PR solve?
This PR adds [Avian](https://avian.io) as a new LLM provider to RAGFlow.
Avian provides an OpenAI-compatible API with competitive pricing,
offering access to models like DeepSeek V3.2, Kimi K2.5, GLM-5, and
MiniMax M2.5.
**Provider details:**
- API Base URL: `https://api.avian.io/v1`
- Auth: Bearer token via API key
- OpenAI-compatible (chat completions, streaming, function calling)
- Models:
- `deepseek/deepseek-v3.2` — 164K context, $0.26/$0.38 per 1M tokens
- `moonshotai/kimi-k2.5` — 131K context, $0.45/$2.20 per 1M tokens
- `z-ai/glm-5` — 131K context, $0.30/$2.55 per 1M tokens
- `minimax/minimax-m2.5` — 1M context, $0.30/$1.10 per 1M tokens
**Changes:**
- `rag/llm/chat_model.py` — Add `AvianChat` class extending `Base`
- `rag/llm/__init__.py` — Register in `SupportedLiteLLMProvider`,
`FACTORY_DEFAULT_BASE_URL`, `LITELLM_PROVIDER_PREFIX`
- `conf/llm_factories.json` — Add Avian factory with model definitions
- `web/src/constants/llm.ts` — Add to `LLMFactory` enum, `IconMap`,
`APIMapUrl`
- `web/src/components/svg-icon.tsx` — Register SVG icon
- `web/src/assets/svg/llm/avian.svg` — Provider icon
- `docs/references/supported_models.mdx` — Add to supported models table
This follows the same pattern as other OpenAI-compatible providers
(e.g., n1n #12680, TokenPony).
cc @KevinHuSh @JinHai-CN
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Documentation Update
2026-02-27 09:36:55 +00:00
|
|
|
SupportedLiteLLMProvider.Avian: "https://api.avian.io/v1",
|
2025-08-12 10:59:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LITELLM_PROVIDER_PREFIX = {
|
|
|
|
|
SupportedLiteLLMProvider.Tongyi_Qianwen: "dashscope/",
|
|
|
|
|
SupportedLiteLLMProvider.Dashscope: "dashscope/",
|
|
|
|
|
SupportedLiteLLMProvider.Bedrock: "bedrock/",
|
|
|
|
|
SupportedLiteLLMProvider.Moonshot: "moonshot/",
|
|
|
|
|
SupportedLiteLLMProvider.xAI: "xai/",
|
|
|
|
|
SupportedLiteLLMProvider.DeepInfra: "deepinfra/",
|
|
|
|
|
SupportedLiteLLMProvider.Groq: "groq/",
|
|
|
|
|
SupportedLiteLLMProvider.Cohere: "", # don't need a prefix
|
|
|
|
|
SupportedLiteLLMProvider.Gemini: "gemini/",
|
|
|
|
|
SupportedLiteLLMProvider.DeepSeek: "deepseek/",
|
|
|
|
|
SupportedLiteLLMProvider.Nvidia: "nvidia_nim/",
|
|
|
|
|
SupportedLiteLLMProvider.TogetherAI: "together_ai/",
|
|
|
|
|
SupportedLiteLLMProvider.Anthropic: "", # don't need a prefix
|
2025-08-25 17:56:31 +08:00
|
|
|
SupportedLiteLLMProvider.Ollama: "ollama_chat/",
|
2025-11-11 16:58:47 +08:00
|
|
|
SupportedLiteLLMProvider.LongCat: "openai/",
|
2025-09-18 17:16:59 +08:00
|
|
|
SupportedLiteLLMProvider.CometAPI: "openai/",
|
|
|
|
|
SupportedLiteLLMProvider.SILICONFLOW: "openai/",
|
|
|
|
|
SupportedLiteLLMProvider.OpenRouter: "openai/",
|
|
|
|
|
SupportedLiteLLMProvider.StepFun: "openai/",
|
|
|
|
|
SupportedLiteLLMProvider.PPIO: "openai/",
|
|
|
|
|
SupportedLiteLLMProvider.PerfXCloud: "openai/",
|
|
|
|
|
SupportedLiteLLMProvider.Upstage: "openai/",
|
|
|
|
|
SupportedLiteLLMProvider.NovitaAI: "openai/",
|
|
|
|
|
SupportedLiteLLMProvider.Lingyi_AI: "openai/",
|
|
|
|
|
SupportedLiteLLMProvider.GiteeAI: "openai/",
|
|
|
|
|
SupportedLiteLLMProvider.AI_302: "openai/",
|
2025-11-17 19:47:46 +08:00
|
|
|
SupportedLiteLLMProvider.JiekouAI: "openai/",
|
2025-12-01 14:24:06 +08:00
|
|
|
SupportedLiteLLMProvider.ZHIPU_AI: "openai/",
|
2025-12-02 14:43:44 +08:00
|
|
|
SupportedLiteLLMProvider.MiniMax: "openai/",
|
2025-12-08 09:43:03 +08:00
|
|
|
SupportedLiteLLMProvider.DeerAPI: "openai/",
|
|
|
|
|
SupportedLiteLLMProvider.GPUStack: "openai/",
|
2025-12-12 17:35:08 +08:00
|
|
|
SupportedLiteLLMProvider.OpenAI: "openai/",
|
2025-12-13 11:32:46 +08:00
|
|
|
SupportedLiteLLMProvider.Azure_OpenAI: "azure/",
|
2026-01-19 13:12:42 +08:00
|
|
|
SupportedLiteLLMProvider.n1n: "openai/",
|
2026-01-27 17:04:53 +08:00
|
|
|
SupportedLiteLLMProvider.HunYuan: "openai/",
|
feat: Add Avian as an LLM provider (#13256)
### What problem does this PR solve?
This PR adds [Avian](https://avian.io) as a new LLM provider to RAGFlow.
Avian provides an OpenAI-compatible API with competitive pricing,
offering access to models like DeepSeek V3.2, Kimi K2.5, GLM-5, and
MiniMax M2.5.
**Provider details:**
- API Base URL: `https://api.avian.io/v1`
- Auth: Bearer token via API key
- OpenAI-compatible (chat completions, streaming, function calling)
- Models:
- `deepseek/deepseek-v3.2` — 164K context, $0.26/$0.38 per 1M tokens
- `moonshotai/kimi-k2.5` — 131K context, $0.45/$2.20 per 1M tokens
- `z-ai/glm-5` — 131K context, $0.30/$2.55 per 1M tokens
- `minimax/minimax-m2.5` — 1M context, $0.30/$1.10 per 1M tokens
**Changes:**
- `rag/llm/chat_model.py` — Add `AvianChat` class extending `Base`
- `rag/llm/__init__.py` — Register in `SupportedLiteLLMProvider`,
`FACTORY_DEFAULT_BASE_URL`, `LITELLM_PROVIDER_PREFIX`
- `conf/llm_factories.json` — Add Avian factory with model definitions
- `web/src/constants/llm.ts` — Add to `LLMFactory` enum, `IconMap`,
`APIMapUrl`
- `web/src/components/svg-icon.tsx` — Register SVG icon
- `web/src/assets/svg/llm/avian.svg` — Provider icon
- `docs/references/supported_models.mdx` — Add to supported models table
This follows the same pattern as other OpenAI-compatible providers
(e.g., n1n #12680, TokenPony).
cc @KevinHuSh @JinHai-CN
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Documentation Update
2026-02-27 09:36:55 +00:00
|
|
|
SupportedLiteLLMProvider.Avian: "openai/",
|
2025-08-12 10:59:20 +08:00
|
|
|
}
|
|
|
|
|
|
2025-07-03 19:05:31 +08:00
|
|
|
ChatModel = globals().get("ChatModel", {})
|
|
|
|
|
CvModel = globals().get("CvModel", {})
|
|
|
|
|
EmbeddingModel = globals().get("EmbeddingModel", {})
|
|
|
|
|
RerankModel = globals().get("RerankModel", {})
|
|
|
|
|
Seq2txtModel = globals().get("Seq2txtModel", {})
|
|
|
|
|
TTSModel = globals().get("TTSModel", {})
|
2025-12-09 18:54:14 +08:00
|
|
|
OcrModel = globals().get("OcrModel", {})
|
2025-03-06 10:44:04 +08:00
|
|
|
|
2025-08-12 10:59:20 +08:00
|
|
|
|
2025-07-03 19:05:31 +08:00
|
|
|
MODULE_MAPPING = {
|
|
|
|
|
"chat_model": ChatModel,
|
|
|
|
|
"cv_model": CvModel,
|
|
|
|
|
"embedding_model": EmbeddingModel,
|
|
|
|
|
"rerank_model": RerankModel,
|
|
|
|
|
"sequence2txt_model": Seq2txtModel,
|
|
|
|
|
"tts_model": TTSModel,
|
2025-12-09 18:54:14 +08:00
|
|
|
"ocr_model": OcrModel,
|
2024-01-15 08:46:22 +08:00
|
|
|
}
|
|
|
|
|
|
2025-07-03 19:05:31 +08:00
|
|
|
package_name = __name__
|
2024-01-15 08:46:22 +08:00
|
|
|
|
2025-07-03 19:05:31 +08:00
|
|
|
for module_name, mapping_dict in MODULE_MAPPING.items():
|
|
|
|
|
full_module_name = f"{package_name}.{module_name}"
|
|
|
|
|
module = importlib.import_module(full_module_name)
|
2024-01-18 19:28:37 +08:00
|
|
|
|
2025-07-03 19:05:31 +08:00
|
|
|
base_class = None
|
2025-08-12 10:59:20 +08:00
|
|
|
lite_llm_base_class = None
|
2025-07-03 19:05:31 +08:00
|
|
|
for name, obj in inspect.getmembers(module):
|
2025-08-12 10:59:20 +08:00
|
|
|
if inspect.isclass(obj):
|
|
|
|
|
if name == "Base":
|
|
|
|
|
base_class = obj
|
|
|
|
|
elif name == "LiteLLMBase":
|
|
|
|
|
lite_llm_base_class = obj
|
|
|
|
|
assert hasattr(obj, "_FACTORY_NAME"), "LiteLLMbase should have _FACTORY_NAME field."
|
|
|
|
|
if hasattr(obj, "_FACTORY_NAME"):
|
|
|
|
|
if isinstance(obj._FACTORY_NAME, list):
|
|
|
|
|
for factory_name in obj._FACTORY_NAME:
|
|
|
|
|
mapping_dict[factory_name] = obj
|
|
|
|
|
else:
|
|
|
|
|
mapping_dict[obj._FACTORY_NAME] = obj
|
|
|
|
|
|
|
|
|
|
if base_class is not None:
|
|
|
|
|
for _, obj in inspect.getmembers(module):
|
|
|
|
|
if inspect.isclass(obj) and issubclass(obj, base_class) and obj is not base_class and hasattr(obj, "_FACTORY_NAME"):
|
|
|
|
|
if isinstance(obj._FACTORY_NAME, list):
|
|
|
|
|
for factory_name in obj._FACTORY_NAME:
|
|
|
|
|
mapping_dict[factory_name] = obj
|
|
|
|
|
else:
|
|
|
|
|
mapping_dict[obj._FACTORY_NAME] = obj
|
|
|
|
|
|
2024-08-26 15:19:43 +08:00
|
|
|
|
2025-07-03 19:05:31 +08:00
|
|
|
__all__ = [
|
|
|
|
|
"ChatModel",
|
|
|
|
|
"CvModel",
|
|
|
|
|
"EmbeddingModel",
|
|
|
|
|
"RerankModel",
|
|
|
|
|
"Seq2txtModel",
|
|
|
|
|
"TTSModel",
|
2025-12-09 18:54:14 +08:00
|
|
|
"OcrModel",
|
2025-07-03 19:05:31 +08:00
|
|
|
]
|