mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-07 03:18:23 -05:00
[PR #14108] [CLOSED] feat: Call native tools automatically within non-streaming chat-completion request. #39021
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/14108
Author: @diwakar-s-maurya
Created: 5/20/2025
Status: ❌ Closed
Base:
dev← Head:patch-5📝 Commits (3)
d5e0c0cimprove native function calling to call multiple tools in a chaincee86d5make MAX_TOOL_CALL_RETRIES equal for both streaming and non-streaming case.a023a88make non-streaming mode work from curl api calls too instead of only from browser.📊 Changes
1 file changed (+1046 additions, -774 deletions)
View changed files
📝
backend/open_webui/utils/middleware.py(+1046 -774)📄 Description
Pull Request Checklist
Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.
Before submitting, make sure you've checked the following:
devbranch.Changelog Entry
Description
The changes are to enhance the chat response processing system with a focus making native tool/function calling capabilities available in non-streaming requests such as a simple curl POST /api/chat/completions API call.
This unlocks capability of using open-webui's model+tools from other simple web application without implementing streaming response handling logic. With the right prompts sent in a API request, open-webui can now become a universal backend for every frontend. Imagine this. You have an simple web-application having a button "Send popularity report of open-webui". The web application can do simple
POST /api/chat/completionsAPI of open-webui to leverage the model+tools and get the work done easily. We can offloaded the entire logic of calling and orchestrating API logic to open-webui (given that tools are added in open-webui).Example:
Currently, if I send this request body to /api/chat/completions,
open-webui returns this, which is not useful. It stopped after tool call instruction generation.
But with this PR code, it will complete all the tools-calls and acheive the task.
Added
Fixed
Screenshots or Videos
The API request/response pairs are mentioned in the description. Kindly see that.
On browser, without this PR, it does not call multiple functions/tools. It gets stuck when function_calling was set to native and streaming was false.

After, with this feature, it does call multiple functions/tools when function_calling is native and streaming is false.

Here is the dummy tool used for demonstration for these screenshots and api calls.
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.