make the modelfile path relative for ollama create (#8380)

This commit is contained in:
Patrick Devine 2025-01-10 16:14:08 -08:00 committed by GitHub
parent 9446c2c902
commit 32bd37adf8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 155 additions and 25 deletions

View file

@ -46,9 +46,8 @@ import (
var errModelfileNotFound = errors.New("specified Modelfile wasn't found")
func getModelfileName(cmd *cobra.Command) (string, error) {
fn, _ := cmd.Flags().GetString("file")
filename, _ := cmd.Flags().GetString("file")
filename := fn
if filename == "" {
filename = "Modelfile"
}
@ -60,7 +59,7 @@ func getModelfileName(cmd *cobra.Command) (string, error) {
_, err = os.Stat(absName)
if err != nil {
return fn, err
return filename, err
}
return absName, nil
@ -100,7 +99,7 @@ func CreateHandler(cmd *cobra.Command, args []string) error {
spinner := progress.NewSpinner(status)
p.Add(status, spinner)
req, err := modelfile.CreateRequest()
req, err := modelfile.CreateRequest(filepath.Dir(filename))
if err != nil {
return err
}