MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / RemoveModel

Method RemoveModel

module/ai-local/iml.go:409–436  ·  view source on GitHub ↗
(ctx context.Context, model string)

Source from the content-addressed store, hash-verified

407}
408
409func (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
438func (i *imlLocalModel) Enable(ctx context.Context, model string) error {
439 info, err := i.localModelService.Get(ctx, model)

Callers

nothing calls this directly

Calls 5

CountByModelMethod · 0.65
GetMethod · 0.65
RemoveModelMethod · 0.65
DeleteMethod · 0.65
IntMethod · 0.45

Tested by

no test coverage detected