(ctx context.Context, model string)
| 407 | } |
| 408 | |
| 409 | func (i *imlLocalModel) RemoveModel(ctx context.Context, model string) error { |
| 410 | // 判断是否有api |
| 411 | count, err := i.aiAPIService.CountByModel(ctx, model) |
| 412 | if err != nil { |
| 413 | return err |
| 414 | } |
| 415 | if count > 0 { |
| 416 | return fmt.Errorf("model %s has api, can not remove", model) |
| 417 | } |
| 418 | info, err := i.localModelService.Get(ctx, model) |
| 419 | if err != nil { |
| 420 | if !errors.Is(err, gorm.ErrRecordNotFound) { |
| 421 | return err |
| 422 | } |
| 423 | return ai_provider_local.RemoveModel(model) |
| 424 | } |
| 425 | if info.State == ai_local_dto.LocalModelStateDeploying.Int() { |
| 426 | return fmt.Errorf("model %s is deploying, can not remove", model) |
| 427 | } |
| 428 | return i.transaction.Transaction(ctx, func(txCtx context.Context) error { |
| 429 | err = i.localModelService.Delete(ctx, model) |
| 430 | if err != nil { |
| 431 | return err |
| 432 | } |
| 433 | return ai_provider_local.RemoveModel(model) |
| 434 | }) |
| 435 | |
| 436 | } |
| 437 | |
| 438 | func (i *imlLocalModel) Enable(ctx context.Context, model string) error { |
| 439 | info, err := i.localModelService.Get(ctx, model) |
nothing calls this directly
no test coverage detected