ImportQuantizedModelEndpoint imports a quantized model into LocalAI.
(qService *quantization.QuantizationService)
| 149 | |
| 150 | // ImportQuantizedModelEndpoint imports a quantized model into LocalAI. |
| 151 | func 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. |
| 179 | func DownloadQuantizedModelEndpoint(qService *quantization.QuantizationService) echo.HandlerFunc { |
no test coverage detected