(ctx context.Context, model string)
| 476 | } |
| 477 | |
| 478 | func (i *imlLocalModel) Disable(ctx context.Context, model string) error { |
| 479 | info, err := i.localModelService.Get(ctx, model) |
| 480 | if err != nil { |
| 481 | return err |
| 482 | } |
| 483 | if info.State == ai_local_dto.LocalModelStateNormal.Int() { |
| 484 | disable := ai_local_dto.LocalModelStateDisable.Int() |
| 485 | return i.transaction.Transaction(ctx, func(ctx context.Context) error { |
| 486 | err = i.localModelService.Save(ctx, model, &ai_local.EditLocalModel{State: &disable}) |
| 487 | if err != nil { |
| 488 | return err |
| 489 | } |
| 490 | |
| 491 | return i.syncGateway(ctx, cluster.DefaultClusterID, []*gateway.DynamicRelease{ |
| 492 | { |
| 493 | BasicItem: &gateway.BasicItem{ |
| 494 | ID: info.Id, |
| 495 | Resource: "ai-provider", |
| 496 | }, |
| 497 | }}, false) |
| 498 | }) |
| 499 | |
| 500 | } |
| 501 | return fmt.Errorf("model %s is not enabled state,can not disable", model) |
| 502 | } |
| 503 | |
| 504 | func (i *imlLocalModel) OnInit() { |
| 505 | register.Handle(func(v server.Server) { |
nothing calls this directly
no test coverage detected