[GH-ISSUE #413] panic with empty TEMPLATE in Modelfile #188

Closed
opened 2026-04-12 09:43:00 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @sqs on GitHub (Aug 25, 2023).
Original GitHub issue: https://github.com/ollama/ollama/issues/413

Originally assigned to: @mxyng on GitHub.

I know that TEMPLATE should not be blank, but I'm reporting this anyway. (I think what I wanted is for TEMPLATE to be {{ .Prompt }}.)

Repro:

Make a Modelfile (intent is to have an empty template):

FROM codellama:7b

TEMPLATE """"""

Run ollama create foo-notmpl -f Modelfile then ollama run foo-notmpl and then type something in.

ollama run exits with Error: unexpected end of response and the ollama server panics with:

[GIN] 2023/08/25 - 13:17:14 | 200 |  298.153511ms |       127.0.0.1 | POST     "/api/generate"
panic: runtime error: slice bounds out of range [:-1]

goroutine 31 [running]:
github.com/jmorganca/ollama/llm.(*llama).marshalPrompt(0xc0001c50e0, {0x0, 0x0, 0x0}, {0x0?, 0x4730db?})
	/home/sqs/src/github.com/jmorganca/ollama/llm/llama.go:429 +0x61c
github.com/jmorganca/ollama/llm.(*llama).Predict(0xc0001c50e0, {0x0, 0x0, 0x0}, {0x0, 0x0}, 0xc00023e550)
	/home/sqs/src/github.com/jmorganca/ollama/llm/llama.go:320 +0x9b
github.com/jmorganca/ollama/server.GenerateHandler.func1()
	/home/sqs/src/github.com/jmorganca/ollama/server/routes.go:199 +0x1f9
created by github.com/jmorganca/ollama/server.GenerateHandler
	/home/sqs/src/github.com/jmorganca/ollama/server/routes.go:183 +0x96a
Originally created by @sqs on GitHub (Aug 25, 2023). Original GitHub issue: https://github.com/ollama/ollama/issues/413 Originally assigned to: @mxyng on GitHub. I know that TEMPLATE should not be blank, but I'm reporting this anyway. (I think what I wanted is for TEMPLATE to be `{{ .Prompt }}`.) Repro: Make a Modelfile (intent is to have an empty template): ``` FROM codellama:7b TEMPLATE """""" ``` Run `ollama create foo-notmpl -f Modelfile` then `ollama run foo-notmpl` and then type something in. `ollama run` exits with `Error: unexpected end of response` and the ollama server panics with: ``` [GIN] 2023/08/25 - 13:17:14 | 200 | 298.153511ms | 127.0.0.1 | POST "/api/generate" panic: runtime error: slice bounds out of range [:-1] goroutine 31 [running]: github.com/jmorganca/ollama/llm.(*llama).marshalPrompt(0xc0001c50e0, {0x0, 0x0, 0x0}, {0x0?, 0x4730db?}) /home/sqs/src/github.com/jmorganca/ollama/llm/llama.go:429 +0x61c github.com/jmorganca/ollama/llm.(*llama).Predict(0xc0001c50e0, {0x0, 0x0, 0x0}, {0x0, 0x0}, 0xc00023e550) /home/sqs/src/github.com/jmorganca/ollama/llm/llama.go:320 +0x9b github.com/jmorganca/ollama/server.GenerateHandler.func1() /home/sqs/src/github.com/jmorganca/ollama/server/routes.go:199 +0x1f9 created by github.com/jmorganca/ollama/server.GenerateHandler /home/sqs/src/github.com/jmorganca/ollama/server/routes.go:183 +0x96a ```
GiteaMirror added the bug label 2026-04-12 09:43:00 -05:00
Author
Owner

@mxyng commented on GitHub (Aug 26, 2023):

Thanks for creating the issue. I've been meaning to fix this for a while. If TEMPLATE is empty, it should default to {{ .Prompt }}

<!-- gh-comment-id:1694484818 --> @mxyng commented on GitHub (Aug 26, 2023): Thanks for creating the issue. I've been meaning to fix this for a while. If `TEMPLATE` is empty, it should default to `{{ .Prompt }}`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#188