From 61f4742d19c545ed5b8c9a1c452cc32bc9933e55 Mon Sep 17 00:00:00 2001 From: Liujian <824010343@qq.com> Date: Mon, 17 Feb 2025 18:08:29 +0800 Subject: [PATCH] init service consumer --- controller/ai-local/iml.go | 17 +++++++++++++++-- controller/service/iml.go | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/controller/ai-local/iml.go b/controller/ai-local/iml.go index 1966bf92..c46b4083 100644 --- a/controller/ai-local/iml.go +++ b/controller/ai-local/iml.go @@ -9,6 +9,9 @@ import ( "net/http" "strings" + "github.com/APIParkLab/APIPark/module/subscribe" + subscribe_dto "github.com/APIParkLab/APIPark/module/subscribe/dto" + "github.com/APIParkLab/APIPark/model/plugin_model" "github.com/APIParkLab/APIPark/service/api" @@ -44,7 +47,9 @@ type imlLocalModelController struct { serviceModule service.IServiceModule `autowired:""` catalogueModule catalogue.ICatalogueModule `autowired:""` aiAPIModule ai_api.IAPIModule `autowired:""` + appModule service.IAppModule `autowired:""` routerModule router.IRouterModule `autowired:""` + subscribeModule subscribe.ISubscribeModule `autowired:""` docModule service.IServiceDocModule `autowired:""` transaction store.ITransaction `autowired:""` } @@ -226,7 +231,7 @@ func (i *imlLocalModelController) initAILocalService(ctx context.Context, model Type: "local", } name := "Demo AI API" - description := "A demo that shows you how to use a e a Chat API." + description := "This is a demo that shows you how to use a Chat API." apiId := uuid.NewString() err = i.aiAPIModule.Create( ctx, @@ -281,7 +286,15 @@ func (i *imlLocalModelController) initAILocalService(ctx context.Context, model if err != nil { return err } - + apps, err := i.appModule.Search(ctx, teamID, "") + if err != nil { + return err + } + for _, app := range apps { + i.subscribeModule.AddSubscriber(ctx, serviceId, &subscribe_dto.AddSubscriber{ + Application: app.Id, + }) + } return i.docModule.SaveServiceDoc(ctx, serviceId, &service_dto.SaveServiceDoc{ Doc: "", }) diff --git a/controller/service/iml.go b/controller/service/iml.go index c21ecb88..310b5876 100644 --- a/controller/service/iml.go +++ b/controller/service/iml.go @@ -386,7 +386,7 @@ func (i *imlServiceController) createAIService(ctx *gin.Context, teamID string, Type: modelType, } name := "Demo AI API " - description := "A demo that shows you how to use Chat API." + description := "This is a demo that shows you how to use a Chat API." apiId := uuid.New().String() err = i.aiAPIModule.Create( ctx,