Download internal/httpapi/openai/shared/models.go from a3216/ds2api: direct link, hf CLI and curl.
- Browser
- Download file 610 Bytes
-
https://huggingface.co/spaces/a3216/ds2api/resolve/ce5a019598af8a3a8fa70d3880098df3e850ecd7/internal/httpapi/openai/shared/models.go
- Command line
-
hf download hf://spaces/a3216/ds2api@ce5a019598af8a3a8fa70d3880098df3e850ecd7/internal/httpapi/openai/shared/models.go
-
curl -L -o models.go https://huggingface.co/spaces/a3216/ds2api/resolve/ce5a019598af8a3a8fa70d3880098df3e850ecd7/internal/httpapi/openai/shared/models.go
610 Bytes
| package shared | |
| import ( | |
| "net/http" | |
| "strings" | |
| "github.com/go-chi/chi/v5" | |
| "ds2api/internal/config" | |
| ) | |
| type ModelsHandler struct { | |
| Store ConfigReader | |
| } | |
| func (h *ModelsHandler) ListModels(w http.ResponseWriter, _ *http.Request) { | |
| WriteJSON(w, http.StatusOK, config.OpenAIModelsResponse()) | |
| } | |
| func (h *ModelsHandler) GetModel(w http.ResponseWriter, r *http.Request) { | |
| modelID := strings.TrimSpace(chi.URLParam(r, "model_id")) | |
| model, ok := config.OpenAIModelByID(h.Store, modelID) | |
| if !ok { | |
| WriteOpenAIError(w, http.StatusNotFound, "Model not found.") | |
| return | |
| } | |
| WriteJSON(w, http.StatusOK, model) | |
| } | |