[PR #4237] [MERGED] refactor: Simplify functions #8221

Closed
opened 2025-11-11 17:48:04 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/4237
Author: @michaelpoluektov
Created: 7/31/2024
Status: Merged
Merged: 8/1/2024
Merged by: @tjbck

Base: devHead: refactor-webui-main


📝 Commits (10+)

📊 Changes

5 files changed (+284 additions, -392 deletions)

View changed files

📝 backend/apps/socket/main.py (+2 -4)
📝 backend/apps/webui/main.py (+225 -302)
📝 backend/apps/webui/models/models.py (+2 -10)
📝 backend/main.py (+16 -44)
📝 backend/utils/misc.py (+39 -32)

📄 Description

Pull Request Checklist

Motivation: there are no docs on functions, so if people will keep using code as documentation might as well make the code more readable.

Also this makes it simpler to add more features/custom named params to functions.

Testing:

  • Tested with all combinations of function outputting/not outputting stream and OWUI expecting/not expecting stream
  • Did not test with every single possible case (Iterator, Generator, starting/not starting with "data:" etc.): testing welcome.

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

Refactor everything around function calling.

  • Remove unneeded async in get_event_emitter
  • Remove unused imports
  • Split generate_function_chat_completion into multiple smaller functions
  • DRY changes
  • Use dict.pop when appropriate

No functional changes expected: everything should work exactly as before.


🔄 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/4237 **Author:** [@michaelpoluektov](https://github.com/michaelpoluektov) **Created:** 7/31/2024 **Status:** ✅ Merged **Merged:** 8/1/2024 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `refactor-webui-main` --- ### 📝 Commits (10+) - [`3978efd`](https://github.com/open-webui/open-webui/commit/3978efd7104cbaf21ad054080e694f8919f1b306) refac: Refactor functions - [`deec41d`](https://github.com/open-webui/open-webui/commit/deec41d29a850afa62f1607da231ad25aee88cc2) fix: function early returns - [`22a5e19`](https://github.com/open-webui/open-webui/commit/22a5e196c9fd460099c9703a02b8298b5fd4de74) simplify main.py - [`29a3b82`](https://github.com/open-webui/open-webui/commit/29a3b82336cecf7a602e7569478b964f3003667e) refac: reuse stream_message_template - [`006fc34`](https://github.com/open-webui/open-webui/commit/006fc3495ec00e9ac018442f74379f2f1f0f6e8e) fix: stream_message_template - [`baf58ef`](https://github.com/open-webui/open-webui/commit/baf58ef396c0d8652222d1d9edcd6410ce1390eb) refac: use add_or_update_system_message - [`034411e`](https://github.com/open-webui/open-webui/commit/034411e47eda245678249cd23394403d478b7311) fix: type not manifold - [`ae0bb8f`](https://github.com/open-webui/open-webui/commit/ae0bb8f1ebc0d769408753b75df1027c8a2fa009) Merge branch 'dev' of https://github.com/open-webui/open-webui into refactor-webui-main - [`f872671`](https://github.com/open-webui/open-webui/commit/f8726719ef93f28f92e5af550e4109ce3da098b9) refac: rename whole_message_template, silence lsp - [`2e0fa1c`](https://github.com/open-webui/open-webui/commit/2e0fa1c6a09fbf1ba35c5286458838a96f6d8d1a) refac: rename stream_message_template ### 📊 Changes **5 files changed** (+284 additions, -392 deletions) <details> <summary>View changed files</summary> 📝 `backend/apps/socket/main.py` (+2 -4) 📝 `backend/apps/webui/main.py` (+225 -302) 📝 `backend/apps/webui/models/models.py` (+2 -10) 📝 `backend/main.py` (+16 -44) 📝 `backend/utils/misc.py` (+39 -32) </details> ### 📄 Description # Pull Request Checklist Motivation: there are no docs on functions, so if people will keep using code as documentation might as well make the code more readable. Also this makes it simpler to add more features/custom named params to functions. ## Testing: - Tested with all combinations of function outputting/not outputting stream and OWUI expecting/not expecting stream - Did not test with every single possible case (Iterator, Generator, starting/not starting with "data:" etc.): testing welcome. **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. - [x] **Documentation:** Have you updated relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs), or other documentation sources? - [x] **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? - [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 Refactor everything around function calling. - Remove unneeded `async` in `get_event_emitter` - Remove unused imports - Split `generate_function_chat_completion` into multiple smaller functions - DRY changes - Use dict.pop when appropriate No functional changes expected: everything should work exactly as before. --- <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-11 17:48:04 -06: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#8221