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

Function httpStatusForModelAdminError

core/http/endpoints/localai/edit_model.go:101–119  ·  view source on GitHub ↗

httpStatusForModelAdminError maps the typed errors from modeladmin to the HTTP status codes the existing endpoints used to return — keeps the REST contract identical after the refactor.

(err error)

Source from the content-addressed store, hash-verified

99// the HTTP status codes the existing endpoints used to return — keeps the
100// REST contract identical after the refactor.
101func httpStatusForModelAdminError(err error) int {
102 switch {
103 case errors.Is(err, modeladmin.ErrNameRequired),
104 errors.Is(err, modeladmin.ErrEmptyBody),
105 errors.Is(err, modeladmin.ErrPathSeparator),
106 errors.Is(err, modeladmin.ErrBadAction),
107 errors.Is(err, modeladmin.ErrInvalidConfig):
108 return http.StatusBadRequest
109 case errors.Is(err, modeladmin.ErrNotFound),
110 errors.Is(err, modeladmin.ErrConfigFileMissing):
111 return http.StatusNotFound
112 case errors.Is(err, modeladmin.ErrPathNotTrusted):
113 return http.StatusForbidden
114 case errors.Is(err, modeladmin.ErrConflict):
115 return http.StatusConflict
116 default:
117 return http.StatusInternalServerError
118 }
119}
120
121// ReloadModelsEndpoint handles reloading model configurations from disk
122func ReloadModelsEndpoint(cl *config.ModelConfigLoader, appConfig *config.ApplicationConfig) echo.HandlerFunc {

Callers 6

GetEditModelPageFunction · 0.85
EditModelEndpointFunction · 0.85
PatchConfigEndpointFunction · 0.85
VRAMEstimateEndpointFunction · 0.85
ToggleStateModelEndpointFunction · 0.85

Calls 1

IsMethod · 0.45

Tested by

no test coverage detected