Browse Source

show a more descriptive error in the client if it is newer than the server (#8351)

Patrick Devine 3 tháng trước cách đây
mục cha
commit
8bccae4f92
2 tập tin đã thay đổi với 5 bổ sung1 xóa
  1. 3 0
      cmd/cmd.go
  2. 2 1
      server/create.go

+ 3 - 0
cmd/cmd.go

@@ -162,6 +162,9 @@ func CreateHandler(cmd *cobra.Command, args []string) error {
 	}
 
 	if err := client.Create(cmd.Context(), req, fn); err != nil {
+		if strings.Contains(err.Error(), "path or Modelfile are required") {
+			return fmt.Errorf("the ollama server must be updated to use `ollama create` with this client")
+		}
 		return err
 	}
 

+ 2 - 1
server/create.go

@@ -33,6 +33,7 @@ var (
 	errOnlyOneAdapterSupported = errors.New("only one adapter is currently supported")
 	errOnlyGGUFSupported       = errors.New("supplied file was not in GGUF format")
 	errUnknownType             = errors.New("unknown type")
+	errNeitherFromOrFiles      = errors.New("neither 'from' or 'files' was specified")
 )
 
 func (s *Server) CreateHandler(c *gin.Context) {
@@ -95,7 +96,7 @@ func (s *Server) CreateHandler(c *gin.Context) {
 				return
 			}
 		} else {
-			ch <- gin.H{"error": "neither 'from' or 'files' was specified", "status": http.StatusBadRequest}
+			ch <- gin.H{"error": errNeitherFromOrFiles.Error(), "status": http.StatusBadRequest}
 			return
 		}