[PR #7836] [MERGED] api: (Fix) Enable Tool streaming #11269

Closed
opened 2025-11-12 16:10:25 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/7836
Author: @ParthSareen
Created: 11/26/2024
Status: Merged
Merged: 11/27/2024
Merged by: @ParthSareen

Base: mainHead: parth/tool-streaming


📝 Commits (10+)

  • 1f6f64d Enabling tool-streaming
  • 310bb3e Support streaming for openai compatibility
  • 5b6a3f3 Bugfixes and streaming
  • 6bedbf1 Add tests and address comments
  • 54eac08 Simplifying tool streaming
  • 17bb030 Abstract tool conversion function
  • c67af45 Update server/routes.go
  • ff68ea8 Update server/routes.go
  • 4ad03a8 Update server/routes.go
  • 62ee2b4 Apply suggestions from code review

📊 Changes

4 files changed (+289 additions, -13 deletions)

View changed files

📝 openai/openai.go (+9 -4)
📝 server/model_test.go (+1 -0)
📝 server/routes.go (+31 -1)
📝 server/routes_generate_test.go (+248 -8)

📄 Description

As much desired by the community - https://github.com/ollama/ollama/issues/5796

  • We currently do not support streaming correctly and just return data in .Content if streaming ToolCalls
  • This ends breaks patterns for other clients but also some users who want to set streaming to true and not worry about switching back and forth
  • This fix streams a full tool call back instead of returning partially formed tools - which means if there are multiple tools, a full tool will be returned to the user as soon it is recognized on Ollama's side

TODO:

  • Tests

🔄 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/7836 **Author:** [@ParthSareen](https://github.com/ParthSareen) **Created:** 11/26/2024 **Status:** ✅ Merged **Merged:** 11/27/2024 **Merged by:** [@ParthSareen](https://github.com/ParthSareen) **Base:** `main` ← **Head:** `parth/tool-streaming` --- ### 📝 Commits (10+) - [`1f6f64d`](https://github.com/ollama/ollama/commit/1f6f64d10fc72b7ee199e3e2404e00954f035e69) Enabling tool-streaming - [`310bb3e`](https://github.com/ollama/ollama/commit/310bb3e9c305f63c7a4ce7b7476461bc1e6fc997) Support streaming for openai compatibility - [`5b6a3f3`](https://github.com/ollama/ollama/commit/5b6a3f30dd6792783b4b701479727caaaca85df1) Bugfixes and streaming - [`6bedbf1`](https://github.com/ollama/ollama/commit/6bedbf1e43cfdff34db567a6c58d6cf5f8c261c7) Add tests and address comments - [`54eac08`](https://github.com/ollama/ollama/commit/54eac080477fe43229441fdac08897cf2e88d650) Simplifying tool streaming - [`17bb030`](https://github.com/ollama/ollama/commit/17bb030b0e7e3f5f526739c1ac83757995ac732c) Abstract tool conversion function - [`c67af45`](https://github.com/ollama/ollama/commit/c67af454162f4f1e9985bfd2cbf9b0fb7d46510a) Update server/routes.go - [`ff68ea8`](https://github.com/ollama/ollama/commit/ff68ea86a3ca1c479397fe8fa7c993b0724821d6) Update server/routes.go - [`4ad03a8`](https://github.com/ollama/ollama/commit/4ad03a8c8ecd430f4ba98a10f6c4ff844300c0fa) Update server/routes.go - [`62ee2b4`](https://github.com/ollama/ollama/commit/62ee2b45d4723ce69a5c9b8bd63b2430cfa3b5f6) Apply suggestions from code review ### 📊 Changes **4 files changed** (+289 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `openai/openai.go` (+9 -4) 📝 `server/model_test.go` (+1 -0) 📝 `server/routes.go` (+31 -1) 📝 `server/routes_generate_test.go` (+248 -8) </details> ### 📄 Description As much desired by the community - https://github.com/ollama/ollama/issues/5796 - We currently do not support streaming correctly and just return data in `.Content` if streaming ToolCalls - This ends breaks patterns for other clients but also some users who want to set streaming to true and not worry about switching back and forth - This fix streams a full tool call back instead of returning partially formed tools - which means if there are multiple tools, a full tool will be returned to the user as soon it is recognized on Ollama's side TODO: - [x] Tests --- <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 2025-11-12 16:10:25 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama-ollama#11269