Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better client error for /api/create #8351

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
3 changes: 2 additions & 1 deletion server/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}

Expand Down
Loading