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

Method Enable

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

Source from the content-addressed store, hash-verified

436}
437
438func (i *imlLocalModel) Enable(ctx context.Context, model string) error {
439 info, err := i.localModelService.Get(ctx, model)
440 if err != nil {
441 return err
442 }
443 if info.State == ai_local_dto.LocalModelStateDisable.Int() || info.State == ai_local_dto.LocalModelStateError.Int() {
444
445 return i.transaction.Transaction(ctx, func(ctx context.Context) error {
446 status := ai_local_dto.LocalModelStateNormal.Int()
447 err = i.localModelService.Save(ctx, model, &ai_local.EditLocalModel{State: &status})
448 if err != nil {
449 return err
450 }
451 v, _ := i.settingService.Get(ctx, "system.ai_model.ollama_address")
452 cfg := make(map[string]interface{})
453 cfg["provider"] = ai_provider_local.ProviderLocal
454 cfg["model"] = info.Id
455 cfg["model_config"] = ai_provider_local.LocalConfig
456 cfg["priority"] = 0
457 cfg["base"] = v
458
459 return i.syncGateway(ctx, cluster.DefaultClusterID, []*gateway.DynamicRelease{
460 {
461 BasicItem: &gateway.BasicItem{
462 ID: info.Id,
463 Description: info.Id,
464 Resource: "ai-provider",
465 Version: info.UpdateAt.Format("20060102150405"),
466 MatchLabels: map[string]string{
467 "module": "ai-provider",
468 },
469 },
470 Attr: cfg,
471 }}, true)
472 })
473
474 }
475 return fmt.Errorf("model %s is not disabled state,can not enable", model)
476}
477
478func (i *imlLocalModel) Disable(ctx context.Context, model string) error {
479 info, err := i.localModelService.Get(ctx, model)

Callers

nothing calls this directly

Calls 4

syncGatewayMethod · 0.95
GetMethod · 0.65
SaveMethod · 0.65
IntMethod · 0.45

Tested by

no test coverage detected