mirror of
https://github.com/APIParkLab/APIPark.git
synced 2026-07-06 16:11:56 +08:00
Fix: Failure to update local model configuration to gateway
This commit is contained in:
@@ -10,6 +10,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
subscribe_dto "github.com/APIParkLab/APIPark/module/subscribe/dto"
|
||||
|
||||
"github.com/eolinker/eosc/log"
|
||||
|
||||
ai_dto "github.com/APIParkLab/APIPark/module/ai/dto"
|
||||
@@ -222,6 +224,7 @@ type imlInitController struct {
|
||||
applicationAuthorizationModule application_authorization.IAuthorizationModule `autowired:""`
|
||||
catalogueModule catalogue.ICatalogueModule `autowired:""`
|
||||
providerModule ai.IProviderModule `autowired:""`
|
||||
subscribeModule subscribe.ISubscribeModule `autowired:""`
|
||||
transaction store.ITransaction `autowired:""`
|
||||
aiAPIModule ai_api.IAPIModule `autowired:""`
|
||||
docModule service.IServiceDocModule `autowired:""`
|
||||
@@ -264,6 +267,13 @@ func (i *imlInitController) OnInit() {
|
||||
if err != nil {
|
||||
return fmt.Errorf("create default team error: %v", err)
|
||||
}
|
||||
app, err := i.appModule.CreateApp(ctx, info.Id, &service_dto.CreateApp{
|
||||
Name: "Demo Application",
|
||||
Description: "Auto created By APIPark",
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("create default app error: %v", err)
|
||||
}
|
||||
// 创建Rest服务
|
||||
restPath := "/rest-demo"
|
||||
serviceInfo, err := i.serviceModule.Create(ctx, info.Id, &service_dto.CreateService{
|
||||
@@ -298,6 +308,13 @@ func (i *imlInitController) OnInit() {
|
||||
if err != nil {
|
||||
return fmt.Errorf("create default router error: %v", err)
|
||||
}
|
||||
err = i.subscribeModule.AddSubscriber(ctx, serviceInfo.Id, &subscribe_dto.AddSubscriber{
|
||||
Application: app.Id,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 创建AI服务
|
||||
err = i.createAIService(ctx, info.Id, &service_dto.CreateService{
|
||||
Name: "AI Demo Service",
|
||||
@@ -307,17 +324,11 @@ func (i *imlInitController) OnInit() {
|
||||
Catalogue: catalogueId,
|
||||
ApprovalType: "auto",
|
||||
Kind: "ai",
|
||||
})
|
||||
}, app.Id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
app, err := i.appModule.CreateApp(ctx, info.Id, &service_dto.CreateApp{
|
||||
Name: "Demo Application",
|
||||
Description: "Auto created By APIPark",
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("create default app error: %v", err)
|
||||
}
|
||||
|
||||
_, err = i.applicationAuthorizationModule.AddAuthorization(ctx, app.Id, &application_authorization_dto.CreateAuthorization{
|
||||
Name: "Default API Key",
|
||||
Driver: "apikey",
|
||||
@@ -338,7 +349,7 @@ func (i *imlInitController) OnInit() {
|
||||
}
|
||||
})
|
||||
}
|
||||
func (i *imlInitController) createAIService(ctx context.Context, teamID string, input *service_dto.CreateService) error {
|
||||
func (i *imlInitController) createAIService(ctx context.Context, teamID string, input *service_dto.CreateService, appId string) error {
|
||||
|
||||
providerId := "fakegpt"
|
||||
err := i.providerModule.UpdateProviderConfig(ctx, providerId, &ai_dto.UpdateConfig{
|
||||
@@ -469,6 +480,12 @@ func (i *imlInitController) createAIService(ctx context.Context, teamID string,
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = i.subscribeModule.AddSubscriber(ctx, info.Id, &subscribe_dto.AddSubscriber{
|
||||
Application: appId,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return i.docModule.SaveServiceDoc(ctx, info.Id, &service_dto.SaveServiceDoc{
|
||||
Doc: "The Translation API allows developers to translate text from one language to another. It supports multiple languages and enables easy integration of high-quality translation features into applications. With simple API requests, you can quickly translate content into different target languages.",
|
||||
|
||||
Reference in New Issue
Block a user