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

Method Run

core/cli/run.go:189–680  ·  view source on GitHub ↗
(ctx *cliContext.Context)

Source from the content-addressed store, hash-verified

187}
188
189func (r *RunCMD) Run(ctx *cliContext.Context) error {
190 warnDeprecatedFlags()
191
192 if r.Version {
193 fmt.Println(internal.Version)
194 return nil
195 }
196
197 os.MkdirAll(r.BackendsPath, 0750)
198 os.MkdirAll(r.ModelsPath, 0750)
199
200 systemState, err := system.GetSystemState(
201 system.WithBackendSystemPath(r.BackendsSystemPath),
202 system.WithModelPath(r.ModelsPath),
203 system.WithBackendPath(r.BackendsPath),
204 system.WithBackendImagesReleaseTag(r.BackendImagesReleaseTag),
205 system.WithBackendImagesBranchTag(r.BackendImagesBranchTag),
206 system.WithBackendDevSuffix(r.BackendDevSuffix),
207 system.WithPreferDevelopmentBackends(r.PreferDevelopmentBackends),
208 )
209 if err != nil {
210 return err
211 }
212
213 opts := []config.AppOption{
214 config.WithContext(context.Background()),
215 config.WithConfigFile(r.ModelsConfigFile),
216 config.WithJSONStringPreload(r.PreloadModels),
217 config.WithYAMLConfigPreload(r.PreloadModelsConfig),
218 config.WithSystemState(systemState),
219 config.WithContextSize(r.ContextSize),
220 config.WithDebug(ctx.Debug || (ctx.LogLevel != nil && *ctx.LogLevel == "debug")),
221 config.WithGeneratedContentDir(r.GeneratedContentPath),
222 config.WithUploadDir(r.UploadPath),
223 config.WithDataPath(r.DataPath),
224 config.WithDynamicConfigDir(r.LocalaiConfigDir),
225 config.WithDynamicConfigDirPollInterval(r.LocalaiConfigDirPollInterval),
226 config.WithF16(r.F16),
227 config.WithStringGalleries(r.Galleries),
228 config.WithBackendGalleries(r.BackendGalleries),
229 config.WithCors(r.CORS),
230 config.WithCorsAllowOrigins(r.CORSAllowOrigins),
231 config.WithDisableCSRF(r.DisableCSRF),
232 config.WithThreads(r.Threads),
233 config.WithUploadLimitMB(r.UploadLimit),
234 config.WithApiKeys(r.APIKeys),
235 config.WithModelsURL(append(r.Models, r.ModelArgs...)...),
236 config.WithExternalBackends(r.ExternalBackends...),
237 config.WithWebRTCNAT1To1IPs(r.WebRTCNAT1To1IPs...),
238 config.WithWebRTCICEInterfaces(r.WebRTCICEInterfaces...),
239 config.WithOpaqueErrors(r.OpaqueErrors),
240 config.WithEnforcedPredownloadScans(!r.DisablePredownloadScan),
241 config.WithSubtleKeyComparison(r.UseSubtleKeyComparison),
242 config.WithDisableApiKeyRequirementForHttpGet(r.DisableApiKeyRequirementForHttpGet),
243 config.WithHttpGetExemptedEndpoints(r.HttpGetExemptedEndpoints),
244 config.WithP2PNetworkID(r.Peer2PeerNetworkID),
245 config.WithLoadToMemory(r.LoadToMemory),
246 config.WithMachineTag(r.MachineTag),

Callers

nothing calls this directly

Calls 15

GetSystemStateFunction · 0.92
WithBackendSystemPathFunction · 0.92
WithModelPathFunction · 0.92
WithBackendPathFunction · 0.92
WithBackendDevSuffixFunction · 0.92
WithContextFunction · 0.92
WithConfigFileFunction · 0.92
WithJSONStringPreloadFunction · 0.92
WithYAMLConfigPreloadFunction · 0.92

Tested by

no test coverage detected