MCPcopy
hub / github.com/mudler/LocalAI / Run

Method Run

core/cli/backends.go:101–136  ·  view source on GitHub ↗
(ctx *cliContext.Context)

Source from the content-addressed store, hash-verified

99}
100
101func (bi *BackendsInstall) Run(ctx *cliContext.Context) error {
102 var galleries []config.Gallery
103 if err := json.Unmarshal([]byte(bi.BackendGalleries), &galleries); err != nil {
104 xlog.Error("unable to load galleries", "error", err)
105 }
106
107 systemState, err := system.GetSystemState(
108 system.WithBackendSystemPath(bi.BackendsSystemPath),
109 system.WithBackendPath(bi.BackendsPath),
110 )
111 if err != nil {
112 return err
113 }
114
115 progressBar := progressbar.NewOptions(
116 1000,
117 progressbar.OptionSetDescription(fmt.Sprintf("downloading backend %s", bi.BackendArgs)),
118 progressbar.OptionShowBytes(false),
119 progressbar.OptionClearOnFinish(),
120 )
121 progressCallback := func(fileName string, current string, total string, percentage float64) {
122 v := int(percentage * 10)
123 err := progressBar.Set(v)
124 if err != nil {
125 xlog.Error("error while updating progress bar", "error", err, "filename", fileName, "value", v)
126 }
127 }
128
129 modelLoader := model.NewModelLoader(systemState)
130 err = galleryop.InstallExternalBackend(context.Background(), galleries, systemState, modelLoader, progressCallback, bi.BackendArgs, bi.Name, bi.Alias, bi.RequireBackendIntegrity)
131 if err != nil {
132 return err
133 }
134
135 return nil
136}
137
138func (bu *BackendsUpgrade) Run(ctx *cliContext.Context) error {
139 var galleries []config.Gallery

Callers

nothing calls this directly

Calls 7

GetSystemStateFunction · 0.92
WithBackendSystemPathFunction · 0.92
WithBackendPathFunction · 0.92
NewModelLoaderFunction · 0.92
InstallExternalBackendFunction · 0.92
SetMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected