mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-04 01:29:35 +08:00
Fix Go: list providers order issue. (#16616)
### Summary As title. --------- Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "Aliyun",
|
||||
"rank": 983,
|
||||
"url": {
|
||||
"default": "https://dashscope.aliyuncs.com",
|
||||
"singapore": "https://dashscope-intl.aliyuncs.com",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "Anthropic",
|
||||
"rank": 998,
|
||||
"url": {
|
||||
"default": "https://api.anthropic.com"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "CoHere",
|
||||
"rank": 990,
|
||||
"url": {
|
||||
"default": "https://api.cohere.com"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "DeepSeek",
|
||||
"rank": 996,
|
||||
"url": {
|
||||
"default": "https://api.deepseek.com"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "Google",
|
||||
"rank": 997,
|
||||
"url": {
|
||||
"default": "https://generativelanguage.googleapis.com"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "HuggingFace",
|
||||
"rank": 991,
|
||||
"url": {
|
||||
"default": "https://router.huggingface.co/v1"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "MiniMax",
|
||||
"rank": 987,
|
||||
"url": {
|
||||
"default": "https://api.minimaxi.com/",
|
||||
"global": "https://api.minimax.io/"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "Moonshot",
|
||||
"rank": 994,
|
||||
"url": {
|
||||
"default": "https://api.moonshot.cn/v1"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "ollama",
|
||||
"rank": 978,
|
||||
"url_suffix": {
|
||||
"chat": "api/chat",
|
||||
"models": "api/tags",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "OpenAI",
|
||||
"rank": 999,
|
||||
"url": {
|
||||
"default": "https://api.openai.com/v1"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "OpenRouter",
|
||||
"rank": 989,
|
||||
"url": {
|
||||
"default": "https://openrouter.ai/api/v1"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "Replicate",
|
||||
"rank": 981,
|
||||
"url": {
|
||||
"default": "https://api.replicate.com"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "SiliconFlow",
|
||||
"rank": 980,
|
||||
"url": {
|
||||
"default": "https://api.siliconflow.cn/v1"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "vllm",
|
||||
"rank": 975,
|
||||
"url_suffix": {
|
||||
"chat": "chat/completions",
|
||||
"models": "models",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "VolcEngine",
|
||||
"rank": 986,
|
||||
"url": {
|
||||
"default": "https://ark.cn-beijing.volces.com/api/v3"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "xAI",
|
||||
"rank": 992,
|
||||
"url": {
|
||||
"default": "https://api.x.ai/v1"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "ZHIPU-AI",
|
||||
"rank": 993,
|
||||
"url": {
|
||||
"default": "https://open.bigmodel.cn/api/paas/v4"
|
||||
},
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user