[PR #2399] [MERGED] Fix hanging issue when sending empty content #16147

Closed
opened 2026-04-16 05:17:48 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/2399
Author: @jmorganca
Created: 2/7/2024
Status: Merged
Merged: 2/8/2024
Merged by: @jmorganca

Base: mainHead: jmorgan/fix-empty


📝 Commits (1)

  • 0f5a928 Fix hanging issue when sending empty content

📊 Changes

2 files changed (+24 additions, -21 deletions)

View changed files

📝 server/images.go (+12 -9)
📝 server/routes.go (+12 -12)

📄 Description

This fixes an issue where the prompt would be templated as an empty string "".

Fixes https://github.com/ollama/ollama/issues/2397

# loads model
% curl http://localhost:11434/api/chat -d '{
  "model": "llama2",
  "messages": [],
  "stream": false           
}'
{"model":"llama2","created_at":"2024-02-07T23:21:14.816749Z","message":{"role":"assistant","content":""},"done":true}
# loads model
% curl http://localhost:11434/api/chat -d '{
  "model": "llama2",
  "messages": [{ "role": "user", "content": ""}],
  "stream": false
}'
{"model":"llama2","created_at":"2024-02-07T23:20:28.175454Z","message": {"role":"assistant","content":""},"done":true}
# still works
% curl http://localhost:11434/api/chat -d '{
  "model": "llama2",
  "messages": [{ "role": "system", "content": "sing me a song!"}],
  "stream": false
}'
{"model":"llama2","created_at":"2024-02-07T23:19:01.582144Z","message":{"role":"assistant","content":"Of course, I'd be happy to sing you a song! *clears throat* Here we go:\n\n\"Oh, the stars are shining bright and bold,\nA celestial show, so fine and cold.\nThe moon is smiling, its light so pure,\nA gentle melody, for you I endure.\n\nIn the night's embrace, I find my peace,\nThe world outside, a distant release.\nI lose myself in the music of the night,\nAnd let my spirit take flight.\n\nSo come and join me, in this song so bright,\nTogether we'll dance, under the stars' delight.\nWith every note, our hearts will be as one,\nIn this magical moment, we'll have fun.\"\n\nHow was that? Did you enjoy it?"},"done":true,"total_duration":5454697000,"load_duration":1188958,"prompt_eval_duration":177470000,"eval_count":182,"eval_duration":5275568000}

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/2399 **Author:** [@jmorganca](https://github.com/jmorganca) **Created:** 2/7/2024 **Status:** ✅ Merged **Merged:** 2/8/2024 **Merged by:** [@jmorganca](https://github.com/jmorganca) **Base:** `main` ← **Head:** `jmorgan/fix-empty` --- ### 📝 Commits (1) - [`0f5a928`](https://github.com/ollama/ollama/commit/0f5a9284c6eb17633ac62bc11bd1d140cce59227) Fix hanging issue when sending empty content ### 📊 Changes **2 files changed** (+24 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `server/images.go` (+12 -9) 📝 `server/routes.go` (+12 -12) </details> ### 📄 Description This fixes an issue where the prompt would be templated as an empty string `""`. Fixes https://github.com/ollama/ollama/issues/2397 ```shell # loads model % curl http://localhost:11434/api/chat -d '{ "model": "llama2", "messages": [], "stream": false }' {"model":"llama2","created_at":"2024-02-07T23:21:14.816749Z","message":{"role":"assistant","content":""},"done":true} ``` ```shell # loads model % curl http://localhost:11434/api/chat -d '{ "model": "llama2", "messages": [{ "role": "user", "content": ""}], "stream": false }' {"model":"llama2","created_at":"2024-02-07T23:20:28.175454Z","message": {"role":"assistant","content":""},"done":true} ``` ```shell # still works % curl http://localhost:11434/api/chat -d '{ "model": "llama2", "messages": [{ "role": "system", "content": "sing me a song!"}], "stream": false }' {"model":"llama2","created_at":"2024-02-07T23:19:01.582144Z","message":{"role":"assistant","content":"Of course, I'd be happy to sing you a song! *clears throat* Here we go:\n\n\"Oh, the stars are shining bright and bold,\nA celestial show, so fine and cold.\nThe moon is smiling, its light so pure,\nA gentle melody, for you I endure.\n\nIn the night's embrace, I find my peace,\nThe world outside, a distant release.\nI lose myself in the music of the night,\nAnd let my spirit take flight.\n\nSo come and join me, in this song so bright,\nTogether we'll dance, under the stars' delight.\nWith every note, our hearts will be as one,\nIn this magical moment, we'll have fun.\"\n\nHow was that? Did you enjoy it?"},"done":true,"total_duration":5454697000,"load_duration":1188958,"prompt_eval_duration":177470000,"eval_count":182,"eval_duration":5275568000} ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-16 05:17:48 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#16147