[PR #1530] [MERGED] send empty messages on last chat response #21150

Closed
opened 2026-04-19 15:28:22 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/1530
Author: @BruceMacD
Created: 12/14/2023
Status: Merged
Merged: 12/18/2023
Merged by: @BruceMacD

Base: mainHead: brucemacd/no-empty-msg


📝 Commits (2)

  • 67face5 send empty messages on last chat response
  • 565a884 pr feedback

📊 Changes

2 files changed (+6 additions, -10 deletions)

View changed files

📝 api/types.go (+2 -2)
📝 server/routes.go (+4 -8)

📄 Description

Send an empty message on the last chat response rather than omitting it. This makes the chat API match the generate API.

As of this change...

/generate

curl http://localhost:11434/api/generate -d '{
    "model": "mistral"
}'

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Thu, 14 Dec 2023 22:42:13 GMT
Content-Length: 88
Connection: close

{
  "model": "mistral",
  "created_at": "2023-12-14T22:42:13.365069Z",
  "response": "",
  "done": true
}
curl http://localhost:11434/api/generate -d '{
    "model": "mistral",
    "prompt": "reply with a single word"
}'

HTTP/1.1 200 OK
Content-Type: application/x-ndjson
Date: Thu, 14 Dec 2023 22:43:05 GMT
Connection: close
Transfer-Encoding: chunked

{"model":"mistral","created_at":"2023-12-14T22:43:05.60168Z","response":" Okay","done":false}
{"model":"mistral","created_at":"2023-12-14T22:43:05.616406Z","response":".","done":false}
{"model":"mistral","created_at":"2023-12-14T22:43:05.631163Z","response":"","done":true,"context":[733,16289,28793,28705,10071,395,264,2692,1707,733,28748,16289,28793,19811,28723],"total_duration":414743625,"load_duration":760500,"prompt_eval_count":14,"prompt_eval_duration":393924000,"eval_count":2,"eval_duration":14727000}

/chat

curl http://localhost:11434/api/chat -d '{
    "model": "mistral"
}'

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Thu, 14 Dec 2023 22:41:56 GMT
Content-Length: 132
Connection: close

{
  "model": "mistral",
  "created_at": "2023-12-14T22:41:56.540246Z",
  "message": {
    "role": "assistant",
    "content": "",
    "images": null
  },
  "done": true
}
curl http://localhost:11434/api/chat -d '{
    "model": "mistral",
    "messages": [
        {
            "role": "user",
            "content": "reply with one word"
        }
    ]
}'
HTTP/1.1 200 OK
Content-Type: application/x-ndjson
Date: Thu, 14 Dec 2023 22:38:36 GMT
Connection: close
Transfer-Encoding: chunked

{"model":"mistral","created_at":"2023-12-14T22:38:36.625168Z","message":{"role":"assistant","content":" Okay","images":null},"done":false}
{"model":"mistral","created_at":"2023-12-14T22:38:36.639622Z","message":{"role":"assistant","content":".","images":null},"done":false}
{"model":"mistral","created_at":"2023-12-14T22:38:36.654161Z","message":{"role":"assistant","content":"","images":null},"done":true,"total_duration":417861167,"load_duration":927584,"prompt_eval_count":13,"prompt_eval_duration":396099000,"eval_count":2,"eval_duration":14502000}

🔄 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/1530 **Author:** [@BruceMacD](https://github.com/BruceMacD) **Created:** 12/14/2023 **Status:** ✅ Merged **Merged:** 12/18/2023 **Merged by:** [@BruceMacD](https://github.com/BruceMacD) **Base:** `main` ← **Head:** `brucemacd/no-empty-msg` --- ### 📝 Commits (2) - [`67face5`](https://github.com/ollama/ollama/commit/67face591d5a915a56212b0c1588ce6f93b507e7) send empty messages on last chat response - [`565a884`](https://github.com/ollama/ollama/commit/565a884e7fd2d475c2044b5143761492c3ab84a1) pr feedback ### 📊 Changes **2 files changed** (+6 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `api/types.go` (+2 -2) 📝 `server/routes.go` (+4 -8) </details> ### 📄 Description Send an empty message on the last chat response rather than omitting it. This makes the chat API match the generate API. As of this change... `/generate` ``` curl http://localhost:11434/api/generate -d '{ "model": "mistral" }' HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 Date: Thu, 14 Dec 2023 22:42:13 GMT Content-Length: 88 Connection: close { "model": "mistral", "created_at": "2023-12-14T22:42:13.365069Z", "response": "", "done": true } ``` ``` curl http://localhost:11434/api/generate -d '{ "model": "mistral", "prompt": "reply with a single word" }' HTTP/1.1 200 OK Content-Type: application/x-ndjson Date: Thu, 14 Dec 2023 22:43:05 GMT Connection: close Transfer-Encoding: chunked {"model":"mistral","created_at":"2023-12-14T22:43:05.60168Z","response":" Okay","done":false} {"model":"mistral","created_at":"2023-12-14T22:43:05.616406Z","response":".","done":false} {"model":"mistral","created_at":"2023-12-14T22:43:05.631163Z","response":"","done":true,"context":[733,16289,28793,28705,10071,395,264,2692,1707,733,28748,16289,28793,19811,28723],"total_duration":414743625,"load_duration":760500,"prompt_eval_count":14,"prompt_eval_duration":393924000,"eval_count":2,"eval_duration":14727000} ``` `/chat` ``` curl http://localhost:11434/api/chat -d '{ "model": "mistral" }' HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 Date: Thu, 14 Dec 2023 22:41:56 GMT Content-Length: 132 Connection: close { "model": "mistral", "created_at": "2023-12-14T22:41:56.540246Z", "message": { "role": "assistant", "content": "", "images": null }, "done": true } ``` ``` curl http://localhost:11434/api/chat -d '{ "model": "mistral", "messages": [ { "role": "user", "content": "reply with one word" } ] }' HTTP/1.1 200 OK Content-Type: application/x-ndjson Date: Thu, 14 Dec 2023 22:38:36 GMT Connection: close Transfer-Encoding: chunked {"model":"mistral","created_at":"2023-12-14T22:38:36.625168Z","message":{"role":"assistant","content":" Okay","images":null},"done":false} {"model":"mistral","created_at":"2023-12-14T22:38:36.639622Z","message":{"role":"assistant","content":".","images":null},"done":false} {"model":"mistral","created_at":"2023-12-14T22:38:36.654161Z","message":{"role":"assistant","content":"","images":null},"done":true,"total_duration":417861167,"load_duration":927584,"prompt_eval_count":13,"prompt_eval_duration":396099000,"eval_count":2,"eval_duration":14502000} ``` --- <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-19 15:28:22 -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#21150