[PR #4602] [MERGED] refactor, perf: Tools refactor (progress PR 1) #21521

Closed
opened 2026-04-20 03:34:07 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/4602
Author: @michaelpoluektov
Created: 8/14/2024
Status: Merged
Merged: 8/17/2024
Merged by: @tjbck

Base: devHead: tools-refac-1


📝 Commits (10+)

  • 3befadb remove unnecessary nesting, remove unused endpoint
  • 589efcd is_chat_completion_request helper, remove nesting
  • 23f1bee cleanup
  • 60003c9 rename to chat_completions_inlet_handler for clarity
  • 556141c refactor task
  • 0c9119d move task to metadata
  • 9fb7096 factor out get_content_from_response
  • a68b918 refactor get_function_call_response
  • ff9d899 fix more LSP errors
  • e866882 factor out get_function_calling_payload

📊 Changes

3 files changed (+350 additions, -447 deletions)

View changed files

📝 backend/apps/webui/models/users.py (+3 -10)
📝 backend/main.py (+346 -436)
📝 backend/utils/task.py (+1 -1)

📄 Description

Pull Request Checklist

Reviewing is easier to be done commit-by-commit. No single commit should break anything.

NOTE:

This is not the PR that implements OpenAI tool calling. This is an intermediate PR that refactors everything around tool calling to better support passing tools to the request body (as well as improve performance slightly).

Before submitting, make sure you've checked the following:

Before submitting, make sure you've checked the following:

  • Target branch: Please verify that the pull request targets the dev branch.
  • Description: Provide a concise description of the changes made in this pull request.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Documentation: Have you updated relevant documentation Open WebUI Docs, or other documentation sources?
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
  • Testing: Have you written and run sufficient tests for validating the changes?
  • Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
  • Prefix: To cleary categorize this pull request, prefix the pull request title, using one of the following:
    • BREAKING CHANGE: Significant changes that may affect compatibility
    • build: Changes that affect the build system or external dependencies
    • ci: Changes to our continuous integration processes or workflows
    • chore: Refactor, cleanup, or other non-functional code changes
    • docs: Documentation update or addition
    • feat: Introduces a new feature or enhancement to the codebase
    • fix: Bug fix or error correction
    • i18n: Internationalization or localization changes
    • perf: Performance improvement
    • refactor: Code restructuring for better maintainability, readability, or scalability
    • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.)
    • test: Adding missing tests or correcting existing tests
    • WIP: Work in progress, a temporary label for incomplete or ongoing work

Changelog Entry

Description

  • Change tool calling pre-processing to only use a single LLM call for all toolkits.
  • Rename functions with "function" in their name that actually refer to "tool"s.
  • Other minor refactoring changes.

Breaking Changes

  • BREAKING CHANGE: Function and pipeline inlets should now expect task to be passed through body["metadata"]["task"] rather than body["task"]. This is consistent with other types of functions/pipelines and should not affect any function/pipeline examples (none of them seem to use task in inlets).

Additional Information

I have tested this with 2 toolkits, one of which had 2 tools, as well as an OpenAI proxy function, default OpenAI API and Ollama (llama3.1:8b). Pipelines were not tested.


🔄 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/open-webui/open-webui/pull/4602 **Author:** [@michaelpoluektov](https://github.com/michaelpoluektov) **Created:** 8/14/2024 **Status:** ✅ Merged **Merged:** 8/17/2024 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `tools-refac-1` --- ### 📝 Commits (10+) - [`3befadb`](https://github.com/open-webui/open-webui/commit/3befadb29f61df4c363697829cc1be0d820a0d50) remove unnecessary nesting, remove unused endpoint - [`589efcd`](https://github.com/open-webui/open-webui/commit/589efcdc5fe61754112312ef275fa6f164362efc) is_chat_completion_request helper, remove nesting - [`23f1bee`](https://github.com/open-webui/open-webui/commit/23f1bee7bd3af6bc935934e5d31240724928cf81) cleanup - [`60003c9`](https://github.com/open-webui/open-webui/commit/60003c976aadfd44f8ff25850872301e564888e6) rename to chat_completions_inlet_handler for clarity - [`556141c`](https://github.com/open-webui/open-webui/commit/556141cdd84db9483afeb3c68d4dc795847b5fc8) refactor task - [`0c9119d`](https://github.com/open-webui/open-webui/commit/0c9119d6199f61c623ea06e0899a2f36c7ecc09d) move task to metadata - [`9fb7096`](https://github.com/open-webui/open-webui/commit/9fb70969d729af13960ddf9b4be5df753299d57e) factor out get_content_from_response - [`a68b918`](https://github.com/open-webui/open-webui/commit/a68b918cbbc84e4b1ecc806c00c7d425c60d31b8) refactor get_function_call_response - [`ff9d899`](https://github.com/open-webui/open-webui/commit/ff9d899f9c5d8318cacc17c23b1df64a64213eea) fix more LSP errors - [`e866882`](https://github.com/open-webui/open-webui/commit/e86688284add6a5a6c37584f666019d4d15745b5) factor out get_function_calling_payload ### 📊 Changes **3 files changed** (+350 additions, -447 deletions) <details> <summary>View changed files</summary> 📝 `backend/apps/webui/models/users.py` (+3 -10) 📝 `backend/main.py` (+346 -436) 📝 `backend/utils/task.py` (+1 -1) </details> ### 📄 Description # Pull Request Checklist Reviewing is easier to be done commit-by-commit. No single commit should break anything. ## NOTE: This is not the PR that implements OpenAI tool calling. This is an intermediate PR that refactors everything around tool calling to better support passing tools to the request body (as well as improve performance slightly). ### Before submitting, make sure you've checked the following: **Before submitting, make sure you've checked the following:** - [x] **Target branch:** Please verify that the pull request targets the `dev` branch. - [x] **Description:** Provide a concise description of the changes made in this pull request. - [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [ ] **Documentation:** Have you updated relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs), or other documentation sources? - [ ] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? - [x] **Testing:** Have you written and run sufficient tests for validating the changes? - [x] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards? - [x] **Prefix:** To cleary categorize this pull request, prefix the pull request title, using one of the following: - **BREAKING CHANGE**: Significant changes that may affect compatibility - **build**: Changes that affect the build system or external dependencies - **ci**: Changes to our continuous integration processes or workflows - **chore**: Refactor, cleanup, or other non-functional code changes - **docs**: Documentation update or addition - **feat**: Introduces a new feature or enhancement to the codebase - **fix**: Bug fix or error correction - **i18n**: Internationalization or localization changes - **perf**: Performance improvement - **refactor**: Code restructuring for better maintainability, readability, or scalability - **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.) - **test**: Adding missing tests or correcting existing tests - **WIP**: Work in progress, a temporary label for incomplete or ongoing work # Changelog Entry ### Description - Change tool calling pre-processing to only use a single LLM call for all toolkits. - Rename functions with "function" in their name that actually refer to "tool"s. - Other minor refactoring changes. ### Breaking Changes - **BREAKING CHANGE**: Function and pipeline inlets should now expect `task` to be passed through `body["metadata"]["task"]` rather than `body["task"]`. This is consistent with other types of functions/pipelines and should not affect any function/pipeline examples (none of them seem to use `task` in inlets). ### Additional Information I have tested this with 2 toolkits, one of which had 2 tools, as well as an OpenAI proxy function, default OpenAI API and Ollama (llama3.1:8b). Pipelines were not tested. --- <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-20 03:34:07 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#21521