From 36d8b96b61aeb7baaed47a61713965800060f14b Mon Sep 17 00:00:00 2001 From: Liujian <824010343@qq.com> Date: Fri, 3 Jan 2025 09:33:12 +0800 Subject: [PATCH] update ai api list --- module/ai-api/dto/output.go | 13 ------------- module/ai-key/iml.go | 1 + module/ai/dto/output.go | 1 + module/ai/iml.go | 18 ++++++++++++------ 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/module/ai-api/dto/output.go b/module/ai-api/dto/output.go index 83186d7c..a00c6690 100644 --- a/module/ai-api/dto/output.go +++ b/module/ai-api/dto/output.go @@ -30,19 +30,6 @@ type APIItem struct { Model ModelItem `json:"model"` } -type AIAPIItem struct { - Id string `json:"id"` - Name string `json:"name"` - Service auto.Label `json:"service" aolabel:"service"` - Method string `json:"method"` - RequestPath string `json:"request_path"` - Model ModelItem `json:"model"` - Provider ProviderItem `json:"provider"` - UpdateTime auto.TimeLabel `json:"update_time"` - UseToken int64 `json:"use_token"` - Disable bool `json:"disabled"` -} - type ModelItem struct { Id string `json:"id"` Logo string `json:"logo"` diff --git a/module/ai-key/iml.go b/module/ai-key/iml.go index fb6efe13..caa1c964 100644 --- a/module/ai-key/iml.go +++ b/module/ai-key/iml.go @@ -41,6 +41,7 @@ func (i *imlKeyModule) Create(ctx context.Context, providerId string, input *ai_ if !has { return fmt.Errorf("provider not found: %w", err) } + p.URI() err = p.Check(input.Config) if err != nil { return fmt.Errorf("config check failed: %w", err) diff --git a/module/ai/dto/output.go b/module/ai/dto/output.go index d41687a5..7ea2681e 100644 --- a/module/ai/dto/output.go +++ b/module/ai/dto/output.go @@ -78,6 +78,7 @@ type APIItem struct { Id string `json:"id"` Name string `json:"name"` Service auto.Label `json:"service" aolabel:"service"` + Team auto.Label `json:"team" aolabel:"team"` Method string `json:"method"` RequestPath string `json:"request_path"` Model auto.Label `json:"model"` diff --git a/module/ai/iml.go b/module/ai/iml.go index b68ed21a..9789c18d 100644 --- a/module/ai/iml.go +++ b/module/ai/iml.go @@ -734,12 +734,17 @@ func (i *imlAIApiModule) APIs(ctx context.Context, keyword string, providerId st if err != nil { return nil, nil, 0, err } - serviceItems := utils.SliceToSlice(services, func(e *service.Service) *ai_dto.BasicInfo { - return &ai_dto.BasicInfo{ - Id: e.Id, - Name: e.Name, - } - }) + serviceItems := make([]*ai_dto.BasicInfo, 0, len(services)) + serviceTeamMap := make(map[string]string) + for _, s := range services { + serviceItems = append(serviceItems, &ai_dto.BasicInfo{ + Id: s.Id, + Name: s.Name, + }) + serviceTeamMap[s.Id] = s.Team + + } + modelItems := utils.SliceToSlice(p.Models(), func(e model_runtime.IModel) *ai_dto.BasicInfo { return &ai_dto.BasicInfo{ Id: e.ID(), @@ -786,6 +791,7 @@ func (i *imlAIApiModule) APIs(ctx context.Context, keyword string, providerId st Id: e.API, Name: info.Name, Service: auto.UUID(info.Service), + Team: auto.UUID(serviceTeamMap[info.Service]), Method: http.MethodPost, RequestPath: info.Path, Model: auto.Label{