Skip to content

Commit

Permalink
Merge pull request ollama#1393 from jmorganca/mxyng/fix-whitespace
Browse files Browse the repository at this point in the history
fix: trim space in modelfile fields
  • Loading branch information
mxyng authored Dec 5, 2023
2 parents 195e3d9 + 38fe1a3 commit b12f1b9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ func Parse(reader io.Reader) ([]Command, error) {
switch string(bytes.ToUpper(fields[0])) {
case "FROM":
command.Name = "model"
command.Args = string(fields[1])
command.Args = string(bytes.TrimSpace(fields[1]))
// copy command for validation
modelCommand = command
case "LICENSE", "TEMPLATE", "SYSTEM", "PROMPT", "ADAPTER":
case "ADAPTER":
command.Name = string(bytes.ToLower(fields[0]))
command.Args = string(bytes.TrimSpace(fields[1]))
case "LICENSE", "TEMPLATE", "SYSTEM", "PROMPT":
command.Name = string(bytes.ToLower(fields[0]))
command.Args = string(fields[1])
case "PARAMETER":
Expand All @@ -50,7 +53,7 @@ func Parse(reader io.Reader) ([]Command, error) {
}

command.Name = string(fields[0])
command.Args = string(fields[1])
command.Args = string(bytes.TrimSpace(fields[1]))
case "EMBED":
return nil, fmt.Errorf("deprecated command: EMBED is no longer supported, use the /embed API endpoint instead")
default:
Expand Down

0 comments on commit b12f1b9

Please sign in to comment.