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

Function ImportQuantizedModelEndpoint

core/http/endpoints/localai/quantization.go:151–176  ·  view source on GitHub ↗

ImportQuantizedModelEndpoint imports a quantized model into LocalAI.

(qService *quantization.QuantizationService)

Source from the content-addressed store, hash-verified

149
150// ImportQuantizedModelEndpoint imports a quantized model into LocalAI.
151func ImportQuantizedModelEndpoint(qService *quantization.QuantizationService) echo.HandlerFunc {
152 return func(c echo.Context) error {
153 userID := getUserID(c)
154 jobID := c.Param("id")
155
156 var req schema.QuantizationImportRequest
157 if err := c.Bind(&req); err != nil {
158 return c.JSON(http.StatusBadRequest, map[string]string{
159 "error": "Invalid request: " + err.Error(),
160 })
161 }
162
163 modelName, err := qService.ImportModel(c.Request().Context(), userID, jobID, req)
164 if err != nil {
165 return c.JSON(http.StatusInternalServerError, map[string]string{
166 "error": err.Error(),
167 })
168 }
169
170 return c.JSON(http.StatusAccepted, map[string]string{
171 "status": "importing",
172 "message": "Import started for model '" + modelName + "'",
173 "model_name": modelName,
174 })
175 }
176}
177
178// DownloadQuantizedModelEndpoint streams the quantized model file.
179func DownloadQuantizedModelEndpoint(qService *quantization.QuantizationService) echo.HandlerFunc {

Callers 1

Calls 6

getUserIDFunction · 0.85
JSONMethod · 0.80
ImportModelMethod · 0.80
ContextMethod · 0.65
RequestMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected