[PR #4235] [MERGED] add done_reason to the api #42669

Closed
opened 2026-04-24 22:24:46 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/4235
Author: @BruceMacD
Created: 5/7/2024
Status: Merged
Merged: 5/9/2024
Merged by: @BruceMacD

Base: mainHead: brucemacd/stop-reason


📝 Commits (4)

📊 Changes

4 files changed (+44 additions, -40 deletions)

View changed files

📝 api/types.go (+7 -3)
📝 llm/server.go (+12 -4)
📝 openai/openai.go (+6 -18)
📝 server/routes.go (+19 -15)

📄 Description

When generating content using the chat or generate endpoints it is useful to know the reason the LLM stopped generating.

This may be due to 3 reasons currently in our API:

  • "stop" - The generation hit a stop token.
  • "length" - The maximum num_tokens was reached.
  • "load" - The request was sent with an empty body to load the model.

This change proposes a new done_reason parameter on the chat and generate responses.

Moving forward this change help us give more information to the user. For example we can add timeouts on requests to prevent the server from hanging.

Follow-up:

  • update docs
  • update javascript and python client libraries

Related: #4230


🔄 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/4235 **Author:** [@BruceMacD](https://github.com/BruceMacD) **Created:** 5/7/2024 **Status:** ✅ Merged **Merged:** 5/9/2024 **Merged by:** [@BruceMacD](https://github.com/BruceMacD) **Base:** `main` ← **Head:** `brucemacd/stop-reason` --- ### 📝 Commits (4) - [`0e2a456`](https://github.com/ollama/ollama/commit/0e2a4564b7f7a8274f4322362d08e1c060dcc533) add finish_reason to the api - [`74a68cf`](https://github.com/ollama/ollama/commit/74a68cf686b7f770a848fd0a5f6a5d0de4e36247) done_reason - [`263493d`](https://github.com/ollama/ollama/commit/263493dc0cf5c712f6964c00236929bd39f34880) Update types.go - [`0d3ce18`](https://github.com/ollama/ollama/commit/0d3ce189e0128ea6258be14ecb7b9179f67d3dad) do not omit empty done reason ### 📊 Changes **4 files changed** (+44 additions, -40 deletions) <details> <summary>View changed files</summary> 📝 `api/types.go` (+7 -3) 📝 `llm/server.go` (+12 -4) 📝 `openai/openai.go` (+6 -18) 📝 `server/routes.go` (+19 -15) </details> ### 📄 Description When generating content using the chat or generate endpoints it is useful to know the reason the LLM stopped generating. This may be due to 3 reasons currently in our API: - "stop" - The generation hit a stop token. - "length" - The maximum `num_tokens` was reached. - "load" - The request was sent with an empty body to load the model. This change proposes a new `done_reason` parameter on the chat and generate responses. Moving forward this change help us give more information to the user. For example we can add timeouts on requests to prevent the server from hanging. Follow-up: - update docs - update javascript and python client libraries Related: #4230 --- <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-24 22:24:46 -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#42669