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

Method Deploy

module/ai-local/iml.go:306–350  ·  view source on GitHub ↗
(ctx context.Context, model string, session string, fn ...func() error)

Source from the content-addressed store, hash-verified

304}
305
306func (i *imlLocalModel) Deploy(ctx context.Context, model string, session string, fn ...func() error) (*ai_provider_local.Pipeline, error) {
307 var p *ai_provider_local.Pipeline
308 err := i.transaction.Transaction(ctx, func(txCtx context.Context) error {
309 item, err := i.localModelCacheService.GetByTarget(ctx, ai_local.CacheTypeService, model)
310 if err != nil {
311 if !errors.Is(err, gorm.ErrRecordNotFound) {
312 return err
313 }
314
315 } else {
316 model = item.Model
317 }
318 info, err := i.localModelService.Get(ctx, model)
319 if err != nil {
320 if !errors.Is(err, gorm.ErrRecordNotFound) {
321 return err
322 }
323 err = i.localModelService.Create(ctx, &ai_local.CreateLocalModel{
324 Id: model,
325 Name: model,
326 Provider: ai_provider_local.ProviderLocal,
327 State: ai_local_dto.LocalModelStateDeploying.Int(),
328 })
329
330 } else {
331 if info.State == ai_local_dto.LocalModelStateDeployingError.Int() {
332 state := ai_local_dto.LocalModelStateDeploying.Int()
333 err = i.localModelService.Save(ctx, model, &ai_local.EditLocalModel{State: &state})
334 }
335 }
336 if err != nil {
337 return err
338 }
339 p, err = ai_provider_local.PullModel(model, session, i.pullHook(fn...))
340 if err != nil {
341 return err
342 }
343 return nil
344 })
345 if err != nil {
346 return nil, err
347 }
348
349 return p, nil
350}
351
352func (i *imlLocalModel) SaveCache(ctx context.Context, model string, target string) error {
353 return i.localModelCacheService.Save(ctx, model, ai_local.CacheTypeService, target)

Callers

nothing calls this directly

Calls 6

pullHookMethod · 0.95
GetByTargetMethod · 0.65
GetMethod · 0.65
CreateMethod · 0.65
SaveMethod · 0.65
IntMethod · 0.45

Tested by

no test coverage detected