Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix Go: list providers order issue. (#16616)

Jin Hai83d09b16ceef
diff --git a/conf/models/aliyun.json b/conf/models/aliyun.json
index 51adef5d74..66a569bfa7 100644
--- a/conf/models/aliyun.json
+++ b/conf/models/aliyun.json
@@ -1,5 +1,6 @@
{
"name": "Aliyun",
+ "rank": 983,
"url": {
"default": "https://dashscope.aliyuncs.com",
"singapore": "https://dashscope-intl.aliyuncs.com",
diff --git a/conf/models/anthropic.json b/conf/models/anthropic.json
index d94ac4d882..f35585fb54 100644
--- a/conf/models/anthropic.json
+++ b/conf/models/anthropic.json
@@ -1,5 +1,6 @@
{
"name": "Anthropic",
+ "rank": 998,
"url": {
"default": "https://api.anthropic.com"
},
diff --git a/conf/models/cohere.json b/conf/models/cohere.json
index 1bc484ebfb..98a2c1d576 100644
--- a/conf/models/cohere.json
+++ b/conf/models/cohere.json
@@ -1,5 +1,6 @@
{
"name": "CoHere",
+ "rank": 990,
"url": {
"default": "https://api.cohere.com"
},
diff --git a/conf/models/deepseek.json b/conf/models/deepseek.json
index 146e11862a..6870b478b6 100644
--- a/conf/models/deepseek.json
+++ b/conf/models/deepseek.json
@@ -1,5 +1,6 @@
{
"name": "DeepSeek",
+ "rank": 996,
"url": {
"default": "https://api.deepseek.com"
},
diff --git a/conf/models/google.json b/conf/models/google.json
index a1d5f129f0..96bbb22c4f 100644
--- a/conf/models/google.json
+++ b/conf/models/google.json
@@ -1,5 +1,6 @@
{
"name": "Google",
+ "rank": 997,
"url": {
"default": "https://generativelanguage.googleapis.com"
},
diff --git a/conf/models/huggingface.json b/conf/models/huggingface.json
index f1a7d942fb..fd7d0b774b 100644
--- a/conf/models/huggingface.json
+++ b/conf/models/huggingface.json
@@ -1,5 +1,6 @@
{
"name": "HuggingFace",
+ "rank": 991,
"url": {
"default": "https://router.huggingface.co/v1"
},
diff --git a/conf/models/minimax.json b/conf/models/minimax.json
index f0ae1ae1ce..c2b06e37be 100644
--- a/conf/models/minimax.json
+++ b/conf/models/minimax.json
@@ -1,5 +1,6 @@
{
"name": "MiniMax",
+ "rank": 987,
"url": {
"default": "https://api.minimaxi.com/",
"global": "https://api.minimax.io/"
diff --git a/conf/models/moonshot.json b/conf/models/moonshot.json
index b9df95e0c2..be2359dd48 100644
--- a/conf/models/moonshot.json
+++ b/conf/models/moonshot.json
@@ -1,5 +1,6 @@
{
"name": "Moonshot",
+ "rank": 994,
"url": {
"default": "https://api.moonshot.cn/v1"
},
diff --git a/conf/models/ollama.json b/conf/models/ollama.json
index ea0757e189..3a470d2a45 100644
--- a/conf/models/ollama.json
+++ b/conf/models/ollama.json
@@ -1,5 +1,6 @@
{
"name": "ollama",
+ "rank": 978,
"url_suffix": {
"chat": "api/chat",
"models": "api/tags",
diff --git a/conf/models/openai.json b/conf/models/openai.json
index b4711ab59c..9e9f5c3510 100644
--- a/conf/models/openai.json
+++ b/conf/models/openai.json
@@ -1,5 +1,6 @@
{
"name": "OpenAI",
+ "rank": 999,
"url": {
"default": "https://api.openai.com/v1"
},
diff --git a/conf/models/openrouter.json b/conf/models/openrouter.json
index 3fb81d332b..1833a0921e 100644
--- a/conf/models/openrouter.json
+++ b/conf/models/openrouter.json
@@ -1,5 +1,6 @@
{
"name": "OpenRouter",
+ "rank": 989,
"url": {
"default": "https://openrouter.ai/api/v1"
},
diff --git a/conf/models/replicate.json b/conf/models/replicate.json
index 84cf3f2173..23553526d5 100644
--- a/conf/models/replicate.json
+++ b/conf/models/replicate.json
@@ -1,5 +1,6 @@
{
"name": "Replicate",
+ "rank": 981,
"url": {
"default": "https://api.replicate.com"
},
diff --git a/conf/models/siliconflow.json b/conf/models/siliconflow.json
index ec8f9079ec..d7b8e18f3d 100644
--- a/conf/models/siliconflow.json
+++ b/conf/models/siliconflow.json
@@ -1,5 +1,6 @@
{
"name": "SiliconFlow",
+ "rank": 980,
"url": {
"default": "https://api.siliconflow.cn/v1"
},
diff --git a/conf/models/vllm.json b/conf/models/vllm.json
index d4f074330b..2a8d8157f0 100644
--- a/conf/models/vllm.json
+++ b/conf/models/vllm.json
@@ -1,5 +1,6 @@
{
"name": "vllm",
+ "rank": 975,
"url_suffix": {
"chat": "chat/completions",
"models": "models",
diff --git a/conf/models/volcengine.json b/conf/models/volcengine.json
index 76506ad134..ab2c72e40d 100644
--- a/conf/models/volcengine.json
+++ b/conf/models/volcengine.json
@@ -1,5 +1,6 @@
{
"name": "VolcEngine",
+ "rank": 986,
"url": {
"default": "https://ark.cn-beijing.volces.com/api/v3"
},
diff --git a/conf/models/xai.json b/conf/models/xai.json
index e272b0985d..f350cb5878 100644
--- a/conf/models/xai.json
+++ b/conf/models/xai.json
@@ -1,5 +1,6 @@
{
"name": "xAI",
+ "rank": 992,
"url": {
"default": "https://api.x.ai/v1"
},
diff --git a/conf/models/zhipu-ai.json b/conf/models/zhipu-ai.json
index 872e555047..e51819d243 100644
--- a/conf/models/zhipu-ai.json
+++ b/conf/models/zhipu-ai.json
@@ -1,5 +1,6 @@
{
"name": "ZHIPU-AI",
+ "rank": 993,
"url": {
"default": "https://open.bigmodel.cn/api/paas/v4"
},
diff --git a/internal/entity/models/model.go b/internal/entity/models/model.go
index 390a92e429..96dcef6423 100644
--- a/internal/entity/models/model.go
+++ b/internal/entity/models/model.go
@@ -22,6 +22,7 @@ import (
"fmt"
"os"
"path/filepath"
+ "sort"
"strings"
)
@@ -174,6 +175,7 @@ type Model struct {
// Provider represents an LLM provider
type Provider struct {
Name string `json:"name"`
+ Rank int `json:"rank"`
URL map[string]string `json:"url"`
URLSuffix URLSuffix `json:"url_suffix"`
Models []*Model `json:"models"`
@@ -372,6 +374,7 @@ func (pm *ProviderManager) ListProviders() ([]map[string]interface{}, error) {
providerData := map[string]interface{}{
"name": provider.Name,
+ "rank": provider.Rank,
"url": provider.URL,
"model_types": modelTypes,
"url_suffix": provider.URLSuffix,
@@ -379,6 +382,11 @@ func (pm *ProviderManager) ListProviders() ([]map[string]interface{}, error) {
providers = append(providers, providerData)
}
+ // Sort providers by rank
+ sort.Slice(providers, func(i, j int) bool {
+ return providers[i]["rank"].(int) > providers[j]["rank"].(int)
+ })
+
if len(providers) == 0 {
return nil, fmt.Errorf("no providers found")
}