diff --git a/ai-provider/model-runtime/entity/provider.go b/ai-provider/model-runtime/entity/provider.go
index 195da52a..d9014560 100644
--- a/ai-provider/model-runtime/entity/provider.go
+++ b/ai-provider/model-runtime/entity/provider.go
@@ -21,8 +21,10 @@ type Provider struct {
Help Help `json:"help" yaml:"help"`
SupportedModelTypes []string `json:"supported_model_types" yaml:"supported_model_types"`
ProviderCredentialSchema ProviderCredentialSchema `json:"provider_credential_schema" yaml:"provider_credential_schema"`
- Default map[string]string `json:"default"`
- Address string `json:"address"`
+ Default map[string]string `json:"default" yaml:"default"`
+ Address string `json:"address" yaml:"address"`
+ Recommend bool `json:"recommend" yaml:"recommend"`
+ Sort int `json:"sort" yaml:"sort"`
}
type ProviderCredentialSchema struct {
diff --git a/ai-provider/model-runtime/manager.go b/ai-provider/model-runtime/manager.go
index 382866e4..dbefea3e 100644
--- a/ai-provider/model-runtime/manager.go
+++ b/ai-provider/model-runtime/manager.go
@@ -1,6 +1,8 @@
package model_runtime
-import "github.com/eolinker/eosc"
+import (
+ "github.com/eolinker/eosc"
+)
var (
defaultManager = NewManager()
@@ -27,6 +29,13 @@ func (m *Manager) Del(name string) {
}
func (m *Manager) List() []IProvider {
+ //list := m.providers.List()
+ //sort.Slice(list, func(i, j int) bool {
+ // if list[i].Sort() == list[j].Sort() {
+ // return list[i].ID() < list[j].ID()
+ // }
+ // return list[i].Sort() < list[j].Sort()
+ //})
return m.providers.List()
}
diff --git a/ai-provider/model-runtime/model-providers/authropic/anthropic.yaml b/ai-provider/model-runtime/model-providers/authropic/anthropic.yaml
index 10cad537..f44d3e18 100644
--- a/ai-provider/model-runtime/model-providers/authropic/anthropic.yaml
+++ b/ai-provider/model-runtime/model-providers/authropic/anthropic.yaml
@@ -38,3 +38,5 @@ provider_credential_schema:
zh_Hans: 在此输入您的 API URL
en_US: Enter your API URL
address: https://api.anthropic.com
+recommend: true
+sort: 2
\ No newline at end of file
diff --git a/ai-provider/model-runtime/model-providers/bedrock/bedrock.yaml b/ai-provider/model-runtime/model-providers/bedrock/bedrock.yaml
index bda4cc38..b9f165c2 100644
--- a/ai-provider/model-runtime/model-providers/bedrock/bedrock.yaml
+++ b/ai-provider/model-runtime/model-providers/bedrock/bedrock.yaml
@@ -1,6 +1,6 @@
provider: bedrock
label:
- en_US: AWS
+ en_US: AWS Bedrock
description:
en_US: AWS Bedrock's models.
icon_small:
@@ -87,4 +87,6 @@ provider_credential_schema:
placeholder:
en_US: A model you have access to (e.g. amazon.titan-text-lite-v1) for validation.
zh_Hans: 为了进行验证,请输入一个您可用的模型名称 (例如:amazon.titan-text-lite-v1)
-address: https://bedrock-runtime.amazonaws.com
\ No newline at end of file
+address: https://bedrock-runtime.amazonaws.com
+sort: 4
+recommend: true
\ No newline at end of file
diff --git a/ai-provider/model-runtime/model-providers/google/google.yaml b/ai-provider/model-runtime/model-providers/google/google.yaml
index 1d45610f..e54c899f 100644
--- a/ai-provider/model-runtime/model-providers/google/google.yaml
+++ b/ai-provider/model-runtime/model-providers/google/google.yaml
@@ -1,6 +1,6 @@
provider: google
label:
- en_US: Google
+ en_US: Google Gemini
description:
en_US: Google's Gemini model.
zh_Hans: 谷歌提供的 Gemini 模型.
@@ -38,4 +38,6 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 API Base, 如:https://api.google.com
en_US: Enter your API Base, e.g. https://api.google.com
-address: https://generativelanguage.googleapis.com
\ No newline at end of file
+address: https://generativelanguage.googleapis.com
+recommend: true
+sort: 3
\ No newline at end of file
diff --git a/ai-provider/model-runtime/model-providers/minimax/minimax.yaml b/ai-provider/model-runtime/model-providers/minimax/minimax.yaml
index c4ce3c75..d6d82e8a 100644
--- a/ai-provider/model-runtime/model-providers/minimax/minimax.yaml
+++ b/ai-provider/model-runtime/model-providers/minimax/minimax.yaml
@@ -27,4 +27,6 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
-address: https://api.minimax.chat
\ No newline at end of file
+address: https://api.minimax.chat
+recommend: true
+sort: 5
\ No newline at end of file
diff --git a/ai-provider/model-runtime/model-providers/moonshot/moonshot.yaml b/ai-provider/model-runtime/model-providers/moonshot/moonshot.yaml
index 577bf26c..406213b3 100644
--- a/ai-provider/model-runtime/model-providers/moonshot/moonshot.yaml
+++ b/ai-provider/model-runtime/model-providers/moonshot/moonshot.yaml
@@ -31,4 +31,6 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
-address: https://api.moonshot.cn
\ No newline at end of file
+address: https://api.moonshot.cn
+recommend: true
+sort: 6
\ No newline at end of file
diff --git a/ai-provider/model-runtime/model-providers/nvidia/nvidia.yaml b/ai-provider/model-runtime/model-providers/nvidia/nvidia.yaml
index e2fd93c7..c2038512 100644
--- a/ai-provider/model-runtime/model-providers/nvidia/nvidia.yaml
+++ b/ai-provider/model-runtime/model-providers/nvidia/nvidia.yaml
@@ -1,6 +1,6 @@
provider: nvidia
label:
- en_US: API Catalog
+ en_US: Nvidia
description:
en_US: API Catalog
zh_Hans: API Catalog
diff --git a/ai-provider/model-runtime/model-providers/openAI/openai.yaml b/ai-provider/model-runtime/model-providers/openAI/openai.yaml
index 8b04aaef..475a8700 100644
--- a/ai-provider/model-runtime/model-providers/openAI/openai.yaml
+++ b/ai-provider/model-runtime/model-providers/openAI/openai.yaml
@@ -88,3 +88,5 @@ provider_credential_schema:
zh_Hans: 在此输入您的 API Base, 如:https://api.openai.com
en_US: Enter your API Base, e.g. https://api.openai.com
address: https://api.openai.com
+recommend: true
+sort: 1
\ No newline at end of file
diff --git a/ai-provider/model-runtime/model-providers/wenxin/wenxin.yaml b/ai-provider/model-runtime/model-providers/wenxin/wenxin.yaml
index f4fde100..e429ea11 100644
--- a/ai-provider/model-runtime/model-providers/wenxin/wenxin.yaml
+++ b/ai-provider/model-runtime/model-providers/wenxin/wenxin.yaml
@@ -1,6 +1,6 @@
provider: wenxin
label:
- en_US: WenXin
+ en_US: Wenxin YiYan
zh_Hans: 文心一言
icon_small:
en_US: icon_s_en.svg
@@ -38,4 +38,6 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 Secret Key
en_US: Enter your Secret Key
-address: https://aip.baidubce.com
\ No newline at end of file
+address: https://aip.baidubce.com
+recommend: true
+sort: 7
\ No newline at end of file
diff --git a/ai-provider/model-runtime/model-providers/zhinao/assets/icon_l_en.svg b/ai-provider/model-runtime/model-providers/zhinao/assets/icon_l_en.svg
index b22b8694..651a133f 100644
--- a/ai-provider/model-runtime/model-providers/zhinao/assets/icon_l_en.svg
+++ b/ai-provider/model-runtime/model-providers/zhinao/assets/icon_l_en.svg
@@ -1,8 +1,8 @@
diff --git a/ai-provider/model-runtime/model-providers/zhinao/assets/icon_s_en.svg b/ai-provider/model-runtime/model-providers/zhinao/assets/icon_s_en.svg
index 8fe72b7d..2590f3d9 100644
--- a/ai-provider/model-runtime/model-providers/zhinao/assets/icon_s_en.svg
+++ b/ai-provider/model-runtime/model-providers/zhinao/assets/icon_s_en.svg
@@ -1,8 +1,8 @@
diff --git a/ai-provider/model-runtime/provider.go b/ai-provider/model-runtime/provider.go
index 226719eb..666fc11f 100644
--- a/ai-provider/model-runtime/provider.go
+++ b/ai-provider/model-runtime/provider.go
@@ -22,6 +22,8 @@ type IProvider interface {
ModelsByType(modelType string) ([]IModel, bool)
IConfig
MaskConfig(cfg string) string
+ Sort() int
+ Recommend() bool
}
type IProviderURI interface {
@@ -72,6 +74,8 @@ func NewProvider(providerData string, modelContents map[string]eosc.Untyped[stri
defaultModels: eosc.BuildUntyped[string, IModel](),
modelsByType: eosc.BuildUntyped[string, []IModel](),
maskKeys: make([]string, 0),
+ recommend: providerCfg.Recommend,
+ sort: providerCfg.Sort,
uri: uri,
}
defaultCfg := make(map[string]string)
@@ -126,9 +130,19 @@ type Provider struct {
modelsByType eosc.Untyped[string, []IModel]
maskKeys []string
uri IProviderURI
+ sort int
+ recommend bool
IConfig
}
+func (p *Provider) Sort() int {
+ return p.sort
+}
+
+func (p *Provider) Recommend() bool {
+ return p.recommend
+}
+
func (p *Provider) URI() IProviderURI {
return p.uri
}
diff --git a/module/ai/dto/input.go b/module/ai/dto/input.go
index 894bfd94..8f1b4c48 100644
--- a/module/ai/dto/input.go
+++ b/module/ai/dto/input.go
@@ -5,5 +5,6 @@ type UpdateLLM struct {
}
type UpdateConfig struct {
- Config string `json:"config"`
+ DefaultLLM string `json:"default_llm"`
+ Config string `json:"config"`
}
diff --git a/module/ai/dto/output.go b/module/ai/dto/output.go
index 9c37fcb5..c21f7ceb 100644
--- a/module/ai/dto/output.go
+++ b/module/ai/dto/output.go
@@ -7,7 +7,7 @@ type Provider struct {
Name string `json:"name"`
Config string `json:"config"`
GetAPIKeyUrl string `json:"get_apikey_url"`
- DefaultLLM string `json:"-"`
+ DefaultLLM string `json:"defaultLLM"`
DefaultLLMConfig string `json:"-"`
}
@@ -18,6 +18,8 @@ type ProviderItem struct {
DefaultLLMLogo string `json:"default_llm_logo"`
Logo string `json:"logo"`
Configured bool `json:"configured"`
+ Recommend bool `json:"recommend"`
+ Sort int `json:"sort"`
UpdateTime time.Time `json:"-"`
}
diff --git a/module/ai/iml.go b/module/ai/iml.go
index ba65e8e4..c1547850 100644
--- a/module/ai/iml.go
+++ b/module/ai/iml.go
@@ -90,9 +90,11 @@ func (i *imlProviderModule) Providers(ctx context.Context) ([]*ai_dto.ProviderIt
continue
}
item := &ai_dto.ProviderItem{
- Id: v.ID(),
- Name: v.Name(),
- Logo: v.Logo(),
+ Id: v.ID(),
+ Name: v.Name(),
+ Logo: v.Logo(),
+ Recommend: v.Recommend(),
+ Sort: v.Sort(),
}
if info, has := providerMap[v.ID()]; has {
item.Configured = true
@@ -103,8 +105,19 @@ func (i *imlProviderModule) Providers(ctx context.Context) ([]*ai_dto.ProviderIt
items = append(items, item)
}
sort.Slice(items, func(i, j int) bool {
-
- return items[i].UpdateTime.After(items[j].UpdateTime)
+ if items[i].Configured == items[j].Configured && items[i].Configured {
+ return items[i].Name < items[j].Name
+ }
+ if items[i].Sort != items[j].Sort {
+ if items[i].Sort == 0 {
+ return false
+ }
+ if items[j].Sort == 0 {
+ return true
+ }
+ return items[i].Sort < items[j].Sort
+ }
+ return items[i].Name < items[j].Name
})
return items, nil
}
@@ -262,14 +275,14 @@ func (i *imlProviderModule) UpdateProviderConfig(ctx context.Context, id string,
if !errors.Is(err, gorm.ErrRecordNotFound) {
return err
}
- defaultLLm, ok := p.DefaultModel(model_runtime.ModelTypeLLM)
- if !ok {
- return fmt.Errorf("ai provider default llm not found")
- }
+ //defaultLLm, ok := p.DefaultModel(model_runtime.ModelTypeLLM)
+ //if !ok {
+ // return fmt.Errorf("ai provider default llm not found")
+ //}
info = &ai.Provider{
Id: id,
Name: p.Name(),
- DefaultLLM: defaultLLm.ID(),
+ DefaultLLM: input.DefaultLLM,
Config: input.Config,
}
}
diff --git a/module/service/dto/output.go b/module/service/dto/output.go
index 55a5c1a0..74b3ac36 100644
--- a/module/service/dto/output.go
+++ b/module/service/dto/output.go
@@ -24,6 +24,7 @@ type AppItem struct {
Team auto.Label `json:"team" aolabel:"team"`
SubscribeNum int64 `json:"subscribe_num"`
SubscribeVerifyNum int64 `json:"subscribe_verify_num"`
+ AuthNum int64 `json:"auth_num"`
Description string `json:"description"`
CreateTime auto.TimeLabel `json:"create_time"`
UpdateTime auto.TimeLabel `json:"update_time"`
diff --git a/module/service/iml.go b/module/service/iml.go
index 075521f0..9f3325ba 100644
--- a/module/service/iml.go
+++ b/module/service/iml.go
@@ -7,6 +7,8 @@ import (
"sort"
"strings"
+ application_authorization "github.com/APIParkLab/APIPark/service/application-authorization"
+
api_doc "github.com/APIParkLab/APIPark/service/api-doc"
service_tag "github.com/APIParkLab/APIPark/service/service-tag"
@@ -532,11 +534,12 @@ var (
)
type imlAppModule struct {
- teamService team.ITeamService `autowired:""`
- serviceService service.IServiceService `autowired:""`
- teamMemberService team_member.ITeamMemberService `autowired:""`
- subscribeService subscribe.ISubscribeService `autowired:""`
- transaction store.ITransaction `autowired:""`
+ teamService team.ITeamService `autowired:""`
+ serviceService service.IServiceService `autowired:""`
+ teamMemberService team_member.ITeamMemberService `autowired:""`
+ subscribeService subscribe.ISubscribeService `autowired:""`
+ authService application_authorization.IAuthorizationService `autowired:""`
+ transaction store.ITransaction `autowired:""`
}
func (i *imlAppModule) ExportAll(ctx context.Context) ([]*service_dto.ExportApp, error) {
@@ -600,6 +603,10 @@ func (i *imlAppModule) Search(ctx context.Context, teamId string, keyword string
}
}
+ appMap, err := i.authService.CountByApp(ctx, serviceIds...)
+ if err != nil {
+ return nil, err
+ }
items := make([]*service_dto.AppItem, 0, len(services))
for _, model := range services {
subscribeNum := subscribeCount[model.Id]
@@ -614,6 +621,7 @@ func (i *imlAppModule) Search(ctx context.Context, teamId string, keyword string
SubscribeNum: subscribeNum,
SubscribeVerifyNum: verifyNum,
CanDelete: subscribeNum == 0,
+ AuthNum: appMap[model.Id],
})
}
sort.Slice(items, func(i, j int) bool {
diff --git a/service/application-authorization/iml.go b/service/application-authorization/iml.go
index 97feab6f..c8b228b8 100644
--- a/service/application-authorization/iml.go
+++ b/service/application-authorization/iml.go
@@ -3,11 +3,11 @@ package application_authorization
import (
"context"
"time"
-
+
"github.com/eolinker/go-common/utils"
-
+
"github.com/eolinker/go-common/auto"
-
+
"github.com/APIParkLab/APIPark/service/universally"
"github.com/APIParkLab/APIPark/stores/service"
)
@@ -24,6 +24,14 @@ type imlAuthorizationService struct {
universally.IServiceEdit[Edit]
}
+func (i *imlAuthorizationService) CountByApp(ctx context.Context, appId ...string) (map[string]int64, error) {
+ w := map[string]interface{}{}
+ if len(appId) > 0 {
+ w["application"] = appId
+ }
+ return i.store.CountByGroup(ctx, "", w, "application")
+}
+
func (i *imlAuthorizationService) ListByApp(ctx context.Context, appId ...string) ([]*Authorization, error) {
w := map[string]interface{}{}
if len(appId) > 0 {
@@ -51,11 +59,11 @@ func (i *imlAuthorizationService) GetLabels(ctx context.Context, ids ...string)
func (i *imlAuthorizationService) OnComplete() {
i.IServiceGet = universally.NewGet[Authorization, service.Authorization](i.store, FromEntity)
-
+
i.IServiceDelete = universally.NewDelete[service.Authorization](i.store)
-
+
i.IServiceCreate = universally.NewCreator[Create, service.Authorization](i.store, "project_authorization", createEntityHandler, uniquestHandler, labelHandler)
-
+
i.IServiceEdit = universally.NewEdit[Edit, service.Authorization](i.store, updateHandler, labelHandler)
auto.RegisterService("project_authorization", i)
}
diff --git a/service/application-authorization/service.go b/service/application-authorization/service.go
index cb355bb9..fd0f683f 100644
--- a/service/application-authorization/service.go
+++ b/service/application-authorization/service.go
@@ -3,7 +3,7 @@ package application_authorization
import (
"context"
"reflect"
-
+
"github.com/APIParkLab/APIPark/service/universally"
"github.com/eolinker/go-common/autowire"
)
@@ -14,6 +14,7 @@ type IAuthorizationService interface {
universally.IServiceCreate[Create]
universally.IServiceEdit[Edit]
ListByApp(ctx context.Context, appId ...string) ([]*Authorization, error)
+ CountByApp(ctx context.Context, appId ...string) (map[string]int64, error)
}
func init() {