From 26a50b9a795670c84c23b126aa57276dfdb54ac0 Mon Sep 17 00:00:00 2001 From: Liujian <824010343@qq.com> Date: Fri, 14 Feb 2025 17:24:41 +0800 Subject: [PATCH] Fix: Local model deployment status error --- ai-provider/local/executor.go | 8 +++++++- controller/ai-local/iml.go | 11 +++++++++++ module/ai-local/iml.go | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ai-provider/local/executor.go b/ai-provider/local/executor.go index ae10a33c..b6648d23 100644 --- a/ai-provider/local/executor.go +++ b/ai-provider/local/executor.go @@ -288,7 +288,13 @@ func CancelPipeline(model string, id string) { func RemoveModel(model string) error { taskExecutor.CloseModelPipeline(model) - return client.Delete(context.Background(), &api.DeleteRequest{Model: model}) + err := client.Delete(context.Background(), &api.DeleteRequest{Model: model}) + if err != nil { + if err.Error() == fmt.Sprintf("model '%s' not found", model) { + return nil + } + } + return err } func ModelsInstalled() ([]Model, error) { diff --git a/controller/ai-local/iml.go b/controller/ai-local/iml.go index 40ddf818..a054973d 100644 --- a/controller/ai-local/iml.go +++ b/controller/ai-local/iml.go @@ -3,12 +3,15 @@ package ai_local import ( "context" "encoding/json" + "errors" "fmt" "io" "math" "net/http" "strings" + "gorm.io/gorm" + "github.com/APIParkLab/APIPark/module/router" "github.com/APIParkLab/APIPark/model/plugin_model" @@ -194,6 +197,14 @@ func (i *imlLocalModelController) DeployStart(ctx *gin.Context, input *ai_local_ func (i *imlLocalModelController) initAILocalService(ctx context.Context, model string, teamID string) error { err := i.transaction.Transaction(ctx, func(ctx context.Context) error { + _, err := i.serviceModule.Get(ctx, model) + if err == nil { + return nil + } else { + if !errors.Is(err, gorm.ErrRecordNotFound) { + return err + } + } catalogueInfo, err := i.catalogueModule.DefaultCatalogue(ctx) if err != nil { return err diff --git a/module/ai-local/iml.go b/module/ai-local/iml.go index 51551201..e153dea4 100644 --- a/module/ai-local/iml.go +++ b/module/ai-local/iml.go @@ -210,6 +210,7 @@ func (i *imlLocalModel) CancelDeploy(ctx context.Context, model string) error { } func (i *imlLocalModel) RemoveModel(ctx context.Context, model string) error { + err := ai_provider_local.RemoveModel(model) if err != nil { return err