Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

server: reuse InvalidModelNameErrMsg type (#8163)

湛露先生928de9050e59
diff --git a/server/routes.go b/server/routes.go
index 0154dde70..f3b78927c 100644
--- a/server/routes.go
+++ b/server/routes.go
@@ -142,7 +142,7 @@ func (s *Server) GenerateHandler(c *gin.Context) {
switch {
case errors.Is(err, fs.ErrNotExist):
c.JSON(http.StatusNotFound, gin.H{"error": fmt.Sprintf("model '%s' not found", req.Model)})
- case err.Error() == "invalid model name":
+ case err.Error() == errtypes.InvalidModelNameErrMsg:
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
default:
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
@@ -568,7 +568,7 @@ func (s *Server) PullHandler(c *gin.Context) {
name := model.ParseName(cmp.Or(req.Model, req.Name))
if !name.IsValid() {
- c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": "invalid model name"})
+ c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": errtypes.InvalidModelNameErrMsg})
return
}
@@ -829,7 +829,7 @@ func (s *Server) ShowHandler(c *gin.Context) {
switch {
case os.IsNotExist(err):
c.JSON(http.StatusNotFound, gin.H{"error": fmt.Sprintf("model '%s' not found", req.Model)})
- case err.Error() == "invalid model name":
+ case err.Error() == errtypes.InvalidModelNameErrMsg:
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
default:
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
@@ -1470,7 +1470,7 @@ func (s *Server) ChatHandler(c *gin.Context) {
switch {
case os.IsNotExist(err):
c.JSON(http.StatusNotFound, gin.H{"error": fmt.Sprintf("model '%s' not found", req.Model)})
- case err.Error() == "invalid model name":
+ case err.Error() == errtypes.InvalidModelNameErrMsg:
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
default:
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})