diff --git a/controller/service/iml.go b/controller/service/iml.go index eb1e297e..2f2f54fa 100644 --- a/controller/service/iml.go +++ b/controller/service/iml.go @@ -92,18 +92,6 @@ func (i *imlServiceController) QuickCreateAIService(ctx *gin.Context, input *ser if err != nil { return err } - //pv, err := i.providerModule.Provider(ctx, input.Provider) - //if err != nil { - // return err - //} - //p, has := model_runtime.GetProvider(input.Provider) - //if !has { - // return fmt.Errorf("provider not found") - //} - //m, has := p.GetModel(pv.DefaultLLM) - //if !has { - // return fmt.Errorf("model %s not found", pv.DefaultLLM) - //} id := uuid.NewString() prefix := fmt.Sprintf("/%s", id[:8]) @@ -124,91 +112,6 @@ func (i *imlServiceController) QuickCreateAIService(ctx *gin.Context, input *ser Kind: "ai", }) return err - //info, err = i.module.Create(ctx, input.Team, &service_dto.CreateService{ - // Id: uuid.NewString(), - // Name: input.Provider + " AI Service", - // Prefix: prefix, - // Description: "Quick create by AI provider", - // ServiceType: "public", - // State: "normal", - // Catalogue: catalogueInfo.Id, - // ApprovalType: "auto", - // Provider: &input.Provider, - // Kind: "ai", - //}) - //if err != nil { - // return err - //} - // - //path := fmt.Sprintf("%s/chat", prefix) - //timeout := 300000 - //retry := 0 - //aiPrompt := &ai_api_dto.AiPrompt{ - // Variables: []*ai_api_dto.AiPromptVariable{}, - // Prompt: "", - //} - //aiModel := &ai_api_dto.AiModel{ - // Id: m.ID(), - // Config: m.DefaultConfig(), - // Provider: input.Provider, - //} - //name := "Demo AI API" - //description := "A demo that shows you how to use a e a Chat" - //apiId := uuid.New().String() - //err = i.aiAPIModule.Create( - // ctx, - // info.Id, - // &ai_api_dto.CreateAPI{ - // Id: apiId, - // Name: name, - // Path: path, - // Description: description, - // Disable: false, - // AiPrompt: aiPrompt, - // AiModel: aiModel, - // Timeout: timeout, - // Retry: retry, - // }, - //) - //if err != nil { - // return err - //} - //plugins := make(map[string]api.PluginSetting) - //plugins["ai_prompt"] = api.PluginSetting{ - // Config: plugin_model.ConfigType{ - // "prompt": aiPrompt.Prompt, - // "variables": aiPrompt.Variables, - // }, - //} - //plugins["ai_formatter"] = api.PluginSetting{ - // Config: plugin_model.ConfigType{ - // "model": aiModel.Id, - // "provider": info.Provider.Id, - // "config": aiModel.Config, - // }, - //} - //_, err = i.routerModule.Create(ctx, info.Id, &router_dto.Create{ - // Id: apiId, - // Name: name, - // Path: path, - // Methods: []string{ - // http.MethodPost, - // }, - // Description: description, - // Protocols: []string{"http", "https"}, - // MatchRules: nil, - // Proxy: &router_dto.InputProxy{ - // Path: path, - // Timeout: timeout, - // Retry: retry, - // Plugins: plugins, - // }, - // Disable: false, - //}) - //if err != nil { - // return err - //} - }) } diff --git a/module/ai-balance/iml.go b/module/ai-balance/iml.go index d2ddd4f5..6f37d240 100644 --- a/module/ai-balance/iml.go +++ b/module/ai-balance/iml.go @@ -150,7 +150,7 @@ func (i *imlBalanceModule) List(ctx context.Context, keyword string) ([]*ai_bala sort.Slice(list, func(i, j int) bool { return list[i].Priority < list[j].Priority }) - aiAPIMap, err := i.aiAPIService.CountMapByProvider(ctx, "", nil) + aiAPIMap, err := i.aiAPIService.CountMapByModel(ctx, "", nil) if err != nil { return nil, fmt.Errorf("get ai api count error:%v", err) } diff --git a/module/service/dto/output.go b/module/service/dto/output.go index a4031979..3fadb202 100644 --- a/module/service/dto/output.go +++ b/module/service/dto/output.go @@ -97,6 +97,7 @@ type Service struct { Tags []auto.Label `json:"tags" aolabel:"tag"` Logo string `json:"logo"` Provider *auto.Label `json:"provider,omitempty" aolabel:"ai_provider"` + ProviderType string `json:"provider_type"` ApprovalType string `json:"approval_type"` AsServer bool `json:"as_server"` AsApp bool `json:"as_app"` @@ -119,6 +120,7 @@ func ToService(model *service.Service) *Service { if model.Prefix != "" { prefix = model.Prefix } + s := &Service{ Id: model.Id, Name: model.Name, @@ -146,6 +148,10 @@ func ToService(model *service.Service) *Service { case service.AIService: provider := auto.UUID(model.AdditionalConfig["provider"]) s.Provider = &provider + s.ProviderType = "local" + if provider.Id != "ollama" { + s.ProviderType = "online" + } } return s }